-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcontent-localization-on-aws.yaml
executable file
·332 lines (307 loc) · 10.6 KB
/
content-localization-on-aws.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
326
327
328
329
330
331
332
AWSTemplateFormatVersion: "2010-09-09"
Description: "(SO0164) Content Localization on AWS %%VERSION%%"
Parameters:
AdminEmail:
Description: "Email address of the Content Localization on AWS administrator"
Type: String
OpensearchNodeSize:
Description: "The node type to be provisioned for the Opensearch cluster"
Type: String
Default: "t3.small.search"
AllowedValues:
- "t3.small.search"
- "m4.large.search"
- "m4.xlarge.search"
- "c4.large.search"
- "c4.xlarge.search"
- "r4.large.search"
- "r4.xlarge.search"
Conditions:
EnableAnonymizedData: !Equals [ !FindInMap [AnonymizedData,SendAnonymizedData,Data], "Yes"]
Mappings:
MediaInsights:
Release:
Version: "v5.1.9"
Application:
SourceCode:
GlobalS3Bucket: "%%GLOBAL_BUCKET_NAME%%"
TemplateKeyPrefix: "content-localization-on-aws/%%VERSION%%"
RegionalS3Bucket: "%%REGIONAL_BUCKET_NAME%%"
CodeKeyPrefix: "content-localization-on-aws/%%VERSION%%"
Version: "%%VERSION%%"
Solution:
Data:
SolutionId: "SO0164"
SolutionName: "Content Localization on AWS"
ApplicationType: "AWS-Solutions"
AppRegistryApplicationName: "ContentLocalizationOnAws"
AnonymizedData:
SendAnonymizedData:
Data: "Yes"
Resources:
# Deploy Media Insights on AWS Framework
MieStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://solutions-reference.s3.amazonaws.com/media-insights-on-aws/"
- !FindInMap
- MediaInsights
- Release
- Version
- "/media-insights-on-aws-stack.template"
Parameters:
DeployAnalyticsPipeline: "Yes"
DeployTestResources: "No"
MaxConcurrentWorkflows: 5
EnableXrayTrace: "Yes"
SolutionId: SO0164
SolutionVersion: "%%VERSION%%"
# Deploy Opensearch
OpensearchStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/content-localization-on-aws-opensearch.template"
Parameters:
AnalyticsStreamArn: !GetAtt MieStack.Outputs.AnalyticsStreamArn
MieDataplaneBucket: !GetAtt MieStack.Outputs.DataplaneBucket
NodeType: !Ref OpensearchNodeSize
MieKMSArn: !GetAtt MieStack.Outputs.MieKMSArn
# Deploy Auth stack
AuthStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/content-localization-on-aws-auth.template"
Parameters:
AdminEmail: !Ref AdminEmail
WorkflowApiId: !GetAtt MieStack.Outputs.WorkflowApiRestID
DataplaneApiId: !GetAtt MieStack.Outputs.DataplaneApiRestID
SearchDomainArn: !GetAtt OpensearchStack.Outputs.DomainArn
DataplaneBucket: !GetAtt MieStack.Outputs.DataplaneBucket
ParentStackName: !Ref MieStack
MieKMSArn: !GetAtt MieStack.Outputs.MieKMSArn
WebStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/content-localization-on-aws-web.template"
Parameters:
DataplaneEndpoint: !GetAtt MieStack.Outputs.DataplaneApiEndpoint
WorkflowEndpoint: !GetAtt MieStack.Outputs.WorkflowApiEndpoint
SearchEndpoint: !GetAtt OpensearchStack.Outputs.DomainEndpoint
DataplaneBucket: !GetAtt MieStack.Outputs.DataplaneBucket
UserPoolId: !GetAtt AuthStack.Outputs.UserPoolId
IdentityPoolId: !GetAtt AuthStack.Outputs.IdentityPoolId
PoolClientId: !GetAtt AuthStack.Outputs.UserPoolClientId
# Deploy video workflow
VideoWorkflow:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/content-localization-on-aws-video-workflow.template"
Parameters:
WorkflowCustomResourceArn:
Fn::GetAtt:
- MieStack
- Outputs.WorkflowCustomResourceArn
OperatorLibraryStack:
Fn::GetAtt:
- MieStack
- Outputs.OperatorLibraryStack
AnonymizedDataCustomResourceRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
Policies:
-
PolicyName: !Sub "${AWS::StackName}-anonymized-data-logger"
PolicyDocument:
Statement:
-
Effect: Allow
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
Resource:
- !Join ["", ["arn:aws:logs:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":log-group:/aws/lambda/*"]]
-
Effect: Allow
Action:
- ssm:PutParameter
Resource:
- !Join ["", ["arn:aws:ssm:", Ref: "AWS::Region", ":", Ref: "AWS::AccountId", ":parameter/*"]]
AnonymizedDataCustomResource:
Type: AWS::Lambda::Function
Metadata:
cfn_nag:
rules_to_suppress:
- id: W89
reason: "This Lambda function does not need to access any resource provisioned within a VPC."
- id: W92
reason: "This function does not require performance optimization, so the default concurrency limits suffice."
Properties:
FunctionName: !Sub ${AWS::StackName}-anonymized-data
Description: Used to send anonymized data
Handler: anonymized-data-logger.handler
Role: !GetAtt AnonymizedDataCustomResourceRole.Arn
Code:
S3Bucket: !Join [ "-", [ !FindInMap [ "Application", "SourceCode", "RegionalS3Bucket" ], Ref: "AWS::Region" ] ]
S3Key: !Join [ "/", [ !FindInMap [ "Application", "SourceCode", "CodeKeyPrefix" ], "anonymized-data-logger.zip" ] ]
Runtime: python3.11
Timeout: 180
# SendAnonymizedData
AnonymizedDataUuid:
Condition: EnableAnonymizedData
Type: "Custom::UUID"
Properties:
ServiceToken: !GetAtt AnonymizedDataCustomResource.Arn
Resource: UUID
AnonymizedMetric:
Condition: EnableAnonymizedData
Type: "Custom::AnonymizedMetric"
Properties:
ServiceToken: !GetAtt AnonymizedDataCustomResource.Arn
Resource: AnonymizedMetric
SolutionId: "SO0164"
UUID: !GetAtt AnonymizedDataUuid.UUID
Version: !FindInMap ["Application", "SourceCode", "Version"]
# AppRegistry
Application:
Type: AWS::ServiceCatalogAppRegistry::Application
Properties:
Description: !Sub
- Service Catalog application to track and manage all your resources. The Solution ID is ${solutionId} and Solution Version is ${solutionVersion}.
-
solutionId: !FindInMap
- Solution
- Data
- SolutionId
solutionVersion: !FindInMap
- Application
- SourceCode
- Version
Name:
!Join
- "-"
- - !FindInMap [Solution, Data, "AppRegistryApplicationName"]
- !Ref AWS::Region
- !Ref AWS::AccountId
- !Ref AWS::StackName
Tags: {
'Solutions:SolutionID': !FindInMap [Solution, Data, "SolutionId"],
'Solutions:SolutionName': !FindInMap [Solution, Data, "SolutionName"],
'Solutions:SolutionVersion': !FindInMap [Application, SourceCode, "Version"],
'Solutions:ApplicationType': !FindInMap [Solution, Data, "ApplicationType"],
}
AppRegistryApplicationStackAssociation:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref AWS::StackId
ResourceType: CFN_STACK
DefaultApplicationAttributes:
Type: AWS::ServiceCatalogAppRegistry::AttributeGroup
Properties:
Name: !Join ['-', [!Ref 'AWS::Region', !Ref 'AWS::StackName']]
Description: Attribute group for solution information.
Attributes:
{ "ApplicationType" : !FindInMap [Solution, Data, "ApplicationType"],
"Version": !FindInMap [Application, SourceCode, "Version"],
"SolutionID": !FindInMap [Solution, Data, "SolutionId"],
"SolutionName": !FindInMap [Solution, Data, "SolutionName"]
}
AppRegistryApplicationAttributeAssociation:
Type: AWS::ServiceCatalogAppRegistry::AttributeGroupAssociation
Properties:
Application: !GetAtt Application.Id
AttributeGroup: !GetAtt DefaultApplicationAttributes.Id
AppRegistryApplicationStackAssociationOpenSearchStack:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref OpensearchStack
ResourceType: CFN_STACK
AppRegistryApplicationStackAssociationAuthStack:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref AuthStack
ResourceType: CFN_STACK
AppRegistryApplicationStackAssociationWebStack:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref WebStack
ResourceType: CFN_STACK
AppRegistryApplicationStackAssociationVideoWorkflowStack:
Type: AWS::ServiceCatalogAppRegistry::ResourceAssociation
Properties:
Application: !GetAtt Application.Id
Resource:
!Ref VideoWorkflow
ResourceType: CFN_STACK
Outputs:
ContentLocalizationSolution:
Value: !GetAtt WebStack.Outputs.CloudfrontUrl