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

[Bug]: Unable to disable Dynamodb table TTL #39195

Closed
jayjanssen opened this issue Sep 6, 2024 · 7 comments · Fixed by #40046
Closed

[Bug]: Unable to disable Dynamodb table TTL #39195

jayjanssen opened this issue Sep 6, 2024 · 7 comments · Fixed by #40046
Assignees
Labels
bug Addresses a defect in current functionality. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. service/dynamodb Issues and PRs that pertain to the dynamodb service.
Milestone

Comments

@jayjanssen
Copy link

jayjanssen commented Sep 6, 2024

Terraform Core Version

1.6.5

AWS Provider Version

5.66.0

Affected Resource(s)

aws_dynamodb_table

Expected Behavior

I should be able to disable TTLs on my dynamo table in Terraform:

  ttl {
    enabled = false
    attribute_name = "ttlK"
  }

Actual Behavior

I get a provider validation error that i cannot have a name while ttl.enabled is false. If I try to remove the name, I get an error from the Dynamo API itself.

Relevant Error/Panic Output Snippet

│ Error: updating AWS DynamoDB Table (ttl_test): updating Time To Live: operation error DynamoDB: UpdateTimeToLive, https response error StatusCode: 400, RequestID: 4QV78T54MGHV732LBM9N0SUOIVVV4KQNSO5AEMVJF66Q9ASUAAJG, api error ValidationException: 1 validation error detected: Value '' at 'timeToLiveSpecification.attributeName' failed to satisfy constraint: Member must have length greater than or equal to 1

│   with aws_dynamodb_table.ttl_test,
│   on ttl_test.tf line 1, in resource "aws_dynamodb_table" "ttl_test":
│    1: resource "aws_dynamodb_table" "ttl_test" {

and

Planning failed. Terraform encountered an error while generating this plan.


│ Error: Invalid Attribute Combination

│ Attribute "ttl[0].attribute_name" cannot be specified when "ttl[0].enabled" is "false".
│ ttl[0].attribute_name

│   with aws_dynamodb_table.ttl_test,
│   on ttl_test.tf line 1, in resource "aws_dynamodb_table" "ttl_test":
│    1: resource "aws_dynamodb_table" "ttl_test" {

Terraform Configuration Files

resource "aws_dynamodb_table" "ttl_test" {
  name = "ttl_test"

  billing_mode = "PAY_PER_REQUEST"

  hash_key  = "PK"
  range_key = "SK"

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

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

  ttl {
    enabled = true
    attribute_name = "ttlK"
  }
}

Steps to Reproduce

  1. Create the table described in the TF config files above
  2. Try to set enabled=false on line 20, produces first error listed in "Relevant error" section
  3. Additionally try to comment out attribute name: #attribute_name = "ttlK" to get the second error

Debug Output

No response

Panic Output

No response

Important Factoids

I'm pretty sure this validation check is the issue:
https://github.com/hashicorp/terraform-provider-aws/blame/main/internal/service/dynamodb/table.go#L2471-L2475

With it, there is seemingly no way to disable TTLs via Terraform

References

No response

Would you like to implement a fix?

None

@jayjanssen jayjanssen added the bug Addresses a defect in current functionality. label Sep 6, 2024
Copy link

github-actions bot commented Sep 6, 2024

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added service/dynamodb Issues and PRs that pertain to the dynamodb service. needs-triage Waiting for first response or review from a maintainer. labels Sep 6, 2024
@jayjanssen
Copy link
Author

@gdavison added the offending validation in commit: 9f4eafb

@jakubikan
Copy link

jakubikan commented Sep 16, 2024

I'm having the same issue.
even using a dynamic block like this

  ## if turned on you would need to specially go to the aws console and turn it off
  dynamic "ttl" {
    for_each = var.env != "prod" ? [true] : []
    content {
      attribute_name = "ttl"
      enabled = ttl.value
    }
  }

does not really turn off the changes if they are already active
so you have to specifcly set the value to false

but the you run into the the validation issues that name cannot be set if the enabled = false
but on the other hand the attribute_name can also not be empty or null

@justinretzolk justinretzolk added regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 4, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 4, 2024
@YakDriver YakDriver self-assigned this Nov 6, 2024
@YakDriver
Copy link
Member

YakDriver commented Nov 7, 2024

I was able to reproduce this problem immediately and I'm working on a fix. The time-consuming part is waiting for testing: I've added a test for the bug, but since AWS only allows disabling TTL after it's been enabled for an hour, the test takes an hour to run. 🕥

Copy link

github-actions bot commented Nov 8, 2024

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

@github-actions github-actions bot added this to the v5.76.0 milestone Nov 8, 2024
@github-actions github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Nov 11, 2024
Copy link

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

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 Dec 16, 2024
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. regression Pertains to a degraded workflow resulting from an upstream patch or internal enhancement. 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