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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional/Computed attributes #191

Closed
ewbankkit opened this issue Sep 28, 2021 · 3 comments 路 Fixed by #667
Closed

Optional/Computed attributes #191

ewbankkit opened this issue Sep 28, 2021 · 3 comments 路 Fixed by #667
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.
Milestone

Comments

@ewbankkit
Copy link
Contributor

ewbankkit commented Sep 28, 2021

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
  • 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.

There are attributes that are currently marked as Optional: true, Computed: false which are in reality Optional: true, Computed: true.
An example is the awscc_athena_workgroup's work_group_configuration attributes.
When not specified on creation, AWS defines values and returns them on resource read:

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # awscc_athena_work_group.test will be updated in-place
  ~ resource "awscc_athena_work_group" "test" {
        id                       = "awscc-testing"
        name                     = "awscc-testing"
      - state                    = "ENABLED" -> null
        tags                     = [
            {          },
        ]
      - work_group_configuration = {
        - enforce_work_group_configuration   = true -> null
        - engine_version                     = {
          - effective_engine_version = "Athena engine version 2" -> null
          - selected_engine_version  = "AUTO" -> null
        }
        - publish_cloudwatch_metrics_enabled = true -> null
        - requester_pays_enabled             = false -> null
      }
        # (1 unchanged attribute hidden)
    }

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

In the CloudFormation resource schema, WorkGroupConfiguration is correctly not listed as either required or readOnly so the Terraform resource schema code generator only emits Computed: true.
This could be solved by specifying default values in the CFN schema or by having some other way of signaling that a property is optional but a value will then be determined for you.

@ewbankkit
Copy link
Contributor Author

ewbankkit commented Oct 4, 2021

The JSON Schema default keyword is not required so AWS will not always specify the attributes' default values.

@breathingdust
Copy link
Member

After reviewing this issue with the AWS Cloud Control team we will change the provider generation code to mark all optional attributes with no defaults specified as Optional/Computed. This will prevent diffs from showing where an unspecified default value is applied and no value is set by the practioner.

@ewbankkit ewbankkit added 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. and removed upstream-aws Unable to proceed due to missing or broken functionality from an AWS dependency. thinking labels Sep 27, 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
Development

Successfully merging a pull request may close this issue.

2 participants