Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Juju offer default name breaks when charm has multiple relations to expose and no name is specified #643

Open
shipperizer opened this issue Dec 10, 2024 · 2 comments
Labels
area/offer kind/bug indicates a bug in the project

Comments

@shipperizer
Copy link

Description

when i'm trying to expose 2 offers from the very same charm and don't specify the name, the default appears to be the application name

this triggers continuous changes to the terraform state

culprit seems to be https://github.com/juju/terraform-provider-juju/blob/main/internal/juju/offers.go#L94-L97

potentially a more sensible default or making the name mandatory might do the trick

Urgency

Casually reporting

Terraform Juju Provider version

0.15.1

Terraform version

v1.7.2dev

Juju version

3.5.5

Terraform Configuration(s)

data "juju_model" "model" {
  name = var.model
}


data "vault_generic_secret" "lego_credentials" {
  path = var.secret_path
}


resource "juju_secret" "lego_plugin_secret" {
  model = data.juju_model.model.name
  name  = "lego-httpreq-plugin-secret"
  value = {
    httpreq-endpoint            = var.lego_config.httpreq_endpoint
    httpreq-http-timeout        = var.lego_config.httpreq_http_timeout
    httpreq-propagation-timeout = var.lego_config.httpreq_propagation_timeout
    httpreq-username            = data.vault_generic_secret.lego_credentials.data["username"]
    httpreq-password            = sensitive(data.vault_generic_secret.lego_credentials.data["password"])
  }
  info = "Secret for LEGO charm, httpreq config information included"
}

resource "juju_access_secret" "grant" {
  secret_id    = juju_secret.lego_plugin_secret.secret_id
  model        = data.juju_model.model.name
  applications = [juju_application.lego.name]
}

resource "juju_application" "lego" {
  name  = var.name
  model = data.juju_model.model.name
  trust = var.trust

  charm {
    name    = var.charm.name
    channel = var.charm.channel
    base    = var.charm.base
  }

  config = {
    email                   = var.lego_config.email
    plugin                  = "httpreq"
    plugin-config-secret-id = juju_secret.lego_plugin_secret.secret_id
  }
}

resource "juju_offer" "certificates" {
  model            = data.juju_model.model.name
  application_name = juju_application.lego.name
  name             = "certificates"
  endpoint         = "certificates"
}

resource "juju_offer" "send_ca_certificate" {
  model            = data.juju_model.model.name
  application_name = juju_application.lego.name
  name             = "send-ca-cert"
  endpoint         = "send-ca-cert"
}


### Reproduce / Test

```shell
terraform init && terraform apply

Debug/Panic Output

No response

Notes & References

No response

@shipperizer shipperizer added kind/bug indicates a bug in the project state/untriaged untriaged bug report labels Dec 10, 2024
@alesstimec
Copy link
Member

Thank you for reporting this issue. We will discuss it and let you know about its resolution as soon as possible.

@alesstimec alesstimec added area/offer and removed state/untriaged untriaged bug report labels Dec 13, 2024
@hmlanigan
Copy link
Member

This is the same behavior as the juju cli: https://github.com/juju/juju/blob/f75387c60dd05478d64f515961f282ab3c6fc5f3/cmd/juju/crossmodel/offer.go#L153-L155

Requiring a name would be a compatibility issue at this point and only necessary when making offers on different endpoints of a single application. However the documentation can be updated to be clear on the behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/offer kind/bug indicates a bug in the project
Projects
None yet
Development

No branches or pull requests

3 participants