Louis Q

At Accru we strive to document everything using Infrastructure as Code and to be as event driven as possible rather than operating in batch which doesn’t scale so well.

I do love a bit of DynamoDB and one of my favourite features is it’s ability to act as a scheduler. How so?

Simply create a table (using the AWS CDK) with a time to live attribute and setup streams like so:

Any write to this table will trigger a lambda to execute round about the time you set the ttl to be.

This is how you setup the lambda:

and this is an example of how you can write to dynamo:

You can then write the simple lambda function to do with the event what you wish:

Enjoy

--

--

The AWS CDK is an awesome tool for describing your infrastructure.

In a language of your choice, TypeScript is my own, you can define and deploy your stack. For example:

and then simply run:

cdk deploy

to send it out the door.

Recentlyish’ AWS added provisioned concurrency where you can ensure a certain number of instances of your functions are available between certain times. This great and can be done like so:

Another approach is polling the lambda. In days gone by I’ve used the Serverless framework which has a warmup plugin you can use. I wondered how I could do this with the CDK. Well here’s how:

This will ensure you don’t invoke your business logic but keep costs low and keep everything nice and toasty.

--

--