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

b/fix constant drift when nested required attributes have no defaults #2022

Merged
merged 21 commits into from
Sep 18, 2024

Conversation

johnsonaj
Copy link
Contributor

@johnsonaj johnsonaj commented Sep 17, 2024

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.

Description

When a required attributed that is nested inside a computed,optional attribute does not have a default set it can cause a constant drift.

This PR sets all nested required attributes to also be computed,optional. To maintain the required validation, a new NotNull validator is added. This will set the attribute as required when not configured, and the entire object is not computed

References

Closes #1216
Closes #1847
Closes #1819
Closes #1795
Closes #1852
Closes #1714
Closes #1854
Closes #1855

Testing

Before

  # awscc_lambda_function.main will be updated in-place
  ~ resource "awscc_lambda_function" "main" {
      ~ code                           = {
          + image_uri          = (known after apply)
          + s3_bucket          = (known after apply)
          + s3_key             = (known after apply)
          + s3_object_version  = (known after apply)
          + source_kms_key_arn = (known after apply)
            # (1 unchanged attribute hidden)
        }
      + code_signing_config_arn        = (known after apply)
      + dead_letter_config             = (known after apply)
      + file_system_configs            = (known after apply)
        id                             = "lambda_function_name"
      + image_config                   = (known after apply)
      + kms_key_arn                    = (known after apply)
      + layers                         = (known after apply)
      + reserved_concurrent_executions = (known after apply)
      + tags                           = (known after apply)
      + vpc_config                     = (known after apply)
        # (18 unchanged attributes hidden)
    }

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

After

awscc_iam_role.main: Refreshing state... [id=DSEHI0RoHDb9GwstKSiOtQ3RY-CNvIdazwawSR]
awscc_lambda_function.main: Refreshing state... [id=lambda_function_name]

No changes. Your infrastructure matches the configuration.

Before

  # awscc_dynamodb_table.test will be updated in-place
  ~ resource "awscc_dynamodb_table" "test" {
      + global_secondary_indexes             = (known after apply)
        id                                   = "table-name"
      + import_source_specification          = (known after apply)
      + key_schema                           = jsonencode(
            [
              + {
                  + AttributeName = "id"
                  + KeyType       = "HASH"
                },
            ]
        )
      + kinesis_stream_specification         = (known after apply)
      + local_secondary_indexes              = (known after apply)
      + provisioned_throughput               = (known after apply)
      + resource_policy                      = (known after apply)
      + stream_arn                           = (known after apply)
      + stream_specification                 = (known after apply)
      + table_class                          = (known after apply)
      + tags                                 = (known after apply)
        # (10 unchanged attributes hidden)
    }

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

After

awscc_dynamodb_table.test: Refreshing state... [id=table-name]

No changes. Your infrastructure matches the configuration.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

@johnsonaj johnsonaj marked this pull request as ready for review September 18, 2024 18:08
@johnsonaj johnsonaj requested a review from a team as a code owner September 18, 2024 18:08
@johnsonaj johnsonaj added bug code-generation Relates to the conversion of CloudFormation schema to Terraform schema at buildtime. documentation labels Sep 18, 2024
@johnsonaj johnsonaj changed the title b/fix constant drift when required attributes have no defaults b/fix constant drift when nested required attributes have no defaults Sep 18, 2024
@johnsonaj johnsonaj merged commit ef97dde into main Sep 18, 2024
3 checks passed
@johnsonaj johnsonaj deleted the b-computed_optional_nested_attributes branch September 19, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment