Skip to content

Instantly share code, notes, and snippets.

@klausbadelt
Last active October 8, 2018 06:27
Show Gist options
  • Save klausbadelt/75e2178407dca1483bc9a917b1ba98fd to your computer and use it in GitHub Desktop.
Save klausbadelt/75e2178407dca1483bc9a917b1ba98fd to your computer and use it in GitHub Desktop.
CloudFormation template excerpt - lambda function
WebPipelineNotifyFunction:
Type: AWS::Lambda::Function
Properties:
Code:
ZipFile: |
var SNS = require('aws-sdk/clients/sns')
var sns = new SNS()
exports.handler = async (event) => {
console.log(JSON.stringify(event))
const params = {
Message: `Deploy of ${process.env.BRANCH} ${event.detail.state}`,
TopicArn: process.env.TOPIC_ARN,
Subject: `Deploy ${event.detail.state}`
}
console.log(JSON.stringify(params))
return await sns.publish(params).promise()
}
Description: Notifies of deploys with SMS and email
Environment:
Variables:
TOPIC_ARN: !Ref DevNotifyTopic
BRANCH: !Ref DeployBranch
Handler: index.handler
Role: !GetAtt LambdaServiceRole.Arn
Runtime: nodejs8.10
Timeout: 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment