This AWS Lambda function will attach to the DynamoDB Stream of the
logfile table to replicate item puts and deletes to the
logfile_replica table. The Lambda function code has been provided for you in the file
ddbreplica_lambda.py. You may review the contents of the script if you would like with
Zip the contents of the script. We will upload this to AWS Lambda when we create the function.
zip ddbreplica_lambda.zip ddbreplica_lambda.py lab_config.py
Get the Amazon Resource Name (ARN) of the precreated IAM role so that you can associate it with the Lambda function. Run the following command to retrieve the ARN of the role that was created during the lab creation.
The output looks like the following.
Now, run the following command to create the Lambda function.
aws lambda create-function \ --function-name ddbreplica_lambda --zip-file fileb://ddbreplica_lambda.zip \ --handler ddbreplica_lambda.lambda_handler --timeout 60 --runtime python3.7 \ --description "Sample lambda function for dynamodb streams" \ --role $(cat ~/workshop/ddb-replication-role-arn.txt)