-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverless.yml
140 lines (127 loc) · 3.8 KB
/
serverless.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
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
service:
name: since
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
- serverless-domain-manager
custom:
# Log all events to CloudWatch
slack_enable_logging: true
# The dynamodb table to store OAuth access data
team_table_name: Since-Teams-${opt:stage}
item_table_name: Since-Items-${opt:stage}
# The path used to post Slack events to
slack_event_path: slack
# The path used to install the Slack App
slack_install_path: slack
# The path to redirect to after an install
slack_install_redirect: https://theaway.team/since?installed=complete
# Space delimited scopes
slack_client_scopes: "chat:write,commands"
# URL mappings
domains:
dev: dev.since.theaway.team
prod: since.theaway.team
customDomain:
domainName: ${self:custom.domains.${opt:stage}}
basePath: api
stage: ${opt:stage}
createRoute53Record: true
provider:
name: aws
runtime: nodejs14.x
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DescribeTable
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:us-east-1:*:*"
environment:
STAGE: ${opt:stage}
TABLE_NAME: ${self:custom.team_table_name}
ITEM_TABLE_NAME: ${self:custom.item_table_name}
API_APP_ID: ${ssm:since.${opt:stage}.SLACK_APP_API_ID}
CLIENT_ID: ${ssm:since.${opt:stage}.SLACK_CLIENT_ID}
CLIENT_SECRET: ${ssm:since.${opt:stage}.SLACK_CLIENT_SECRET}
CLIENT_SCOPES: ${self:custom.slack_client_scopes}
INSTALL_REDIRECT: ${self:custom.slack_install_redirect}
PAYMENT_DOMAIN: ${ssm:since.${opt:stage}.PAYMENT_DOMAIN}
FREE_TIER_MAXIMUM: ${ssm:since.${opt:stage}.FREE_TIER_MAXIMUM}
VERIFICATION_TOKEN: ${ssm:since.${opt:stage}.VERIFICATION_TOKEN}
ENABLE_LOGGING: ${self:custom.slack_enable_logging}
WEBHOOK: ${ssm:since.${opt:stage}.WEBHOOK}
functions:
slack:
handler: index.handler
events:
## Slash Commands, Events, and Interactive Messages
- http:
path: ${self:custom.slack_event_path}
method: post
integration: lambda
response:
template: $input.path('$')
## OAuth Routes
- http:
path: ${self:custom.slack_install_path}
method: get
integration: lambda
request:
parameters:
querystrings:
code: true
state: false
response:
statusCodes:
201:
pattern: ''
301:
pattern: http.*
headers:
Location: integration.response.body.errorMessage
Cache-Control: "'no-cache, no-store, must-revalidate'"
resources:
Resources:
TeamsDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
KeySchema:
-
AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.team_table_name}
ItemDynamoDbTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
-
AttributeName: id
AttributeType: S
-
AttributeName: teamId
AttributeType: S
KeySchema:
-
AttributeName: teamId
KeyType: HASH
-
AttributeName: id
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.item_table_name}