javaamazon-web-servicesamazon-dynamodbttl

How to unset (clear) a TTL value


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:


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


Solution

  • 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