-
Notifications
You must be signed in to change notification settings - Fork 4
/
cisco-dnacaap-aws-cf.yaml
325 lines (325 loc) · 9.26 KB
/
cisco-dnacaap-aws-cf.yaml
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
322
323
324
325
AWSTemplateFormatVersion: 2010-09-09
Parameters:
EmailSubscriber:
Type: String
AllowedPattern: .+
Description: >-
What's the first subscribers email? (Only one. More can be added in the
AWS SNS Service Portal)
Metadata:
'AWS::CloudFormation::Designer':
bdbd6f02-f496-476a-8177-61269b1fa3a6:
size:
width: 60
height: 60
position:
x: -160
'y': 90
z: 1
embeds: []
e551bd59-1c06-4b29-b87b-f3bc04ad3c25:
size:
width: 330
height: 240
position:
x: 80
'y': 110
z: 1
embeds:
- 9498b44d-683f-4f4c-82e2-41b57e07d348
- 52c1e2d0-cf7e-49b0-b269-fbb82c3b1085
9498b44d-683f-4f4c-82e2-41b57e07d348:
size:
width: 60
height: 60
position:
x: 110
'y': 170
z: 2
parent: e551bd59-1c06-4b29-b87b-f3bc04ad3c25
embeds: []
iscontainedinside:
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
52c1e2d0-cf7e-49b0-b269-fbb82c3b1085:
size:
width: 60
height: 60
position:
x: 230
'y': 170
z: 2
parent: e551bd59-1c06-4b29-b87b-f3bc04ad3c25
embeds: []
iscontainedinside:
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
dependson:
- 9498b44d-683f-4f4c-82e2-41b57e07d348
e3de2aeb-a71c-48a6-8115-9020e1a2ba2a:
size:
width: 60
height: 60
position:
x: -160
'y': 190
z: 1
embeds: []
dependson:
- e551bd59-1c06-4b29-b87b-f3bc04ad3c25
- bdbd6f02-f496-476a-8177-61269b1fa3a6
95d0cb3d-5e23-4da9-ae47-39c27193bded:
size:
width: 60
height: 60
position:
x: -60
'y': 10
z: 1
embeds: []
62fe7413-e987-44f0-9b67-32da079ab1bc:
size:
width: 60
height: 60
position:
x: 160
'y': 10
z: 1
embeds: []
dependson:
- bdbd6f02-f496-476a-8177-61269b1fa3a6
- 95d0cb3d-5e23-4da9-ae47-39c27193bded
c1bd7af2-9a4c-428c-991e-96d923b58f3b:
size:
width: 60
height: 60
position:
x: -10
'y': 300
z: 1
embeds: []
c3e1fe72-b120-4285-aef3-79047abf72db:
size:
width: 60
height: 60
position:
x: -160
'y': 300
z: 1
embeds: []
dependson:
- c1bd7af2-9a4c-428c-991e-96d923b58f3b
ff947cc5-eccb-4357-9bee-46013782c40e:
size:
width: 60
height: 60
position:
x: -240
'y': 150
z: 1
embeds: []
Resources:
lambdaFunction:
Type: 'AWS::Lambda::Function'
Properties:
FunctionName: !Sub 'cisco-dnacaap-aws-lambda-${AWS::Region}'
Description: Receive JSON payload from Cisco DNA Center
Handler: lambda_function.lambda_handler
Runtime: python3.7
Code:
S3Bucket: !Sub 'cisco-dnacaap-aws-s3-${AWS::Region}'
S3Key: cisco-dnacaap-aws-lambda.zip
MemorySize: 128
Timeout: 3
Role: !GetAtt lambdaIAMRole.Arn
Environment:
Variables:
S3BUCKET: !Ref s3Bucket
SNSARN: !Ref snsTopic
SNSTOPIC: !GetAtt
- snsTopic
- TopicName
Metadata:
'AWS::CloudFormation::Designer':
id: bdbd6f02-f496-476a-8177-61269b1fa3a6
DependsOn:
- snsTopic
- s3Bucket
lambdaIAMRole:
Type: 'AWS::IAM::Role'
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 'sts:AssumeRole'
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Policies:
- PolicyDocument:
Version: 2012-10-17
Statement:
- Action:
- 'sns:Publish'
Effect: Allow
Resource: !Ref snsTopic
- Action:
- 'logs:CreateLogGroup'
- 'logs:CreateLogStream'
- 'logs:PutLogEvents'
Effect: Allow
Resource:
- !Sub >-
arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:cisco-dnacaap-aws-lambda-${AWS::Region}:*
PolicyName: lambda
Metadata:
'AWS::CloudFormation::Designer':
id: ff947cc5-eccb-4357-9bee-46013782c40e
DependsOn:
- snsTopic
apiGateway:
Type: 'AWS::ApiGateway::RestApi'
Properties:
Name: !Sub 'cisco-dnacaap-aws-apigw-${AWS::Region}'
Description: Cisco DNA Center Lambda API Gateway
Metadata:
'AWS::CloudFormation::Designer':
id: e551bd59-1c06-4b29-b87b-f3bc04ad3c25
apiGatewayRootMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
AuthorizationType: NONE
HttpMethod: POST
Integration:
IntegrationHttpMethod: POST
Type: AWS_PROXY
Uri: !Sub
- >-
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${lambdaArn}/invocations
- lambdaArn: !GetAtt
- lambdaFunction
- Arn
ResourceId: !GetAtt
- apiGateway
- RootResourceId
RestApiId: !Ref apiGateway
Metadata:
'AWS::CloudFormation::Designer':
id: 9498b44d-683f-4f4c-82e2-41b57e07d348
apiGatewayDeployment:
Type: 'AWS::ApiGateway::Deployment'
DependsOn:
- apiGatewayRootMethod
Properties:
RestApiId: !Ref apiGateway
StageName: default
Metadata:
'AWS::CloudFormation::Designer':
id: 52c1e2d0-cf7e-49b0-b269-fbb82c3b1085
lambdaAttachApiGateway:
Type: 'AWS::Lambda::Permission'
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !GetAtt
- lambdaFunction
- Arn
Principal: apigateway.amazonaws.com
SourceArn: !Sub >-
arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${apiGateway}/*/POST/
Metadata:
'AWS::CloudFormation::Designer':
id: e3de2aeb-a71c-48a6-8115-9020e1a2ba2a
DependsOn:
- lambdaFunction
- apiGateway
s3Bucket:
Type: 'AWS::S3::Bucket'
Properties:
BucketName: !Sub 'cisco-dnacaap-aws-lambda-s3-${AWS::Region}'
PublicAccessBlockConfiguration:
BlockPublicAcls: true
IgnorePublicAcls: true
BlockPublicPolicy: true
RestrictPublicBuckets: true
LifecycleConfiguration:
Rules:
- Id: purge
Prefix: ''
Status: Enabled
ExpirationInDays: '30'
Metadata:
'AWS::CloudFormation::Designer':
id: c1bd7af2-9a4c-428c-991e-96d923b58f3b
s3BucketPolicy:
Type: 'AWS::S3::BucketPolicy'
Properties:
Bucket: !Ref s3Bucket
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: !GetAtt lambdaIAMRole.Arn
Action:
- 's3:PutObject'
- 's3:PutObjectAcl'
Resource: !Sub 'arn:aws:s3:::cisco-dnacaap-aws-lambda-s3-${AWS::Region}/*'
Metadata:
'AWS::CloudFormation::Designer':
id: c3e1fe72-b120-4285-aef3-79047abf72db
DependsOn:
- s3Bucket
snsTopic:
Type: 'AWS::SNS::Topic'
Properties:
TopicName: !Sub 'cisco-dnacaap-aws-sns-${AWS::Region}'
DisplayName: Cisco DNA Center Assurance Notification
Metadata:
'AWS::CloudFormation::Designer':
id: 95d0cb3d-5e23-4da9-ae47-39c27193bded
snsEmailSubscriber:
Type: 'AWS::SNS::Subscription'
Properties:
Endpoint: !Ref EmailSubscriber
Protocol: email
TopicArn: !Ref snsTopic
Metadata:
'AWS::CloudFormation::Designer':
id: 62fe7413-e987-44f0-9b67-32da079ab1bc
DependsOn:
- snsTopic
- lambdaFunction