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:
- Deletion will be guaranteed, but you have to wait for 24 to 48 hours (nothing happeened)
- Expired items should be removed from Scans and Queries (ok)
- RCU and WCU should be different, so I put RCU > WCU, but nothing happens, and that's not required
- My items are in the table for almost one week, why?
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
- Changed the RCU and WCU
- Waited for the deletion of the items
- Waited for the deletion of the items
- Waited for the deletion of the items
- Waited for the deletion of the items
- Waited for the deletion of the items
- Waited for the deletion of the items
- Waited for the deletion of the items
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
ExpiresAtbut your item holds a value forExpiredAt, those are two completely separate attribute as far as DynamoDB is concerned.