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

awscc_cassandra_table - force replacement due to attribute column_type value

Open wellsiau-aws opened this issue 1 year 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_cassandra_table

Terraform Configuration Files

Running the following configuration after the first apply will force replacement:

resource "awscc_cassandra_table" "awscc_cassandra_table_example" {
  keyspace_name = awscc_cassandra_keyspace.awscc_cassandra_example.id
  partition_key_columns = [{
    column_name = "Message"
    column_type = "ASCII"
  }]
}

Debug Output

Terraform will perform the following actions:

  # awscc_cassandra_table.awscc_cassandra_table_example must be replaced
-/+ resource "awscc_cassandra_table" "awscc_cassandra_table_example" {
      ~ billing_mode                   = {
          ~ mode                   = "ON_DEMAND" -> (known after apply)
          + provisioned_throughput = (known after apply)
        } -> (known after apply)
      ~ client_side_timestamps_enabled = true -> (known after apply)
      + clustering_key_columns         = (known after apply)
      ~ default_time_to_live           = 0 -> (known after apply)
      ~ encryption_specification       = {
          ~ encryption_type    = "AWS_OWNED_KMS_KEY" -> (known after apply)
          + kms_key_identifier = (known after apply)
        } -> (known after apply)
      ~ id                             = "awscc_cassandra_example|6fNOGZ5tQrypwtArGxwmpyfpA_Ru9hVyDEpTsR" -> (known after apply)
      ~ partition_key_columns          = [ # forces replacement
          ~ {
              ~ column_type = "ascii" -> "ASCII"
                # (1 unchanged attribute hidden)
            },
        ]
      ~ point_in_time_recovery_enabled = false -> (known after apply)
      + regular_columns                = (known after apply)
      ~ table_name                     = "6fNOGZ5tQrypwtArGxwmpyfpA_Ru9hVyDEpTsR" -> (known after apply)
      + tags                           = (known after apply)
        # (1 unchanged attribute hidden)
    }

Expected Behavior

Subsequent terraform apply should not force replacement

Actual Behavior

Terraform detected changes on column_type and force replacement

Steps to Reproduce

  1. terraform apply
  2. let resource stabilize and re-run terraform apply

Important Factoids

Reference to the data types : https://docs.aws.amazon.com/keyspaces/latest/devguide/cql.elements.html#cql.data-types

References

  • #1178

wellsiau-aws avatar Sep 07 '23 04:09 wellsiau-aws

Cfn schema for AWS::Cassandra::Table does not require specific pattern:

  "typeName": "AWS::Cassandra::Table",
  "description": "Resource schema for AWS::Cassandra::Table",
  "definitions": {
    "Column": {
      "type": "object",
      "properties": {
        "ColumnName": {
          "type": "string",
          "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_]{1,47}$"
        },
        "ColumnType": {
          "type": "string"
        }
      },
      "required": [
        "ColumnName",
        "ColumnType"
      ],
      "additionalProperties": false
    }

Hence there's no validation on the resource handler: https://github.com/hashicorp/terraform-provider-awscc/blob/main/internal/aws/cassandra/table_resource_gen.go#L333-L348

I believe this require upstream update to the schema to accomodate such validation

wellsiau-aws avatar Sep 07 '23 04:09 wellsiau-aws