Search code examples
amazon-web-servicesterraformamazon-dynamodbterraform-provider-aws

Ignore changes on terraform aws_dynamodb_table_item for aws replica attributes


I have below terraform code to create the dynamodb table items

resource "aws_dynamodb_table_item" "docroot" {
  count = length(XXX)
  table_name = XXXX
  hash_key   = XXXXX

  item = <<EOF
{
  "XXXX":    { "S": "XXXX, count.index)}" },
  "XXXX": { "S": "XXXX, count.index)}" },
  "XXXX":  { "S": "XXXX, count.index)}" }
}
EOF

}

it works fine. but whenever the terraform is executed, the below changes as always there.

  #  will be updated in-place
  ~ resource "aws_dynamodb_table_item" "docroot" {
        
      ~ item       = jsonencode(
          ~ {
              - aws:rep:deleting     = {
                  - BOOL = false
                } -> null
              - aws:rep:updateregion = {
                  - S = "us-west-2"
                } -> null
              - aws:rep:updatetime   = {
                  - N = "1682511411.190001"
                } -> null
                # (3 unchanged elements hidden)
            }
        )
        # (2 unchanged attributes hidden)
    }

Tried to add a ignore changes on these attributes

 lifecycle {
    ignore_changes=[
      "item.aws:rep:deleting",
    ]
  }

This is not working..

│ Error: Invalid character
│
│   on xxx.tf line 21, in resource "aws_dynamodb_table_item" "docroot":
│   21:       "item.aws:rep:deleting",
│
│ Expected an attribute access or an index operator.`

Terraform version and Provider:
Terraform v1.1.6
+ provider registry.terraform.io/hashicorp/aws v4.64.0

Solution

  • aws replica attributes changes in aws_dynamodb_table_items was due to bug in aws provider. https://github.com/hashicorp/terraform-provider-aws/issues/30690 it was introduced in 4.19. so if the aws version is locked at 4.18.0 till the bug is fixed, the changes won't show up.