-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserverless.yml
122 lines (117 loc) · 3.5 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
service: spacebot
custom:
favoritesTableName: 'spacebot-${self:provider.stage}-favorites'
tokensTableName: 'spacebot-${self:provider.stage}-oauthtokens'
config: ${file(config/config.${self:provider.stage}.yml)}
provider:
name: aws
profile: spacebot
runtime: nodejs16.x
region: us-east-1
stage: ${opt:stage, 'dev'}
memorySize: 128
timeout: 6
iam:
role:
name: spacebot
statements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource:
- !GetAtt FavoritesDynamoDBTable.Arn
- !GetAtt TokensDynamoDBTable.Arn
functions:
messages:
handler: functions/messages/handler.handler
description: Slack Interactive Messages Handler
events:
- http:
path: slack/messages
method: post
environment:
SLACK_TOKEN: ${self:custom.config.SLACK_TOKEN}
FAVORITES_TABLE_NAME: ${self:custom.favoritesTableName}
oauth:
handler: functions/oauth/handler.oauth
description: Slack OAuth function
memorySize: 256
timeout: 15
events:
- http:
path: slack/oauth
method: get
environment:
OAUTH_SUCCESS_URL: ${self:custom.config.OAUTH_SUCCESS_URL}
OAUTH_ERROR_URL: ${self:custom.config.OAUTH_ERROR_URL}
SLACK_CLIENT_ID: ${self:custom.config.SLACK_CLIENT_ID}
SLACK_CLIENT_SECRET: ${self:custom.config.SLACK_CLIENT_SECRET}
SLACK_API_URL: ${self:custom.config.SLACK_API_URL}
TOKENS_TABLE_NAME: ${self:custom.tokensTableName}
slack:
handler: functions/slack/handler.slash
description: Slack /spacebot slash command function
events:
- http:
path: slack/slash
method: post
- schedule:
rate: rate(5 minutes)
enabled: true
environment:
SLACK_TOKEN: ${self:custom.config.SLACK_TOKEN}
NASA_API_KEY: ${self:custom.config.NASA_API_KEY}
resources:
Resources:
FavoritesDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: slackUserId
AttributeType: S
- AttributeName: mediaId
AttributeType: N
- AttributeName: service
AttributeType: S
KeySchema:
- AttributeName: slackUserId
KeyType: HASH
- AttributeName: mediaId
KeyType: RANGE
LocalSecondaryIndexes:
- IndexName: userFavoritesByType
KeySchema:
- AttributeName: slackUserId
KeyType: HASH
- AttributeName: service
KeyType: RANGE
Projection:
NonKeyAttributes:
- mediaId
ProjectionType: INCLUDE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.favoritesTableName}
TokensDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: slackUserId
AttributeType: S
- AttributeName: teamId
AttributeType: S
KeySchema:
- AttributeName: slackUserId
KeyType: HASH
- AttributeName: teamId
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:custom.tokensTableName}