-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
115 lines (106 loc) · 2.71 KB
/
Copy pathtemplate.yaml
File metadata and controls
115 lines (106 loc) · 2.71 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Resources:
Function:
Type: AWS::Lambda::Function
Properties:
Code: target/lambda/release/bootstrap.zip
Handler: main.main
Runtime: provided
MemorySize: 128
Timeout: 5
Role: !GetAtt ExecutionRole.Arn
Environment:
Variables:
RUST_BACKTRACE: 1
TOPIC_ARN: !Ref Topic
TABLE_NAME: !Ref Table
LogGroup:
Type: AWS::Logs::LogGroup
DependsOn: Function
Properties:
RetentionInDays: 14
LogGroupName: !Join ["", ["/aws/lambda/", !Ref Function]]
ExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: "sts:AssumeRole"
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Table:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: flavor
AttributeType: S
KeySchema:
- AttributeName: flavor
KeyType: HASH
TableName: !Ref TableName
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 5
TablePolicy:
Type: AWS::IAM::Policy
Properties:
Roles:
- !Ref ExecutionRole
PolicyName: table-policy
PolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Action:
- dynamodb:PutItem
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:DeleteItem
Resource: !GetAtt Table.Arn
Topic:
Type: AWS::SNS::Topic
Properties:
Subscription:
- Protocol: sms
Endpoint: !Ref PhoneNumber
TopicPolicy:
Type: AWS::IAM::Policy
Properties:
Roles:
- !Ref ExecutionRole
PolicyName: topic-policy
PolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Action:
- sns:Publish
Resource: !Ref Topic
EventRule:
Type: AWS::Events::Rule
Properties:
ScheduleExpression: rate(1 day)
Targets:
- Id: Scheduler
Arn: !GetAtt Function.Arn
EventsPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !GetAtt Function.Arn
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn: !GetAtt EventRule.Arn
Parameters:
TableName:
Type: String
Description: "DynamoDB table name in which the function will store the menu"
MinLength: 1
MaxLength: 255
PhoneNumber:
Type: String
Description: "SMS number with country code to subscribe"
MinLength: 1
MaxLength: 15