hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.61k stars 9k forks source link

[Bug]: DynamoDB: removing server_side_encryption with enabled=true results in empty plan #29811

Open isaac-s opened 1 year ago

isaac-s commented 1 year ago

Terraform Core Version

1.3.7

AWS Provider Version

4.57.0

Affected Resource(s)

Expected Behavior

Terraform should yield a plan to remove the server_side_encryption definition, resulting (after application) in encryption "Managed by DynamoDB"

Actual Behavior

Empty plan. Terraform doesn't prompt to change anything in the table.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_dynamodb_table" "my_table" {
  name           = "my-table"
  billing_mode   = "PROVISIONED"
  hash_key       = "Id"

  attribute {
    name = "Id"
    type = "S"
  }

  server_side_encryption {
    enabled = true
  }
}

Steps to Reproduce

Apply the configuration above. This will result in a table created with encryption managed by KMS. Then, remove the server_side_encryption block, and run terraform plan. You'd expect Terraform to detect this as a change, but it doesn't.

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

fergoid commented 1 year ago

I got the same behaviour with the 'point_in_time_recovery' attribute in provider version 4.63.0. When I changed one of the core attributes the server_side_encryption change was detected.

ethanmills commented 2 months ago

The same also applies to kms_key_arn. This means it's impossible to toggle between Amazon managed key and CMK based on a variable, something like kms_key_arn = var.enabled ? key_arn : null.

I have also tried kms_key_arn = var.enabled ? key_arn : data.aws_kms_alias.dynamo_aws_managed.target_key_arn, but this doesn't work because attempting to set the key ARN explicitly to the value it already is implicitly fails.