Examples for AWS CloudFormation templates. Currently focused on templates for AWS Serverless Application Model (SAM).
- All examples contain a
deploy.shfile which contains some steps to package the source code and deploy a CloudFormation stack. Each file expects that you set a
LAMBDA_BUCKETvariable. Just enter a S3 bucket name where you have access to. It will be used to upload the code zips for your Lambdas.
- Finally, just open your command line and execute
$ ./deploy.shin the desired folder. Alternatively, you can use
$ export LAMBDA_BUCKET=<your-bucket-name> && ./deploy.sh.
- Test it!
If you want more templates, make sure to check out my other repository: NodeJS and Java starter projects for AWS Lambda
AWS Lambda: Policies: Creates multiple Lambda functions and gives them the permission to use CloudWatch logs using different approaches.
AWS Lambda: Register to Kinesis Creates a Kinesis stream. Also deploys one Lambda function which is sending data to the stream and two functions which are reading from the stream.
AWS Lambda: Register to S3 updates This example creates an S3 bucket and a Lambda function. The Lambda function is configured to be called when a new file is uploaded to S3.
AWS Lambda: Register to SNS topic Registers a Lambda function to listen to SNS topic updates.
AWS Lambda: Scheduled Functions Creates two Lambda functions which are triggered every day using different syntax.
AWS Lambda: Serverless Apis Declares a simple AWS Lambda function using SAM.
CloudFormation: AWS::Include If a CloudFormation stack grows bigger and bigger, you might face an error like
at 'templateBody' failed to satisfy constraint: Member must have length less than or equal to 51200which simply means: your CloudFormation template is too big and you have to split it. I also wrote a blog post about two options you have in order to reduce your CloudFormation template size. In this example, I've added the code for using AWS::Include command.
CloudFormation: Environments This example shows how to create parameterized stacks, so e.g. you can create different environments of your stack. The same resources are created with different names and belong to a different stack.
Copyright (c) 2017 Sebastian Hesse
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.