No description
modules | ||
.gitignore | ||
locals.tf | ||
main.tf | ||
README.md | ||
variables.tf |
S3 bucket with a Lambda function as a listener and append to a DynamoDB table With Terraform
This is a simple example of how to use a Lambda function as a listener for an S3 bucket and append the data to a DynamoDB table.
Prerequisites
- Terraform 1.4.x
- AWS CLI
- AWS account with permissions to create the resources
- AWS credentials configured
Usage
- Clone this repository
- go to
locals.tf
in the root directory and change the account_id to your own account id - need to make sure the javascript file inside
module/lambda/files/lambda_function.zip
is wil the right region and table name - Run
terraform init
- Run
terraform apply
Example playlod file *.json
{
"id": "00a6fa25-df29-4701-9077-557932591766",
"timestamp": 23764783264,
"data": "CONTENT OF THE FILE"
}
Test
- Upload a file to the S3 bucket
- Check the DynamoDB table for the new item
- check the CloudWatch logs for the Lambda function