Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
38 lines (36 sloc)
1.53 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: 'AWS::Serverless-2016-10-31' | |
Description: An example app with a Lambda function that sends texts via SNS. | |
Parameters: | |
# Pass secrets that you don't want stored in your code repository as parameters | |
MyPhoneNumber: | |
Type: String | |
Resources: | |
CICDSendTextFunction: | |
# A Lambda function that sends messages to an SNS topic | |
Type: 'AWS::Serverless::Function' | |
Properties: | |
FunctionName: CICDSendTextFunction | |
Handler: send_text_function.lambda_handler | |
Runtime: python3.7 | |
Description: A Lambda function that sends text messages | |
Timeout: 120 | |
Policies: | |
# Find more SAM IAM policy templates here: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-policy-templates.html | |
- SNSPublishMessagePolicy: | |
# Our function only has permissions to send to the SNS topic we created | |
TopicName: !GetAtt CICDSendTextSNSTopic.TopicName | |
Environment: | |
Variables: | |
# If your functions need to use variables passed as parameters, reference them as environment variables | |
MY_PHONE_NUMBER: !Ref MyPhoneNumber | |
# You can also reference other resources created in this template as environment variables | |
SNS_TOPIC_ARN: !Ref CICDSendTextSNSTopic | |
CICDSendTextSNSTopic: | |
# An SNS topic | |
Type: AWS::SNS::Topic | |
Properties: | |
# Subscribing yourself to receive messages from this topic | |
Subscription: | |
- Protocol: sms | |
Endpoint: !Ref MyPhoneNumber |