-
Notifications
You must be signed in to change notification settings - Fork 3
/
serverless.yml
127 lines (119 loc) · 4.01 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
service: WFH-Amida
custom:
env-file: ./serverless.env-dev.yml
dynamodb:
# If you only want to use DynamoDB Local in some stages, declare them here
stages:
- dev
start:
port: 8000
inMemory: true
heapInitial: 200m
heapMax: 1g
migrate: true
seed: true
convertEmptyValues: true
# set to true only if you already have a DynamoDB running locally
noStart: true
plugins:
- serverless-offline
- serverless-pseudo-parameters
- serverless-dynamodb-local
provider:
name: aws
runtime: nodejs10.x
# Uncoment the following two fields only if you want to apply a
# role/profile durind deployment. If you wish to use a profile, you
# will need to add --profile {profile name} to each command.
# profile: cloudformation_role
# role: arn:aws:iam::#{AWS::AccountId}:role/SlackLambdaRole
region: ${file(${self:custom.env-file}):REGION}
stage: ${opt:stage, 'local'}
environment:
REGION: ${self:provider.region}
STAGE: ${self:provider.stage}
LAYER_PATH: ${file(${self:custom.env-file}):LAYER_PATH, '/opt'}
GOOGLE_CLIENT_ID: ${file(${self:custom.env-file}):GOOGLE_CLIENT_ID}
GOOGLE_PROJECT_ID: ${file(${self:custom.env-file}):GOOGLE_PROJECT_ID}
GOOGLE_AUTH_URI: ${file(${self:custom.env-file}):GOOGLE_AUTH_URI}
GOOGLE_TOKEN_URI: ${file(${self:custom.env-file}):GOOGLE_TOKEN_URI}
GOOGLE_AUTH_PROVIDER_X509_CERT_URL: ${file(${self:custom.env-file}):GOOGLE_AUTH_PROVIDER_X509_CERT_URL}
GOOGLE_CLIENT_SECRET: ${file(${self:custom.env-file}):GOOGLE_CLIENT_SECRET}
GOOGLE_REDIRECT_URIS_1: ${file(${self:custom.env-file}):GOOGLE_REDIRECT_URIS_1}
GOOGLE_REDIRECT_URIS_2: ${file(${self:custom.env-file}):GOOGLE_REDIRECT_URIS_2}
WFH_GCAL_ID: ${file(${self:custom.env-file}):WFH_GCAL_ID}
SLACK_WFH_CHANNEL: ${file(${self:custom.env-file}):SLACK_WFH_CHANNEL}
SLACK_BOT_API_TOKEN: ${file(${self:custom.env-file}):SLACK_BOT_API_TOKEN}
WFH_BOT_SLACK_ID: ${file(${self:custom.env-file}):WFH_BOT_SLACK_ID}
MESSAGES_TABLE: ${file(${self:custom.env-file}):MESSAGES_TABLE}
LOCAL_DYNAMODB_ENDPOINT: ${file(${self:custom.env-file}):LOCAL_DYNAMODB_ENDPOINT, ""}
iamRoleStatements:
- Effect: "Allow"
Action:
- "dynamodb:PutItem"
Resource: arn:aws:dynamodb:${file(${self:custom.env-file}):REGION}:#{AWS::AccountId}:table/${file(${self:custom.env-file}):MESSAGES_TABLE}
- Effect: "Allow"
Action:
- "dynamodb:GetItem"
Resource: arn:aws:dynamodb:${file(${self:custom.env-file}):REGION}:#{AWS::AccountId}:table/${file(${self:custom.env-file}):MESSAGES_TABLE}
package:
individually: true
functions:
wfhListener:
handler: handlers/wfhListener/index.handler
events:
- http:
path: /wfh-listener
method: post
package:
individually: true
exclude:
- '**'
include:
- handlers/wfhListener/**
layers:
- { Ref: UtilLambdaLayer }
postDailyMessage:
handler: handlers/postDailyWFHMessage/index.handler
events:
- http: get /postMessage
- schedule: cron(0 10 ? * MON-FRI *)
package:
individually: true
exclude:
- '**'
include:
- handlers/postDailyWFHMessage/**
environment:
SLACK_BOT_API_TOKEN: ${file(${self:custom.env-file}):SLACK_BOT_API_TOKEN}
layers:
- { Ref: UtilLambdaLayer }
resources:
Resources:
MessagesTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: ${file(${self:custom.env-file}):MESSAGES_TABLE}
AttributeDefinitions:
-
AttributeName: TIMESTAMP
AttributeType: S
-
AttributeName: ITEM_USER
AttributeType: S
KeySchema:
-
AttributeName: ITEM_USER
KeyType: HASH
-
AttributeName: TIMESTAMP
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
layers:
Util:
path: opt
compatibleRuntimes:
- nodejs10.x
allowedAccounts:
- '*' # ALL accounts!
retain: false