terraform-provider-awscc icon indicating copy to clipboard operation
terraform-provider-awscc copied to clipboard

Resource schemas should error if passed improper arguments

Open drewmullen opened this issue 3 years ago • 1 comments

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.

Terraform CLI and Terraform AWS Cloud Control Provider Version

Affected Resource(s)

  • awscc_s3_bucket

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_s3_bucket" "main" {
  bucket_name       = "tesasdfasdfasdflkjsdflk"

  bucket_encryption = {
    bucket_key_enabled = true # incorrect location

    server_side_encryption_configuration = [{
      # bucket_key_enabled = true # correct location
      server_side_encryption_by_default = {
        sse_algorithm = "AES256"
      }
    }]
   }
}

Expected Behavior

Schema should error when it finds keys that arent expected

Actual Behavior

It just drops the key from plan but still outputs them (assume theyre part of state)

image

Steps to Reproduce

  1. terraform apply

drewmullen avatar Apr 06 '22 14:04 drewmullen

Here's the CloudFormation and terraform-plugin-framework defined schemas:

https://github.com/hashicorp/terraform-provider-awscc/blob/63e64b3337936a19ea881d022aecc798126d692f/internal/aws/s3/bucket_resource_gen.go#L324-L426

It could actually be a related issue to https://github.com/hashicorp/terraform/issues/30669 where terraform-plugin-sdk was actually providing the validation previously (in a different schema scenario), not Terraform CLI itself, and terraform-plugin-framework does not implement it. Although in this case, single nested attributes is a protocol version 6 feature, so it's a newer thing requiring validation.

bflad avatar Apr 07 '22 15:04 bflad