hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
262 stars 120 forks source link

Fix: Provider produced inconsistent result after apply #2064

Open parisholley opened 1 month ago

parisholley commented 1 month ago

I ran into this issue when trying to create a lex bot: #619

Looking through the issue log, I suspect there are a lot of open issues that have the same problem:

My solution addresses two things:

  1. WriteOnly fields should not be marked as "compute: true", otherwise TF will attempt to compare the CloudControl response (which doesn't have the property) to the DesiredState
  2. WriteOnly (and other flags) need to cascade down to child properties, in my case, bot_locale was compute = false, but because some of the properties beneath were marked as compute = true, the error still exists

For anyone wanting to try this, I have published my fork with this fix:

https://registry.terraform.io/providers/parisholley/awscc/latest

As a note, I am curious if this fix maybe negates the need for this previous PR:

1737

parisholley commented 1 month ago

here are the two changes given that most of the touched files are from make resources

https://github.com/hashicorp/terraform-provider-awscc/blob/e814ac470ca4c7054793106d3ec34ce29a149d59/internal/provider/generators/shared/codegen/emitter.go#L123-L147

https://github.com/hashicorp/terraform-provider-awscc/blob/e814ac470ca4c7054793106d3ec34ce29a149d59/internal/provider/generators/shared/codegen/emitter.go#L182-L184