How to unset (clear) a TTL value

76 views Asked by At

I have an item in DynamoDB table which has a TTL set to next month.

I want to unset (or clear) the TTL value (so that the item will no longer be scheduled for removal), how do I to it?


Here is what I have tried so far, but they both error in my java code:

  • I tried setting it to NULL.

  • I then tried setting it to a dummy string like "NO VALUE".


What is the correct way to unset (clear) a TTL value from an item after the TTL value was previously set.

1

There are 1 answers

3
Leeroy Hannigan On BEST ANSWER

The correct way to do it is to REMOVE the attribute, as DynamoDB uses a schemaless model, there is no need to set it to "Some empty value" and Number types cannot be Null.

aws dynamodb update-item \
    --table-name ProductCatalog \
    --key '{"Id":{"N":"789"}}' \
    --update-expression "REMOVE ttl_attr_name" \
    --return-values ALL_NEW