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

Fix: Provider produced inconsistent result after apply #2064

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

parisholley
Copy link

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 parisholley requested a review from a team as a code owner October 11, 2024 00:47
@parisholley
Copy link
Author

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

createOnly := false
readOnly := false
writeOnly := false
var chunks [][]string
// Build combinations
for i := 1; i <= len(path); i++ {
combination := path[:i]
chunks = append(chunks, combination)
}
for i := 0; i < len(chunks); i++ {
if e.CfResource.CreateOnlyProperties.ContainsPath(chunks[i]) {
createOnly = true
}
if e.CfResource.ReadOnlyProperties.ContainsPath(chunks[i]) {
readOnly = true
}
if e.CfResource.WriteOnlyProperties.ContainsPath(chunks[i]) {
writeOnly = true
}
}

if optional && !computed && !writeOnly {
computed = true
}

@ewbankkit ewbankkit added the code-generation Relates to the conversion of CloudFormation schema to Terraform schema at buildtime. label Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-generation Relates to the conversion of CloudFormation schema to Terraform schema at buildtime. needs-triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants