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

Force all Optional attributes to Computed #667

Merged
merged 149 commits into from
Sep 27, 2022
Merged

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Sep 12, 2022

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request
  • The resources and data sources in this provider are generated from the CloudFormation schema, so they can only support the actions that the underlying schema supports. For this reason submitted bugs should be limited to defects in the generation and runtime code of the provider. Customizing behavior of the resource, or noting a gap in behavior are not valid bugs and should be submitted as enhancements to AWS via the CloudFormation Open Coverage Roadmap.

Closes #191.
Closes #301.
Closes #185.
Closes #220.
Closes #401.
Closes #389.
Closes #362.

This PR addresses the unexpected drift detection reported by Terraform when attributes marked as Optional and with no default value in a resource's CloudFormation schema are not configured by a practitioner but the underlying AWS service applies a default value.
These perpetual diffs are result of a fundamental difference in the way that CloudFormation (and hence the CloudControl API) and Terraform handle unconfigured optional attributes; CloudFormation effectively ignores the attribute but Terraform wants the attribute to have an empty, null value.
To prevent the perpetual diffs we must mark the attributes as Computed when we generate the resource's Terraform schema, indicating that if no value has been configured then Terraform will not perform drift detection on the attribute.

% TF_LOG=ERROR make testacc PKG_NAME=internal/aws/ec2 TESTARGS='-run=TestAccAWSEC2VPC_CidrBlock'
TF_ACC=1 go test ./internal/aws/ec2 -v -count 1 -parallel 20 -run=TestAccAWSEC2VPC_CidrBlock -timeout 180m
=== RUN   TestAccAWSEC2VPC_CidrBlock
=== PAUSE TestAccAWSEC2VPC_CidrBlock
=== CONT  TestAccAWSEC2VPC_CidrBlock
--- PASS: TestAccAWSEC2VPC_CidrBlock (53.13s)
PASS
ok  	github.com/hashicorp/terraform-provider-awscc/internal/aws/ec2	53.994s
% TF_LOG=ERROR make testacc PKG_NAME=internal/aws/iam TESTARGS='-run=TestAccAWSIAMRole_AssumeRolePolicyDocument'
TF_ACC=1 go test ./internal/aws/iam -v -count 1 -parallel 20 -run=TestAccAWSIAMRole_AssumeRolePolicyDocument -timeout 180m
=== RUN   TestAccAWSIAMRole_AssumeRolePolicyDocument
=== PAUSE TestAccAWSIAMRole_AssumeRolePolicyDocument
=== CONT  TestAccAWSIAMRole_AssumeRolePolicyDocument
--- PASS: TestAccAWSIAMRole_AssumeRolePolicyDocument (42.54s)
PASS
ok  	github.com/hashicorp/terraform-provider-awscc/internal/aws/iam	44.481s

@ewbankkit ewbankkit added runtime-handling Relates to runtime handling and conversion of Terraform configuration to CloudFormation. schema-handling Relates to retrieval and handling of CloudFormation schema at buildtime. code-generation Relates to the conversion of CloudFormation schema to Terraform schema at buildtime. and removed runtime-handling Relates to runtime handling and conversion of Terraform configuration to CloudFormation. labels Sep 12, 2022
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. schema-handling Relates to retrieval and handling of CloudFormation schema at buildtime.
Projects
None yet
1 participant