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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamodb_table_item does not update after change is made #15700

Closed
sanp opened this issue Oct 17, 2020 · 4 comments · Fixed by #25326
Closed

dynamodb_table_item does not update after change is made #15700

sanp opened this issue Oct 17, 2020 · 4 comments · Fixed by #25326
Assignees
Labels
bug Addresses a defect in current functionality. service/dynamodb Issues and PRs that pertain to the dynamodb service.
Milestone

Comments

@sanp
Copy link

sanp commented Oct 17, 2020

When I create a dynamodb item in terraform, it works fine. But when I then make a change to the item, the terraform apply succeeds, but the change does not take effect in the actual Dynamo table.

Terraform version

Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v3.11.0

Affected Resource

aws_dynamodb_table_item

Terraform Configuration Files

I am just using the official example on the resource page.

First apply:

resource "aws_dynamodb_table" "example" {
  name           = "example-name"
  read_capacity  = 10
  write_capacity = 10
  hash_key       = "exampleHashKey"

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

resource "aws_dynamodb_table_item" "example" {
  table_name = aws_dynamodb_table.example.name
  hash_key   = aws_dynamodb_table.example.hash_key

  item = <<ITEM
{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "two": {"N": "22222"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
ITEM
}

If I run terraform apply, this produces the expected table, with all five columns.

Second apply:

If I then change the item configuration to:

resource "aws_dynamodb_table_item" "example" {
  table_name = aws_dynamodb_table.example.name
  hash_key   = aws_dynamodb_table.example.hash_key

  item = <<ITEM
{
  "exampleHashKey": {"S": "something"},
  "one": {"N": "11111"},
  "three": {"N": "33333"},
  "four": {"N": "44444"}
}
ITEM
}

and run an apply, no change is made in the table in AWS. All columns still exist.

Debug Output

After running the second apply:

aws_dynamodb_table.example: Refreshing state... [id=example-name]
aws_dynamodb_table_item.example: Refreshing state... [id=example-name|exampleHashKey||something|]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # aws_dynamodb_table_item.example will be updated in-place
  ~ resource "aws_dynamodb_table_item" "example" {
        hash_key   = "exampleHashKey"
        id         = "example-name|exampleHashKey||something|"
      ~ item       = jsonencode(
          ~ {
                exampleHashKey = {
                    S = "something"
                }
                four           = {
                    N = "44444"
                }
                one            = {
                    N = "11111"
                }
                three          = {
                    N = "33333"
                }
              - two            = {
                  - N = "22222"
                } -> null
            }
        )
        table_name = "example-name"
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_dynamodb_table_item.example: Modifying... [id=example-name|exampleHashKey||something|]
aws_dynamodb_table_item.example: Modifications complete after 0s [id=example-name|exampleHashKey||something|]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Expected Behavior

I expect the second terraform apply to update the dynamo table in AWS and remove the "two": {"N": "22222"} column from the table.

Actual Behavior

The terraform apply succeeds according to the output. However, the table in AWS is not updated. All original columns still exist in the table.

Steps to Reproduce

  1. Run terraform apply using the first apply configuration.
  2. Update the configuration to remove one of the items and run terraform apply a second time.
@ghost ghost added the service/dynamodb Issues and PRs that pertain to the dynamodb service. label Oct 17, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 17, 2020
@sanp
Copy link
Author

sanp commented Nov 13, 2020

Can someone please respond to this -- I just upgraded to

Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.15.0

and am still seeing the same bug.

@breathingdust breathingdust added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 16, 2021
@ftaib
Copy link

ftaib commented Oct 8, 2021

I am also still seeing the same bug.

Terraform v1.0.2
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v3.61.0

@github-actions
Copy link

This functionality has been released in v4.19.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/dynamodb Issues and PRs that pertain to the dynamodb service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants