This repository contains Cloudformation templates for a Public-Private VPC and Elastic Filesystem for use with AWS Lambda. Follow the steps below to implement. They must but done in the order indicated since the file system is dependent on the VPC.
- Using Cloudformation Console, create a new stack and upload the VCP template (cloudformation/vpc.yml)
- Using Cloudformation Console, create a new stack and upload the EFS template (cloudformation/efs.yml)
- Create a new lamba via the Lamdba Console, and copy/paste the code from ./lambda.js in the code tab.
- From the Lambda's configuration tab, attach the newly created VPC, using the private subnet and default security group.
- From the Lambda's configuration tab, attach the newly created file system and make note of the mount path you use.
- Once you create the lambda, add a new test from the Test tab and add the following test data:
{"mountPath" : "your mount path" } // Enter the mount path you specified for the file system - Click "Test"
You should see a message indicating that you have Internet access and a console message indicating the test was able to successfully write to and read from your file system.
The VPC only adds two private and two public subnets in two availability zones. You can add more subnets by following the basic outline of the YAML for each subnet.