Lambda function scheduled to perform backups of another server on s3

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 CDK
• AWS S3

Notes

• Source code in Github
https://github.com/fromzerotofullstack/lambda-cron-backup-s3/tree/

• Cron
https://en.wikipedia.org/wiki/Cron

• AWS Lambda documentation
https://aws.amazon.com/lambda/

• AWS Cloudformation
https://aws.amazon.com/cloudformation/

• AWS Cloud Development Kit (CDK) documentation
https://aws.amazon.com/cdk/

• AWS S3 documentation
https://aws.amazon.com/s3/

Clone the repository

git clone https://github.com/fromzerotofullstack/lambda-cron-backup-s3

Episodes

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 CDK
• AWS S3


Ep.2 - Installing dependencies (6 minutes)

We start installing the dependencies for the project.

• curl
• Nodejs and npm
• AWS CDK
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.