This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverless.yml
213 lines (205 loc) · 6.44 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
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# Welcome to Serverless!
#
# Happy Coding!
service: lag-awh
provider:
name: aws
runtime: nodejs6.10
region: ${opt:region}
stage: ${opt:stage}
iamRoleStatements:
- Effect: Allow
Action:
- sns:Publish
Resource:
- ${self:custom.topicArns.loanCreated}
- ${self:custom.topicArns.loanDueDate}
- ${self:custom.topicArns.loanRenewed}
- ${self:custom.topicArns.loanReturned}
- ${self:custom.topicArns.requestCreated}
- ${self:custom.topicArns.requestClosed}
- ${self:custom.topicArns.requestCanceled}
- ${self:custom.topicArns.requestPlacedOnShelf}
- Effect: Allow
Action:
- ssm:GetParameter
- ssm:GetParameters
- ssm:GetParametersByPath
Resource:
- arn:aws:ssm:#{AWS::Region}:#{AWS::AccountId}:parameter${env:ALMA_SHARED_SECRET_NAME}
functions:
challenge:
handler: src/challenge-handler/handler.handleChallengeEvent
events:
- http:
path: ''
method: get
tags:
serverless: true
environment: ${self:custom.environmentNames.${opt:stage}}
service: library-api-gateway
sub-service: webhook-handler
webhook:
handler: src/webhook-handler/handler.handleWebhookEvent
events:
- http:
path: ''
method: post
environment:
ALMA_SECRET_KEY_NAME: ${env:ALMA_SHARED_SECRET_NAME}
LoanCreatedTopicArn: ${self:custom.topicArns.loanCreated}
LoanDueDateTopicArn: ${self:custom.topicArns.loanDueDate}
LoanRenewedTopicArn: ${self:custom.topicArns.loanRenewed}
LoanReturnedTopicArn: ${self:custom.topicArns.loanReturned}
RequestCreatedTopicArn: ${self:custom.topicArns.requestCreated}
RequestClosedTopicArn: ${self:custom.topicArns.requestClosed}
RequestCanceledTopicArn: ${self:custom.topicArns.requestCanceled}
RequestPlacedOnShelfTopicArn: ${self:custom.topicArns.requestPlacedOnShelf}
tags:
serverless: true
environment: ${self:custom.environmentNames.${opt:stage}}
service: library-api-gateway
sub-service: webhook-handler
resources:
Resources:
loanCreatedTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaLoanCreated
loanDueDateTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaLoanDueDate
loanRenewedTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaLoanRenewed
loanReturnedTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaLoanReturned
requestCreatedTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaRequestCreated
requestClosedTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaRequestClosed
requestCanceledTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaRequestCanceled
requestPlacedOnShelfTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: AlmaRequestPlacedOnShelf
Outputs:
LoanCreatedTopicArn:
Description: Arn for Loan Created Topic
Value: ${self:custom.topicArns.loanCreated}
Export:
Name: ${self:service}:${opt:stage}:LoanCreatedTopicArn
LoanDueDateTopicArn:
Description: Arn for Loan Due Date Topic
Value: ${self:custom.topicArns.loanDueDate}
Export:
Name: ${self:service}:${opt:stage}:LoanDueDateTopicArn
LoanRenewedTopicArn:
Description: Arn for Loan Renewed Topic
Value: ${self:custom.topicArns.loanRenewed}
Export:
Name: ${self:service}:${opt:stage}:LoanRenewedTopicArn
LoanReturnedTopicArn:
Description: Arn for Loan Returned Topic
Value: ${self:custom.topicArns.loanReturned}
Export:
Name: ${self:service}:${opt:stage}:LoanReturnedTopicArn
RequestCreatedTopicArn:
Description: Arn for Request Created Topic
Value: ${self:custom.topicArns.requestCreated}
Export:
Name: ${self:service}:${opt:stage}:RequestCreatedTopicArn
RequestClosedTopicArn:
Description: Arn for Request Closed Topic
Value: ${self:custom.topicArns.requestClosed}
Export:
Name: ${self:service}:${opt:stage}:RequestClosedTopicArn
RequestCanceledTopicArn:
Description: Arn for Request Canceled Topic
Value: ${self:custom.topicArns.requestCanceled}
Export:
Name: ${self:service}:${opt:stage}:RequestCanceledTopicArn
RequestPlacedOnShelfTopicArn:
Description: Arn for Request Placed On Shelf Topic
Value: ${self:custom.topicArns.requestPlacedOnShelf}
Export:
Name: ${self:service}:${opt:stage}:RequestPlacedOnShelfTopicArn
custom:
KeyArns:
dev: ${env:KEY_ARN_DEV}
stg: ${env:KEY_ARN_STG}
prod: ${env:KEY_ARN_PROD}
environmentNames:
dev: development
stg: staging
prod: production
topicArns:
loanCreated:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [loanCreatedTopic, TopicName]
loanDueDate:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [loanDueDateTopic, TopicName]
loanRenewed:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [loanRenewedTopic, TopicName]
loanReturned:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [loanReturnedTopic, TopicName]
requestCreated:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [requestCreatedTopic, TopicName]
requestClosed:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [requestClosedTopic, TopicName]
requestCanceled:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [requestCanceledTopic, TopicName]
requestPlacedOnShelf:
"Fn::Join":
- ":"
- - "arn:aws:sns"
- Ref: "AWS::Region"
- Ref: "AWS::AccountId"
- "Fn::GetAtt": [requestPlacedOnShelfTopic, TopicName]
plugins:
- serverless-pseudo-parameters