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

aws_dynamodb_table_item does not work if one of the field contains a hyphen #10385

Closed
thelo-gaultier opened this issue Oct 4, 2019 · 5 comments · Fixed by #14075
Closed

aws_dynamodb_table_item does not work if one of the field contains a hyphen #10385

thelo-gaultier opened this issue Oct 4, 2019 · 5 comments · Fixed by #14075
Labels
bug Addresses a defect in current functionality. service/dynamodb Issues and PRs that pertain to the dynamodb service.
Milestone

Comments

@thelo-gaultier
Copy link

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 "me too" comments, 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

Terraform Version

Terraform v0.11.14

  • provider.aws v2.31.0

Affected Resource(s)

  • aws_dynamodb_table_item

Terraform Configuration Files

resource "aws_dynamodb_table" "dynamodb_table" {
  name            = "test-table"
  hash_key        = "name"

  billing_mode    = "PAY_PER_REQUEST"

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

resource "aws_dynamodb_table_item" "item" {
  table_name = "${aws_dynamodb_table.dynamodb_table.name}"
  hash_key   = "${aws_dynamodb_table.dynamodb_table.hash_key}"

  item = <<ITEM
{
  "name":     {"S": "main"},
  "label":    {"S": "Main"}
}
ITEM
}

resource "aws_dynamodb_table_item" "item_2" {
  table_name = "${aws_dynamodb_table.dynamodb_table.name}"
  hash_key   = "${aws_dynamodb_table.dynamodb_table.hash_key}"

  item = <<ITEM
{
  "label-fail":    {"S": "Main"},
  "name":     {"S": "main2"}
}
ITEM
}

Debug Output

https://gist.github.com/thelo-gaultier/d540ff24beebadca969d9db454ca8f4d

Expected Behavior

the item_2should be created successfully

Actual Behavior

Terraform throw this exception

Error: Error applying plan:

1 error occurred:
	* aws_dynamodb_table_item.item_2: 1 error occurred:
	* aws_dynamodb_table_item.item_2: Error retrieving DynamoDB table item: ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#a_label-fail"
	status code: 400, request id: R9OU92P3E8G8G0GRT7954PSSGJVV4KQNSO5AEMVJF66Q9ASUAAJG

Steps to Reproduce

  1. terraform apply

References

Dynamo offers expression projection to solve this problem, however this does not seem to be available in the current terraform provider documentation

@ghost ghost added the service/dynamodb Issues and PRs that pertain to the dynamodb service. label Oct 4, 2019
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 4, 2019
@edwardofclt
Copy link
Contributor

Similar situation when the key contains a /

Error: Error retrieving DynamoDB table item: ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#a_#/test"
        status code: 400, request id: 6HARTQCVK3K2FB15D15LL9GG6VVV4KQNSO5AEMVJF66Q9ASUAAJG

@opub
Copy link

opub commented Jan 26, 2021

FYI this bug happens when evaluating the state of aws_dynamodb_table_item. So once you have a aws_dynamodb_table_item resource in your state with one of the bad cases above it can't be fixed without manually clearing that out. I just spent hours recreating my table, renaming attributes, changing attribute values, completely removing any references to aws_dynamodb_table_item, etc. all of which had no impact since the bad values were cached in my S3 state file.

@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 21, 2021
@yermulnik
Copy link

Same here 😢

│ Error: Error retrieving DynamoDB table item: ValidationException: ExpressionAttributeNames contains invalid key: Syntax error; key: "#a_s3.storage"
│       status code: 400, request id: 5H680R0K4RDMKE95D6FJN7C90BVV4KQNSO5AEMVJF66Q9ASUAAJG

Added +1 to #14075

@github-actions github-actions bot added this to the v4.8.0 milestone Mar 25, 2022
@ewbankkit ewbankkit modified the milestones: v4.8.0, v4.9.0 Mar 27, 2022
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

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

github-actions bot commented May 8, 2022

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 May 8, 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.

6 participants