This project sets up an AWS infrastructure using Terraform to create a DynamoDB table which moves the deleted items due to TTL to DynamoDB stream as and REMOVE event. This events are processed by Lambda functions.
main.tf: Contains the main configuration for the Terraform infrastructure, defining the AWS EventBridge rule and the Lambda function.variables.tf: Defines input variables for the Terraform configuration, specifying types and default values.outputs.tf: Specifies output values that Terraform will display after applying the configuration, including resource ARNs.provider.tf: Configures the Terraform provider, typically the AWS provider with necessary authentication details.
- Terraform installed on your machine.
- AWS account with appropriate permissions to create resources.
- AWS CLI configured with your credentials.
- Clone the repository:
git clone <repository-url> cd dynamodb_streams_ttl
1.1 Prepare lambda package:
cd lambda_package
zip -r ../lambda.zip .
cd ..
-
Initialize Terraform:
terraform init -
Review and modify the
variables.tffile as needed to set your desired configurations. -
Plan the deployment:
terraform plan -
Apply the configuration:
terraform apply -
Add a item in DB table:
aws dynamodb put-item \ --table-name scheduled_tasks \ --item '{ "task_id": {"S": "task_christmas2024"}, "scheduled_time": {"N": "1735084800"} }' \ --region us-east-1
After applying the configuration, Terraform will display the output values defined in outputs.tf, including the ARN of the created resources.
To remove the resources created by this project, run:
terraform destroy
This project is licensed under the MIT License.
