This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathaws-content-analysis.yaml
executable file
·268 lines (249 loc) · 8.24 KB
/
aws-content-analysis.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
AWSTemplateFormatVersion: "2010-09-09"
Description: "(SO0042) - aws-content-analysis %%VERSION%%. This is the base AWS CloudFormation template that provisions resources for the AWS Content Analysis solution."
Parameters:
AdminEmail:
Description: "Email address of the AWS Content Analysis 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:
EnableAnonymousData: !Equals [ !FindInMap [AnonymousData,SendAnonymousData,Data], "Yes"]
Mappings:
MediaInsightsEngine:
Release:
Version: "v5.1.2"
Application:
SourceCode:
GlobalS3Bucket: "%%GLOBAL_BUCKET_NAME%%"
TemplateKeyPrefix: "content-analysis-on-aws/%%VERSION%%"
RegionalS3Bucket: "%%REGIONAL_BUCKET_NAME%%"
CodeKeyPrefix: "content-analysis-on-aws/%%VERSION%%"
Version: "%%VERSION%%"
AnonymousData:
SendAnonymousData:
Data: "Yes"
Resources:
# Deploy MIE Framework
MieStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://solutions-reference.s3.amazonaws.com/media-insights-on-aws/"
- !FindInMap
- MediaInsightsEngine
- Release
- Version
- "/media-insights-on-aws-stack.template"
Parameters:
DeployAnalyticsPipeline: "Yes"
DeployTestResources: "No"
MaxConcurrentWorkflows: 5
EnableXrayTrace: "Yes"
SendAnonymousData: !FindInMap [AnonymousData,SendAnonymousData,Data]
SolutionId: SO0042
SolutionVersion: "%%VERSION%%"
# Deploy Opensearch
OpensearchStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/aws-content-analysis-opensearch.template"
Parameters:
AnalyticsStreamArn: !GetAtt MieStack.Outputs.AnalyticsStreamArn
MieDataplaneBucket: !GetAtt MieStack.Outputs.DataplaneBucket
NodeType: !Ref OpensearchNodeSize
MieKMSKeyArn: !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
- "/aws-content-analysis-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
MieKMSKeyArn: !GetAtt MieStack.Outputs.MieKMSArn
WebStack:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/aws-content-analysis-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
CompleteVideoWorkflow:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/aws-content-analysis-video-workflow.template"
Parameters:
WorkflowCustomResourceArn:
Fn::GetAtt:
- MieStack
- Outputs.WorkflowCustomResourceArn
OperatorLibraryStack:
Fn::GetAtt:
- MieStack
- Outputs.OperatorLibraryStack
# Deploy image workflow
CompleteImageWorkflow:
Type: "AWS::CloudFormation::Stack"
Properties:
TemplateURL: !Join
- ""
- - "https://"
- !FindInMap
- Application
- SourceCode
- GlobalS3Bucket
- ".s3.amazonaws.com/"
- !FindInMap
- Application
- SourceCode
- TemplateKeyPrefix
- "/aws-content-analysis-image-workflow.template"
Parameters:
WorkflowCustomResourceArn:
Fn::GetAtt:
- MieStack
- Outputs.WorkflowCustomResourceArn
OperatorLibraryStack:
Fn::GetAtt:
- MieStack
- Outputs.OperatorLibraryStack
AnonymousDataCustomResourceRole:
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}-anonymous-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/*"]]
AnonymousDataCustomResource:
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}-anonymous-data
Description: Used to send anonymous data
Handler: anonymous-data-logger.handler
Role: !GetAtt AnonymousDataCustomResourceRole.Arn
Code:
S3Bucket: !Join [ "-", [ !FindInMap [ "Application", "SourceCode", "RegionalS3Bucket" ], Ref: "AWS::Region" ] ]
S3Key: !Join [ "/", [ !FindInMap [ "Application", "SourceCode", "CodeKeyPrefix" ], "anonymous-data-logger.zip" ] ]
Runtime: python3.8
Timeout: 180
# SendAnonymousData
AnonymousDataUuid:
Condition: EnableAnonymousData
Type: "Custom::UUID"
Properties:
ServiceToken: !GetAtt AnonymousDataCustomResource.Arn
Resource: UUID
AnonymousMetric:
Condition: EnableAnonymousData
Type: "Custom::AnonymousMetric"
Properties:
ServiceToken: !GetAtt AnonymousDataCustomResource.Arn
Resource: AnonymousMetric
SolutionId: "SO0042"
UUID: !GetAtt AnonymousDataUuid.UUID
Version: !FindInMap ["Application", "SourceCode", "Version"]
Outputs:
ContentAnalyisSolution:
Value: !GetAtt WebStack.Outputs.CloudfrontUrl