-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtemplate.yml
38 lines (36 loc) · 1.53 KB
/
template.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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