-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserverless.yml
More file actions
executable file
·200 lines (186 loc) · 5.32 KB
/
serverless.yml
File metadata and controls
executable file
·200 lines (186 loc) · 5.32 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# NOTE: Service name must match the repository name, but replace all '.' with '-' (this is a restriction of Cloudformation naming conventions)
service: aws-certbot
custom:
stage: ${opt:stage}
region: ${opt:region}
table: ${self:service}.${self:custom.stage}
emailMappingTable: ${self:service}.nameEmailMapping
officeSlackCustomFieldId:
dev: Xf1LTXNG6P
master: Xf1LTXNG6P
cohortSlackCustomFieldId:
dev: Xf1M339XQX
master: Xf1M339XQX
clientSecret: xoxb-149685676326-618359348662-E5cgXkkRClUUR7Lf5HbtXXRr
clientSecret_user: xoxp-149685676326-604707647410-609851737281-df95205a2da44f63d5492c4c9e3548e5
slackToken: PwS7X21qRovjuYJcwXuFEV2V
provider:
name: aws
runtime: nodejs12.x
stage: ${self:custom.stage}
environment:
TABLE: ${self:custom.table}
MAPPING_TABLE: ${self:custom.emailMappingTable}
SERVICE_AND_STAGE: ${self:service}
GET_SLACK_PROFILE_SERVICE_URL:
Fn::Join:
- ""
- - "https://"
- Ref: "ApiGatewayRestApi"
- ".execute-api.${self:provider.region}.amazonaws.com/${self:provider.stage}/slack/profile"
OFFICE_SLACK_CUSTOM_FIELD_ID: ${self:custom.officeSlackCustomFieldId.${self:provider.stage}}
COHORT_SLACK_CUSTOM_FIELD_ID: ${self:custom.cohortSlackCustomFieldId.${self:provider.stage}}
# NOTE: Codebuild passes the lambda role from the security stack to the serverless deploy command in the live CI/CD pipeline
region: ${self:custom.region}
stackTags:
Type: service
iamRoleStatements: # permissions for all of functions
- Effect: Allow
Action:
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
- dynamodb:Scan
Resource:
- Fn::GetAtt:
- DynamoTable
- Arn
- Fn::GetAtt:
- EmailMappingDynamoTable
- Arn
- Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- logs:DescribeLogStreams
Resource:
Fn::Join:
- ''
- - 'arn:aws:logs:'
- Ref: AWS::Region
- ':*:*'
- Effect: Allow
Action:
- lambda:InvokeAsync
- lambda:InvokeFunction
Resource:
Fn::Join:
- ''
- - 'arn:aws:lambda:'
- Ref: AWS::Region
- ':'
- Ref: AWS::AccountId
- ':function:'
- ${self:service}
- '-'
- ${self:provider.stage}
- '-*'
functions:
hello:
environment:
SLACK_APP_AUTH_TOKEN: ${self:custom.clientSecret}
VERIFICATION_TOKEN: ${self:custom.slackToken}
handler: functions/index.hello
events:
- http:
path: hello/world
method: post
cors: true
postCert:
environment:
VERIFICATION_TOKEN: ${self:custom.slackToken}
handler: functions/postCert.handler
timeout: 30
events:
- http:
path: cert
method: post
cors: true
getData:
environment:
SLACK_APP_AUTH_TOKEN: ${self:custom.clientSecret}
VERIFICATION_TOKEN: ${self:custom.slackToken}
handler: functions/getData.handler
timeout: 30
events:
- http:
path: awsCertData
method: post
cors: true
postMapping:
environment:
VERIFICATION_TOKEN: ${self:custom.slackToken}
handler: functions/postMapping.handler
timeout: 30
events:
- http:
path: mapping
method: post
cors: true
sendReminders:
environment:
SLACK_APP_AUTH_TOKEN: ${self:custom.clientSecret}
REMINDER_DAYS: 90
handler: functions/sendReminders.handler
timeout: 60
events:
- schedule: cron(0 17 * * ? *)
updateFins:
environment:
handler: functions/updateFins.handler
timeout: 60
events:
- schedule: cron(0 5 * * ? *)
getSlackProfileService:
environment:
SLACK_APP_AUTH_TOKEN: ${self:custom.clientSecret}
SLACK_APP_USER_AUTH_TOKEN: ${self:custom.clientSecret_user}
handler: functions/getSlackProfileService.handler
timeout: 30
events:
- http:
path: slack/profile
method: get
cors: true
resources:
Resources:
# TODO: If needed, add CloudFormation resources
# EXAMPLE: S3 Bucket
# NewResource:
# Type: AWS::S3::Bucket
# Properties:
# BucketName: my-new-bucket
DynamoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: '${self:custom.table}'
AttributeDefinitions:
- AttributeName: certKey
AttributeType: S
KeySchema:
- AttributeName: certKey
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
EmailMappingDynamoTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: '${self:custom.emailMappingTable}'
AttributeDefinitions:
- AttributeName: fin
AttributeType: S
KeySchema:
- AttributeName: fin
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
Outputs:
# TODO: If needed, add Cloudformation Outputs
# EXAMPLE: Cloudformation Output
# NewOutput:
# Description: "Description for the output"
# Value: "Some output value"