Reputation: 75
I have a DynamoDB table and defined a field to the expired items. In my code I carefully generated the TTL for a random 15 to 120 minutes just to test this feature, but nothing seems to happen. I waited for almost one week and the items still there. Then I saw a lot of articles and sites saying everything (including StackOverflow), but nothing seems to solve the problem. What I gathered since then:
Am I doing something wrong?
Here is the representation as Terraform Code:
resource "aws_dynamodb_table" "books_database" {
name = "${var.workspace}-books-database"
billing_mode = "PROVISIONED"
read_capacity = "20"
write_capacity = "10"
hash_key = "Id"
range_key = "Title"
stream_enabled = false
attribute {
name = "Id"
type = "N"
}
attribute {
name = "Title"
type = "S"
}
global_secondary_index {
hash_key = "Title"
name = "TitleIndex"
projection_type = "ALL"
read_capacity = 20
write_capacity = 10
}
ttl {
attribute_name = "ExpiresAt"
enabled = "true"
}
}
Example:
Id: 47
Title: Ulysses
FirstName: James
LastName: Joyce
ExpiredAt: 1710849676
Upvotes: 0
Views: 103
Reputation: 19793
There is no 24-48 hour guarantee, but it will be deleted if configured correctly.
You must do this with a FilterExpression explicitly.
This is not required
There is no maximum time to remove the item.
One thing you didn't do was share an example item that you expect to have been deleted already. Add that and ping me on a comment to this answer.
You've enabled ttl in ExpiresAt
but your item holds a value for ExpiredAt
, those are two completely separate attribute as far as DynamoDB is concerned.
Upvotes: 2