Deploy the Message-Function (of level 1) with a Dynamo-DB to persist the messages.
Notes:
- It is possible to keep using the same Image for the function. But you have to provide a environment varibale and a policy, to persist the data.
- Deploy a Dynamo-DB with CDK:
- Create a Partition-Key with the name
id
of typeString
. - Create a Table (with your project name as a prefix).
- Set the
removalPolicy
for the table toDESTROY
. This configuration ensures that your Stack is reproducible.
- Create a Partition-Key with the name
- Connect the database to your Message-Function.
- Set the environment variable
DYNAMODB_TABLE_NAME
to<YOUR_TABLE_NAME>
. - Add a new policy to the Lambda-Function. Use the Action
dynamodb:PutItem
with the EffectALLOW
with a reference to your Table-resource.
- Set the environment variable
- Check the AWS UI if the messages are persisted.
Please note: The creation of the Table and Partition-Key needs a few seconds. A great opportunity for some pizza 🍕