Lambda function scheduled to perform backups of another server on s3
Lambda function scheduled to perform backups of another server on s336 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 https://github.com/fromzerotofullstack/lambda-cron-backup-s3
Ep.1 - Introduction: Lambda cron backup to s3
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
We start installing the dependencies for the project.
• Nodejs and npm
• AWS CDK
We will start organizing the commands used to install dependencies on a Makefile
Ep.3 - CDK first steps
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
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.
We will allocate and deallocate aws resources using cdk deploy and cdk destroy, and deal with some common problems we can run into.