heroku/terraform-provider-heroku

Creating add-on attachments results in recreating each time you apply

Closed this issue · 4 comments

> terraform -v
Terraform v0.12.24
+ provider.heroku v2.4.0

This is related to the heroku_addon_attachment resource

When I create the attachment per the documentation, the attachment is created properly, however an immediate terraform plan shows that it must replace the attachment. It shows that the id will be changed from a UUID to the underlying addon's name

  • Re-applying this does not fix the problem.
  • Removing it from state and re-importing does not fix the problem.
  • Using the add-ons "name" for addon_id (instead of it's id) does not fix the problem (the addon attachment is also correctly created in this case FWIW).

I don't have a workaround other than not using this feature.

Here is a minimal config:

resource "heroku_app" "hermes" {
  name   = "example-hermes"
  region = "us"
}

resource "heroku_addon" "hermes-database" {
  app  = heroku_app.hermes.name
  plan = "heroku-postgresql:standard-0"
}

resource "heroku_app" "brannigan" {
  name   = "example-brannigan"
  region = "us"
}

resource "heroku_addon_attachment" "brannigan-hermes-database" {
  app_id   = heroku_app.brannigan.id
  addon_id = heroku_addon.hermes-database.id
  name     = "database"
}

After an apply, a terraform plan shows this:

-/+ resource "heroku_addon_attachment" "brannigan-hermes-database" {
      ~ addon_id = "«UUID»" -> "postgresql-«name»-«number»" # forces replacement
        app_id   = "mucho-mejor-brannigan"
      ~ id       = "«uuid»" -> (known after apply)
        name     = "hermes_database"
    }

Expected Behavior

The add-on attachment should not have been touched or needed to be changed

Actual Behavior

Add-on attachment changes each time a terraform plan (or apply) is run.

References

See #73

Hi @davetron5000,

Could you paste the state file after you apply your 'minimal config', with the sensitive info redacted? These resources shouldn't be using the name as the resource ID.

Thanks.

I just tried to recreate from scratch and I cannot reproduce. I had previously removed this from my config and since there's no way to get the attachment ID I can't re-import it and try with my actual setup. Unless @FreekingDean can recreate I guess we can close this.

Fortunately for me, unfortunately for @davetron5000 I have not been able to reproduce this.

Alright, closing this issue for now. Feel free to re-open if happening again.