Lambda function scheduled to perform backups of another server on s3

Lambda function scheduled to perform backups of another server on s3

36 minutes

We will use the AWS CDK in Typescript to create a Lambda function and its resources, and schedule it at specific intervals. We will use this lambda to perform regular database backups of a server outside of AWS.

Clone the repository

git clone


Ep.1 - Introduction: Lambda cron backup to s3 (4 minutes)

We explain how the project will be structured and what we are trying to accomplish: a cron process running on AWS Lambda to backup an external server.

• AWS Lambda
• AWS Cloudformation
• AWS S3

Ep.2 - Installing dependencies (6 minutes)

We start installing the dependencies for the project.

• curl
• Nodejs and npm
We will start organizing the commands used to install dependencies on a Makefile

Ep.3 - CDK first steps (15 minutes)

We will run cdk init to start a Typescript project.

• Updating our Makefile to document the setup commands
• Creating a folder with the stack, service, and dependencies
• Install missing aws and system dependencies as we need them
We start by defining a new s3 bucket we want to create.

Ep.4 - CDK deploy and destroy (26 minutes)

We will deploy our resources with cdk deploy. Once we are done we will use cdk destroy to remove the resources.

• Updating our Makefile to document the changes.
• Confirm the s3 bucket is created.
• Deal with common pitfalls when running cdk destroy — like s3 resoruces not being removed.
• Install autodelete bucket and missing aws dependencies.
• Makefile .PHONY targets.
• Permissions.

We will allocate and deallocate aws resources using cdk deploy and cdk destroy, and deal with some common problems we can run into.