-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate.yml
321 lines (321 loc) · 8.76 KB
/
template.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
AWSTemplateFormatVersion: 2010-09-09
Metadata:
'AWS::CloudFormation::Designer':
fef35747-14d8-41d6-b3d5-c5fdd8f7cdbd:
size:
width: 60
height: 60
position:
x: 270
'y': 60
z: 1
embeds: []
dependson:
- b4f06d48-7e6e-42fb-a4fb-b0c893a900b4
b4f06d48-7e6e-42fb-a4fb-b0c893a900b4:
size:
width: 60
height: 60
position:
x: 420
'y': 60
z: 1
embeds: []
isassociatedwith:
- fef35747-14d8-41d6-b3d5-c5fdd8f7cdbd
83abc666-7f64-4024-8b5f-e65ed065f457:
size:
width: 270
height: 270
position:
x: -20
'y': 80
z: 1
embeds:
- 8160655f-bb99-4486-8d14-50c378eff1d4
- f3fecff9-bf64-4a9e-bcf0-c1d8397ded4a
- 3b01c77b-58eb-45f7-b067-60f5214053dd
35e070e2-6ab8-4b16-92e1-dd9b31e92517:
size:
width: 60
height: 60
position:
x: 120
'y': 270
z: 1
embeds: []
f3fecff9-bf64-4a9e-bcf0-c1d8397ded4a:
size:
width: 60
height: 60
position:
x: 0
'y': 210
z: 2
parent: 83abc666-7f64-4024-8b5f-e65ed065f457
embeds: []
iscontainedinside:
- 83abc666-7f64-4024-8b5f-e65ed065f457
3b01c77b-58eb-45f7-b067-60f5214053dd:
size:
width: 60
height: 60
position:
x: 120
'y': 130
z: 2
parent: 83abc666-7f64-4024-8b5f-e65ed065f457
embeds: []
iscontainedinside:
- 83abc666-7f64-4024-8b5f-e65ed065f457
dependson:
- f3fecff9-bf64-4a9e-bcf0-c1d8397ded4a
b2b36c49-1ec1-4ce8-ae47-e9f59d29f0ad:
size:
width: 60
height: 60
position:
x: 240
'y': 180
z: 1
embeds: []
8160655f-bb99-4486-8d14-50c378eff1d4:
size:
width: 60
height: 60
position:
x: 10
'y': 140
z: 2
parent: 83abc666-7f64-4024-8b5f-e65ed065f457
embeds: []
iscontainedinside:
- 83abc666-7f64-4024-8b5f-e65ed065f457
Parameters:
GITHUBAPIKEY:
Type: String
Description: This is your API key as an admin for a GitHub group.
GITHUBTEAMURL:
Type: String
Description: This is the url of the GitHub group.
AllowedPattern: >-
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
AIRTABLEURL:
Type: String
Description: This is the Airtable url with the API key.
MAILCHIMPAPIKEY:
Type: String
Description: This is your API key as an admin for a MailChimp List.
MAILCHIMPLISTID:
Type: String
Description: This is the id of your MailChimp list.
Resources:
s3bucket:
Type: 'AWS::S3::Bucket'
Properties:
AccessControl: PublicRead
BucketName: !Join
- ''
- - !Ref 'AWS::StackName'
- '-bucket'
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
RoutingRules:
- RoutingRuleCondition:
HttpErrorCodeReturnedEquals: '404'
KeyPrefixEquals: out1/
RedirectRule:
HostName: ec2-11-22-333-44.compute-1.amazonaws.com
ReplaceKeyPrefixWith: report-404/
Metadata:
'AWS::CloudFormation::Designer':
id: fef35747-14d8-41d6-b3d5-c5fdd8f7cdbd
s3bucketpolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref s3bucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Sid: AddPerm
Effect: Allow
Principal: '*'
Action: 's3:GetObject'
Resource: !Join
- ''
- - 'arn:aws:s3:::'
- !Ref s3bucket
- /*
Metadata:
'AWS::CloudFormation::Designer':
id: b4f06d48-7e6e-42fb-a4fb-b0c893a900b4
apigateway:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Description: API Gateway for Lambda
Name: !Join
- ''
- - !Ref 'AWS::StackName'
- '-apigateway'
Metadata:
'AWS::CloudFormation::Designer':
id: 83abc666-7f64-4024-8b5f-e65ed065f457
lambda:
Type: 'AWS::Lambda::Function'
Properties:
Code:
S3Bucket: lambda-severless
S3Key: lambda.zip
Description: 'Lambda function that consumes MailChimp, Github Airtable'
FunctionName: !Join
- ''
- - !Ref 'AWS::StackName'
- '-lambda'
Handler: index.handler
Role: !GetAtt
- iamrole
- Arn
Runtime: nodejs8.10
Environment:
Variables:
AIRTABLE_URL: !Ref AIRTABLEURL
GITHUB_ACCESS_TOKEN: !Ref GITHUBAPIKEY
GITHUB_TEAM_URL: !Ref GITHUBTEAMURL
MAILCHIMP_ADMIN_TOKEN: !Ref MAILCHIMPAPIKEY
MAILCHIMP_LIST_ID: !Ref MAILCHIMPLISTID
Metadata:
'AWS::CloudFormation::Designer':
id: 35e070e2-6ab8-4b16-92e1-dd9b31e92517
DependsOn:
- iamrole
apimethodpost:
Type: 'AWS::ApiGateway::Method'
Properties:
AuthorizationType: NONE
HttpMethod: POST
Integration:
Type: AWS
IntegrationHttpMethod: POST
Credentials: !GetAtt
- iamrole
- Arn
Uri: !Join
- ''
- - 'arn:aws:apigateway:'
- !Ref 'AWS::Region'
- ':lambda:path/2015-03-31/functions/'
- !GetAtt
- lambda
- Arn
- /invocations
IntegrationResponses:
- StatusCode: 200
ResponseParameters:
method.response.header.Access-Control-Allow-Origin: '''*'''
ResourceId: !GetAtt
- apigateway
- RootResourceId
RestApiId: !Ref apigateway
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json: Empty
ResponseParameters:
method.response.header.Access-Control-Allow-Origin: true
Metadata:
'AWS::CloudFormation::Designer':
id: f3fecff9-bf64-4a9e-bcf0-c1d8397ded4a
apimethodoptions:
Type: 'AWS::ApiGateway::Method'
Properties:
AuthorizationType: NONE
RestApiId: !Ref apigateway
ResourceId: !GetAtt
- apigateway
- RootResourceId
HttpMethod: OPTIONS
Integration:
IntegrationResponses:
- StatusCode: 200
ResponseParameters:
method.response.header.Access-Control-Allow-Headers: >-
'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'
method.response.header.Access-Control-Allow-Methods: '''POST,OPTIONS'''
method.response.header.Access-Control-Allow-Origin: '''*'''
ResponseTemplates:
application/json: ''
PassthroughBehavior: WHEN_NO_MATCH
RequestTemplates:
application/json: '{"statusCode": 200}'
Type: MOCK
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json: Empty
ResponseParameters:
method.response.header.Access-Control-Allow-Headers: true
method.response.header.Access-Control-Allow-Methods: true
method.response.header.Access-Control-Allow-Origin: true
Metadata:
'AWS::CloudFormation::Designer':
id: 8160655f-bb99-4486-8d14-50c378eff1d4
apideploy:
DependsOn:
- apimethodpost
- apimethodoptions
Type: 'AWS::ApiGateway::Deployment'
Properties:
RestApiId: !Ref apigateway
Description: First Stage
StageName: Stage0
Metadata:
'AWS::CloudFormation::Designer':
id: 3b01c77b-58eb-45f7-b067-60f5214053dd
iamrole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- apigateway.amazonaws.com
Action:
- 'sts:AssumeRole'
Path: /
Policies:
- PolicyName: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: '*'
Resource: '*'
Metadata:
'AWS::CloudFormation::Designer':
id: b2b36c49-1ec1-4ce8-ae47-e9f59d29f0ad
Outputs:
WebsiteURL:
Value: !GetAtt
- s3bucket
- WebsiteURL
Description: URL for website hosted on S3
S3BucketSecureURL:
Value: !Join
- ''
- - 'https://'
- !GetAtt
- s3bucket
- DomainName
Description: Name of S3 bucket to hold website content
InvokeUrl:
Value: !Join
- ''
- - 'https://'
- !Ref apigateway
- .execute-api.
- !Ref 'AWS::Region'
- .amazonaws.com/Stage0