This is a modified version of Resizing Images with Amazon CloudFront & Lambda@Edge | AWS CDN Blog for my own use.
- Updated versions of
nvm
andnode
(as of February, 2020). - Uses gzip
- Compile the lamdba functions using docker:
sh docker_build.sh
- Package up the functions into zip files:
sh package_build.sh
- Upload zips to S3, as instructed in the blog post (Step 1, point 7)
NB: For detailed instructions on the tools and setup involved in this section, please refer to the full AWS SAM CLI documentation
In order to test in your development environment on macOS, you will need to do a bit of setting up first. Follow these instructions to install the AWS SAM CLI. In summary, you will require the following:
- An AWS account
- Set up an IAM user with administrator permissions
- Installed Docker
- Installed Homebrew
- Installed the AWS SAM CLI via Homebrew
At this stage you should confirm that you have the AWS SAM CLI installed: sam --version
.
To make full use of the AWS SAM CLI you must also set up your AWS credentials on your development machine.
Once you have completed the setup of the AWS SAM CLI, you can debug Node.js functions locally from within VS Code.
Since the documentation above isn't the clearest, you can also check out the following video about debugging Lambda functions from within VS Code. Whilst the actions that they perform in the video aren't exactly the same, it will give you an idea of the sorts of functionality that the AWS Toolkit VS Code extension provides.