CloudFormation for serverless services
In this section, we will learn how CloudFormation can be used to build and deploy Lambda functions. We will do the following:
- We will write a
CloudFormationtemplate for a Lambda function that periodically pings a website and gives an error if there is any failure in the process. TheCloudFormationtemplate for this is as follows:
AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: 'Performs a periodic check of the given site, erroring out on test failure.'
Resources:
lambdacanary:
Type: 'AWS::Serverless::Function'
Properties:
Handler: lambda_function.lambda_handler
Runtime: python2.7
CodeUri: .
Description: >-
Performs a periodic check of the given site,
erroring out on test failure.
MemorySize: 128
Timeout: 10
Events:
Schedule1:
Type: Schedule
Properties:
Schedule: rate(1 minute)
Environment:
Variables...