-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplate.yaml
78 lines (73 loc) · 2.67 KB
/
template.yaml
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Pinpoint Weather Bot - responds to a text message from a user with current weather conditions.
Incoming text message must conform to the format "weather <<zipcode>>", else it will be ignored.
Metadata:
AWS::ServerlessRepo::Application:
Name: 'Pinpoint-Weather-Bot'
Description: This application responds to an incoming SMS (with format 'weather <<zipcode>>') with current weather conditions.
Author: James Beswick
SpdxLicenseId: mit-0
LicenseUrl: LICENSE.txt
ReadmeUrl: README.md
Labels: ['SMS', 'weather', 'pinpoint', 'lambda', 'nodejs']
HomePageUrl: https://github.com/jbesw/aws-serverless-sar-pinpoint-weather-bot.git
SemanticVersion: 1.0.0
SourceCodeUrl: https://github.com/jbesw/aws-serverless-sar-pinpoint-weather-bot.git
Parameters:
APIkey:
Type: String
Default: 'APIkey'
Description: (Required) OpenWeatherMap API key
AllowedPattern: ^[A-Za-z0-9-]+$
ConstraintDescription: 'Required parameter.'
ApplicationId:
Type: String
Default: 'PinpointApplicationId'
Description: (Required) Pinpoint application ID (project ID)
AllowedPattern: ^[A-Za-z0-9-]+$
ConstraintDescription: 'Required parameter.'
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Resources:
smsResponderFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: smsResponderFunction/
Handler: app.lambdaHandler
Runtime: nodejs8.10
Environment:
Variables:
ApplicationId: !Ref ApplicationId
APIkey: !Ref APIkey
Policies:
- Statement:
- Sid: PinpointAccess
Effect: Allow
Action:
- mobiletargeting:*
Resource: '*'
- Sid: PinpointSNStopic
Effect: Allow
Action:
- sns:*
Resource: !Ref smsResponderIncomingSNSTopic
Events:
incomingSNS:
#SNS queue where Pinpoint sends incoming text messages
Type: SNS
Properties:
Topic:
Ref: smsResponderIncomingSNSTopic
smsResponderIncomingSNSTopic:
Type: 'AWS::SNS::Topic'
Outputs:
smsResponderFunction:
Description: "Hello World Lambda Function ARN"
Value: !GetAtt smsResponderFunction.Arn
smsResponderFunctionIamRole:
Description: "Implicit IAM Role created for function"
Value: !GetAtt smsResponderFunctionRole.Arn