https://github.com/signiant/dynamodb-add-ttl-lambda
Lambda function to add a ttl attribute to an existing table based on an existing attribute
https://github.com/signiant/dynamodb-add-ttl-lambda
aws dynamodb ttl
Last synced: 7 months ago
JSON representation
Lambda function to add a ttl attribute to an existing table based on an existing attribute
- Host: GitHub
- URL: https://github.com/signiant/dynamodb-add-ttl-lambda
- Owner: Signiant
- License: mit
- Created: 2017-11-03T11:28:59.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2025-07-25T20:06:10.000Z (9 months ago)
- Last Synced: 2025-10-13T16:09:04.510Z (7 months ago)
- Topics: aws, dynamodb, ttl
- Language: Python
- Size: 13.7 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dynamodb-add-ttl-lambda
Lambda function to add a ttl attribute to an existing table based on an existing attribute
[](https://travis-ci.org/Signiant/dynamodb-add-ttl-lambda)
# Purpose
This lambda function is designed to be used as a DynamoDB trigger in order to add a ttl attribute to an existing table for new rows. It will base the new ttl attribute on an existing timestamp attibute by reading the existing attribute and adding a number of days to it. The existing attribute, number of days and new ttl attribute name are all configurable
# Installing
The easiest deployment of this solution is using AWS SAM
* export your AWS credentials (or use --profile option with sam commands)
* update the samconfig.toml file
* stack_name - name for the CFN stack
* region - if other than us-east-1
* parameter overrides
* ttlReferenceAttribute - existing attribute used to calculate TTL
* timeToLive - duration of TTL (in days)
* ttlAttributeName - what to name the TTL (e.g. ttl)
* tableName - the DynamoDB table to watch
* streamARN - the ARN of the DynamoDB stream for the table above
* deploy the lambda using SAM: `./utils/deploy.sh default`
This should deploy the lambda and set up the associated dynamodb trigger for the appropriate table.
NOTE: As per the StartingPosition property on the DynamoDB event trigger - this lambda will only process NEW records.
You may need a separate process to backfill existing records.
You can then monitor the stats for the function and the cloudwatch log to ensure TTLs are being added correctly for new rows.