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

resource/aws_dynamodb_table_item: Correctly handle List and Map attribute JSON values #30712

Merged
merged 7 commits into from
Apr 13, 2023

Conversation

gdavison
Copy link
Contributor

Description

When using a List ("L") or Map ("M") attribute in a DynamoDB Table Item, a plan was showing a diff, like the following:

~ resource "aws_dynamodb_table_item" "item" {
        id         = "doormat-configuration|key||ssh_sign_ttl_config|"
      ~ item       = jsonencode(
          ~ {
              ~ value                = {
                  ~ M = {
                      ~ valid_after  = {
                          - B    = null -> null
                          - BOOL = null -> null
                          - BS   = null -> null
                          - L    = null -> null
                          - M    = null -> null
                          - NS   = null -> null
                          - NULL = null -> null
                          - S    = null -> null
                          - SS   = null -> null
                            # (1 unchanged element hidden)
                        }
                      ~ valid_before = {
                          - B    = null -> null
                          - BOOL = null -> null
                          - BS   = null -> null
                          - L    = null -> null
                          - M    = null -> null
                          - NS   = null -> null
                          - NULL = null -> null
                          - S    = null -> null
                          - SS   = null -> null
                            # (1 unchanged element hidden)
                        }
                    }
                }
                # (1 unchanged element hidden)
            }
        )
        # (2 unchanged attributes hidden)
    }

The unchanged values, an "N" in this case, are indicated by # (1 unchanged element hidden).

Relations

Closes #30689

References

Output from Acceptance Testing

$ make testacc PKG=dynamodb TESTS='TestAccDynamoDBTableItem_|TestAccDynamoDBTableItemDataSource_'

--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey (37.42s)
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey (54.76s)
--- PASS: TestAccDynamoDBTableItem_rangeKey (55.10s)
--- PASS: TestAccDynamoDBTableItem_disappears (55.13s)
--- PASS: TestAccDynamoDBTableItem_wonkyItems (55.15s)
--- PASS: TestAccDynamoDBTableItemDataSource_basic (55.57s)
--- PASS: TestAccDynamoDBTableItemDataSource_projectionExpression (56.14s)
--- PASS: TestAccDynamoDBTableItem_withMultipleItems (56.19s)
--- PASS: TestAccDynamoDBTableItemDataSource_expressionAttributeNames (56.25s)
--- PASS: TestAccDynamoDBTableItem_basic (59.57s)
--- PASS: TestAccDynamoDBTableItem_mapOutOfBandUpdate (71.58s)
--- PASS: TestAccDynamoDBTableItem_update (73.49s)
--- PASS: TestAccDynamoDBTableItem_updateWithRangeKey (73.51s)

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added service/dynamodb Issues and PRs that pertain to the dynamodb service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. labels Apr 13, 2023
Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% make testacc TESTARGS='-run=TestAccDynamoDBTableItem' PKG=dynamodb ACCTEST_PARALLELISM=3
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/dynamodb/... -v -count 1 -parallel 3  -run=TestAccDynamoDBTableItem -timeout 180m
=== RUN   TestAccDynamoDBTableItemDataSource_basic
=== PAUSE TestAccDynamoDBTableItemDataSource_basic
=== RUN   TestAccDynamoDBTableItemDataSource_projectionExpression
=== PAUSE TestAccDynamoDBTableItemDataSource_projectionExpression
=== RUN   TestAccDynamoDBTableItemDataSource_expressionAttributeNames
=== PAUSE TestAccDynamoDBTableItemDataSource_expressionAttributeNames
=== RUN   TestAccDynamoDBTableItem_basic
=== PAUSE TestAccDynamoDBTableItem_basic
=== RUN   TestAccDynamoDBTableItem_rangeKey
=== PAUSE TestAccDynamoDBTableItem_rangeKey
=== RUN   TestAccDynamoDBTableItem_withMultipleItems
=== PAUSE TestAccDynamoDBTableItem_withMultipleItems
=== RUN   TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
=== RUN   TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== PAUSE TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== RUN   TestAccDynamoDBTableItem_wonkyItems
=== PAUSE TestAccDynamoDBTableItem_wonkyItems
=== RUN   TestAccDynamoDBTableItem_update
=== PAUSE TestAccDynamoDBTableItem_update
=== RUN   TestAccDynamoDBTableItem_updateWithRangeKey
=== PAUSE TestAccDynamoDBTableItem_updateWithRangeKey
=== RUN   TestAccDynamoDBTableItem_disappears
=== PAUSE TestAccDynamoDBTableItem_disappears
=== RUN   TestAccDynamoDBTableItem_mapOutOfBandUpdate
=== PAUSE TestAccDynamoDBTableItem_mapOutOfBandUpdate
=== CONT  TestAccDynamoDBTableItemDataSource_basic
=== CONT  TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey
=== CONT  TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsSameRangeKey (30.54s)
=== CONT  TestAccDynamoDBTableItem_withMultipleItems
--- PASS: TestAccDynamoDBTableItem_withDuplicateItemsDifferentRangeKey (48.61s)
=== CONT  TestAccDynamoDBTableItem_rangeKey
--- PASS: TestAccDynamoDBTableItemDataSource_basic (48.86s)
=== CONT  TestAccDynamoDBTableItem_basic
--- PASS: TestAccDynamoDBTableItem_withMultipleItems (45.29s)
=== CONT  TestAccDynamoDBTableItemDataSource_expressionAttributeNames
--- PASS: TestAccDynamoDBTableItem_basic (46.75s)
=== CONT  TestAccDynamoDBTableItemDataSource_projectionExpression
--- PASS: TestAccDynamoDBTableItem_rangeKey (48.80s)
=== CONT  TestAccDynamoDBTableItem_updateWithRangeKey
--- PASS: TestAccDynamoDBTableItemDataSource_expressionAttributeNames (53.82s)
=== CONT  TestAccDynamoDBTableItem_mapOutOfBandUpdate
--- PASS: TestAccDynamoDBTableItemDataSource_projectionExpression (43.11s)
=== CONT  TestAccDynamoDBTableItem_disappears
--- PASS: TestAccDynamoDBTableItem_updateWithRangeKey (56.29s)
=== CONT  TestAccDynamoDBTableItem_update
--- PASS: TestAccDynamoDBTableItem_mapOutOfBandUpdate (42.33s)
=== CONT  TestAccDynamoDBTableItem_wonkyItems
--- PASS: TestAccDynamoDBTableItem_disappears (36.42s)
--- PASS: TestAccDynamoDBTableItem_update (39.65s)
--- PASS: TestAccDynamoDBTableItem_wonkyItems (24.60s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/dynamodb	213.278s

@ewbankkit ewbankkit added the bug Addresses a defect in current functionality. label Apr 13, 2023
@gdavison gdavison merged commit 208030f into main Apr 13, 2023
@gdavison gdavison deleted the b-dynamodb-table-item branch April 13, 2023 21:38
@github-actions github-actions bot added this to the v4.63.0 milestone Apr 13, 2023
github-actions bot pushed a commit that referenced this pull request Apr 13, 2023
@github-actions
Copy link

This functionality has been released in v4.63.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!

alewando pushed a commit to alewando/terraform-provider-aws that referenced this pull request Apr 14, 2023
@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, 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 May 16, 2023
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. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: aws_dynamodb_table_item List and Map attributes do not strip null JSON values
2 participants