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-1938] Ignore similar config values when reading config. #108

Conversation

juanmanuel-tirado
Copy link
Contributor

When reading an existing application now:

  • Ignore configuration elements with default values. They are not relevant.
  • Ignore configuration values similar to the already existing entries. If the read entry differs, this value will overwrite the existing value in the plan.

This Fixes #96

Follow a similar scenario to the one described in #96.

  1. Prepare a plan
provider "juju" {}

resource "juju_model" "test" {
  name = "test"
}

resource "juju_application" "indico" {
  name  = "indico"
  model = juju_model.test.name

  charm {
    name = "indico"
  }

  config = {
    indico_no_reply_email = "test@example.com"
  }
}
  1. Create the corresponding environment in Juju 2.9.37
juju bootstrap localhost controllertest
juju add-model test
juju deploy indico --config indico_no_reply_email="test@example.com"
  1. Run terraform
terraform init --plugin-dir=/whereveryourpluginsare/ -upgrade
terraform import juju_application.indico test:indico
  1. Check that the formed plan does not show any changes in the configuration
Terraform will perform the following actions:

  # juju_application.indico will be updated in-place
  ~ resource "juju_application" "indico" {
        id     = "test:indico"
        name   = "indico"
        # (4 unchanged attributes hidden)

      ~ charm {
          ~ channel  = "stable" -> "latest/stable"
            name     = "indico"
            # (2 unchanged attributes hidden)
        }
    }

  # juju_model.test will be created
  + resource "juju_model" "test" {
      + id   = (known after apply)
      + name = "test"
      + type = (known after apply)

      + cloud {
          + name   = (known after apply)
          + region = (known after apply)
        }
    }

Plan: 1 to add, 1 to change, 0 to destroy.

Notice that only the channel will be modified to be latest/stable.

  1. (Additional) Update the configuration using the juju cli and refresh
juju config indico indico_no_reply_email="otheremail@example.com"
terraform plan
....
# juju_application.indico will be updated in-place
  ~ resource "juju_application" "indico" {
      ~ config = {
          ~ "indico_no_reply_email" = "otheremail@example.com" -> "test@example.com"
        }
        id     = "test:indico"
        name   = "indico"
        # (3 unchanged attributes hidden)

      ~ charm {
          ~ channel  = "stable" -> "latest/stable"
            name     = "indico"
            # (2 unchanged attributes hidden)
        }
    }

  # juju_model.test will be created
  + resource "juju_model" "test" {
      + id   = (known after apply)
      + name = "test"
      + type = (known after apply)

      + cloud {
          + name   = (known after apply)
          + region = (known after apply)
        }
    }

Plan: 1 to add, 1 to change, 0 to destroy.

@juanmanuel-tirado juanmanuel-tirado merged commit 7306402 into juju:main Nov 16, 2022
@juanmanuel-tirado juanmanuel-tirado deleted the JUJU-1938_configuration_is_properly_configured branch November 16, 2022 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After terraform import charm config isn't correctly recognised
1 participant