forked from aws-samples/retail-demo-store
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathweb-ui-pipeline.yaml
501 lines (449 loc) · 15.3 KB
/
web-ui-pipeline.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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
AWSTemplateFormatVersion: 2010-09-09
Description: >
This template deploys the Retail Demo Store Web UI deployment pipeline.
Parameters:
ResourceBucket:
Type: String
Description: S3Bucket Bucket where the deployment Resources are stored (cloudformation, images, lambda code)
ResourceBucketRelativePath:
Type: String
Description: S3Bucket Path where the deployment Resources are stored (cloudformation, images, lambda code) (i.e. path/path2), can be empty if resources are at the root of the bucket. MUST contain trailing /
WebUICDN:
Type: String
Description: CloudFront distribution ID for the Web UI CDN
WebUIBucketName:
Type: String
Description: S3 bucket where Web UI assets stored for serving via CloudFront
WebRootUrl:
Type: String
Description: Public facing root URL where the Retail Demo Store web user interface is served. Used when building fully qualified URLs for the web user interface.
AllowedPattern: "^https?://[^\\s/$.?#].[^\\s]*$"
ConstraintDescription: Must be a valid URL referring to the root domain where web assets are located
ImageRootUrl:
Type: String
Description: URL where Retail Demo Store images such as product images are located
AllowedPattern: "^https?://[^\\s/$.?#].[^\\s]*$"
ConstraintDescription: Must be a valid URL referring to the root path where images are located
SourceDeploymentType:
Type: String
Description: Retail Demo Store source deployment type
AllowedValues:
- 'GitHub'
- 'S3'
Default: 'S3'
GitHubRepo:
Type: String
GitHubBranch:
Type: String
Default: master
GitHubToken:
Type: String
NoEcho: true
GitHubUser:
Type: String
AmazonPayPublicKeyId:
Type: String
Description: Public Key ID for the Amazon Pay sandbox account being used
AmazonPayStoreId:
Type: String
Description: Store ID of the Amazon Pay sandbox account being used
AmazonPayMerchantId:
Type: String
Description: Merchant ID of the Amazon Pay sandbox account being used
UserPoolId:
Type: String
UserPoolClientId:
Type: String
IdentityPoolId:
Type: String
APIGatewayUrl:
Type: String
Default: none
PinpointAppId:
Type: String
Default: none
ParameterPersonalizeEventTrackerId:
Type: String
ParameterAmplitudeApiKey:
Type: String
Description: SSM parameter name for the Amplitude API key parameter name
ParameterOptimizelySdkKey:
Type: String
Description: SSM Parameter name for the Optimizely SDK key parameter name
ParameterSegmentWriteKey:
Type: String
Description: SSM Parameter name for the Segment write key parameter name
ParameterGoogleAnalyticsMeasurementId:
Type: String
Description: Google Analytics Measurement Id parameter name
CleanupBucketLambdaArn:
Type: String
Description: Lambda Arn for cleanup function
LocationResourceName:
Type: String
Description: Name of Location resources (Map, Geofence collection, Tracker)
LocationNotificationEndpoint:
Type: String
Description: URL of WebSocket API for Geofence notifications
FenixZipDetectUrl:
Type: String
Description: Fenix Commerce Zipcode Detect URL
Default: 'https://ipapi.co/json?key=cKGC3jQbSIoXYmI2KtXObugsKfosD9Yr0HnkHhPUu1SM2wQhE0'
FenixTenantId:
Type: String
Description: Fenix Commerce Demo Env TenantID
Default: 'ec6ea3439489426ba09cf6c906ead8d5'
FenixEddEndpoint:
Type: String
Description: Fenix Commerce Estimated Delivery Date Endpoint URL
Default: 'https://awsretaildemo.delest.fenixcommerce.com/fenixdelest/api/v2/deliveryestimates'
FenixMonetaryValue:
Type: String
Description: Fenix Commerce Default monetary value to control free shipping above $100 default for demo
Default: '100'
FenixEnabledPdp:
Type: String
Description: Fenix Commerce Flag to enable EDD on PDP
Default: 'TRUE'
FenixEnabledCart:
Type: String
Description: Fenix Commerce Flag to enable EDD on CART
Default: 'TRUE'
FenixEnabledCheckout:
Type: String
Description: Fenix Commerce Flag to enable EDD on checkout
Default: 'TRUE'
FenixXapiKey:
Type: String
Description: Fenix Commerce Demo Env x-api-key
Default: 'nr50Qdu7FM94n2X1GYuhA8cFzyvdYTJ5Qka4XMOd'
LoggingBucketName:
Type: String
Description: S3 Bucket For logging
BedrockProductPersonalization:
Type: String
Description: Flag to enable product personalization in web-ui feature driven by Bedrock. Amazon Bedrock users need to request access to models before they are available for use. To demo Personalised Product Descriptions make sure to enable access to Anthropic's Claude v2 via the Amazon Bedrock Management Console. Check README Notes for more details.
Default: 'No'
RoomImagesBucket:
Type: String
Description: S3 Bucket name to contain room images for room makeover demo
Conditions:
LinkToGitHub: !Equals [ !Ref SourceDeploymentType, 'GitHub' ]
LinkToS3: !Equals [ !Ref SourceDeploymentType, 'S3' ]
Resources:
CodeBuildServiceRole:
Type: AWS::IAM::Role
Properties:
Path: /
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: codebuild.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: "logs"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- logs:CreateLogGroup
- logs:CreateLogStream
- logs:PutLogEvents
- ssm:GetParameters
- cloudfront:CreateInvalidation
Resource: "*"
- PolicyName: "S3"
PolicyDocument:
Version: "2012-10-17"
Statement:
-
Effect: "Allow"
Action:
- s3:GetObject
- s3:PutObject
- s3:GetObjectVersion
- s3:GetBucketVersioning
Resource:
- !Sub arn:${AWS::Partition}:s3:::${ArtifactBucket}/*
- !Sub arn:${AWS::Partition}:s3:::${WebUIBucketName}/*
CodePipelineServiceRole:
Type: AWS::IAM::Role
Properties:
Path: /
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: codepipeline.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: root
PolicyDocument:
Version: 2012-10-17
Statement:
- Resource:
- !Sub arn:${AWS::Partition}:s3:::${ArtifactBucket}/*
- !Sub arn:${AWS::Partition}:s3:::${ArtifactBucket}
Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:GetObjectVersion
- s3:GetBucketVersioning
- Resource: "*"
Effect: Allow
Action:
- codebuild:StartBuild
- codebuild:BatchGetBuilds
- Resource:
- !Sub arn:${AWS::Partition}:s3:::${ResourceBucket}/*
- !Sub arn:${AWS::Partition}:s3:::${ResourceBucket}
Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
- s3:GetObjectVersion
- s3:GetBucketVersioning
ArtifactBucket:
Type: AWS::S3::Bucket
Properties:
VersioningConfiguration:
Status: Enabled
LoggingConfiguration:
DestinationBucketName: !Ref LoggingBucketName
LogFilePrefix: artifactui-logs
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
SSEAlgorithm: AES256
BucketKeyEnabled: true
# Empties bucket when stack is deleted
EmptyArtifactBucket:
Type: Custom::EmptyArtifactBucket
Properties:
ServiceToken: !Ref CleanupBucketLambdaArn
BucketName: !Ref ArtifactBucket
CodeBuildProject:
Type: 'AWS::CodeBuild::Project'
Properties:
Name: !Ref AWS::StackName
Description: !Sub 'Building stage for ${AWS::StackName}'
Artifacts:
Type: CODEPIPELINE
Source:
Type: CODEPIPELINE
BuildSpec: src/web-ui/buildspec.yml
ServiceRole: !Ref CodeBuildServiceRole
Environment:
ComputeType: BUILD_GENERAL1_SMALL
EnvironmentVariables:
- Name: WEB_BUCKET_NAME
Value: !Ref WebUIBucketName
- Name: CLOUDFRONT_DIST_ID
Value: !Ref WebUICDN
- Name: AMAZON_PAY_PUBLIC_KEY_ID
Value: !Ref AmazonPayPublicKeyId
- Name: AMAZON_PAY_STORE_ID
Value: !Ref AmazonPayStoreId
- Name: AMAZON_PAY_MERCHANT_ID
Value: !Ref AmazonPayMerchantId
- Name: COGNITO_USER_POOL_ID
Value: !Sub ${UserPoolId}
- Name: COGNITO_USER_POOL_CLIENT_ID
Value: !Sub ${UserPoolClientId}
- Name: COGNITO_IDENTITY_POOL_ID
Value: !Sub ${IdentityPoolId}
- Name: API_GATEWAY_URL
Value: !Ref APIGatewayUrl
- Name: DEPLOYED_REGION
Value: !Ref AWS::Region
- Name: PINPOINT_APP_ID
Value: !Ref PinpointAppId
- Name: PERSONALIZE_TRACKING_ID
Type: PARAMETER_STORE
Value: !Ref ParameterPersonalizeEventTrackerId
- Name: AMPLITUDE_API_KEY
Type: PARAMETER_STORE
Value: !Ref ParameterAmplitudeApiKey
- Name: OPTIMIZELY_SDK_KEY
Type: PARAMETER_STORE
Value: !Ref ParameterOptimizelySdkKey
- Name: LOCATION_RESOURCE_NAME
Value: !Ref LocationResourceName
- Name: LOCATION_NOTIFICATION_URL
Value: !Ref LocationNotificationEndpoint
- Name: SEGMENT_WRITE_KEY
Type: PARAMETER_STORE
Value: !Ref ParameterSegmentWriteKey
- Name: GOOGLE_ANALYTICS_ID
Type: PARAMETER_STORE
Value: !Ref ParameterGoogleAnalyticsMeasurementId
- Name: WEB_ROOT_URL
Value: !Ref WebRootUrl
- Name: IMAGE_ROOT_URL
Value: !Ref ImageRootUrl
- Name: FENIX_ZIP_DETECT_URL
Value: !Ref FenixZipDetectUrl
- Name: FENIX_TENANT_ID
Value: !Ref FenixTenantId
- Name: FENIX_EDD_ENDPOINT
Value: !Ref FenixEddEndpoint
- Name: FENIX_MONETARY_VALUE
Value: !Ref FenixMonetaryValue
- Name: FENIX_ENABLED_PDP
Value: !Ref FenixEnabledPdp
- Name: FENIX_ENABLED_CART
Value: !Ref FenixEnabledCart
- Name: FENIX_ENABLED_CHECKOUT
Value: !Ref FenixEnabledCheckout
- Name: FENIX_X_API_KEY
Value: !Ref FenixXapiKey
- Name: BEDROCK_PRODUCT_PERSONALIZATION
Value: !Ref BedrockProductPersonalization
- Name: ROOM_IMAGES_BUCKET
Value: !Ref RoomImagesBucket
Image: 'aws/codebuild/amazonlinux2-x86_64-standard:5.0'
Type: LINUX_CONTAINER
PipelineGitHub:
Condition: LinkToGitHub
Type: AWS::CodePipeline::Pipeline
Properties:
RoleArn: !GetAtt CodePipelineServiceRole.Arn
Tags:
-
Key: RetailDemoStoreServiceName
Value: web-ui
ArtifactStore:
Type: S3
Location: !Ref ArtifactBucket
Stages:
- Name: Source
Actions:
- Name: App
ActionTypeId:
Category: Source
Owner: ThirdParty
Version: '1'
Provider: GitHub
Configuration:
Owner: !Ref GitHubUser
Repo: !Ref GitHubRepo
Branch: !Ref GitHubBranch
OAuthToken: !Ref GitHubToken
OutputArtifacts:
- Name: App
RunOrder: 1
- Name: Build
Actions:
- Name: Build-and-Deploy
InputArtifacts:
- Name: App
ActionTypeId:
Category: Build
Owner: AWS
Version: '1'
Provider: CodeBuild
OutputArtifacts:
- Name: BuildOutput
Configuration:
ProjectName: !Ref CodeBuildProject
RunOrder: 1
PipelineS3:
Condition: LinkToS3
Type: AWS::CodePipeline::Pipeline
Properties:
RoleArn: !GetAtt CodePipelineServiceRole.Arn
Tags:
-
Key: RetailDemoStoreServiceName
Value: web-ui
ArtifactStore:
Type: S3
Location: !Ref ArtifactBucket
Stages:
- Name: Source
Actions:
- Name: App
ActionTypeId:
Category: Source
Owner: AWS
Version: '1'
Provider: S3
Configuration:
S3Bucket: !Ref ResourceBucket
S3ObjectKey: !Sub '${ResourceBucketRelativePath}source/retaildemostore-source.zip'
PollForSourceChanges: false
OutputArtifacts:
- Name: App
RunOrder: 1
- Name: Build
Actions:
- Name: Build-and-Deploy
InputArtifacts:
- Name: App
ActionTypeId:
Category: Build
Owner: AWS
Version: '1'
Provider: CodeBuild
OutputArtifacts:
- Name: BuildOutput
Configuration:
ProjectName: !Ref CodeBuildProject
RunOrder: 1
EventRole:
Condition: LinkToS3
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Principal:
Service:
- events.amazonaws.com
Action: sts:AssumeRole
Path: /
Policies:
-
PolicyName: eb-pipeline-execution
PolicyDocument:
Version: 2012-10-17
Statement:
-
Effect: Allow
Action: codepipeline:StartPipelineExecution
Resource: !Join [ '', [ 'arn:aws:codepipeline:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':', !Ref PipelineS3 ] ]
EventRule:
Condition: LinkToS3
Type: AWS::Events::Rule
Properties:
EventPattern:
source:
- aws.s3
detail-type:
- 'Object Created'
detail:
bucket:
name:
- !Ref ResourceBucket
object:
key:
- !Sub ${ResourceBucketRelativePath}source/retaildemostore-source.zip
Targets:
- Arn: !Sub 'arn:${AWS::Partition}:codepipeline:${AWS::Region}:${AWS::AccountId}:${PipelineS3}'
RoleArn: !GetAtt EventRole.Arn
Id: codepipeline-AppPipeline
Outputs:
PipelineForGitHubUrl:
Condition: LinkToGitHub
Value: !Sub https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${PipelineGitHub}
PipelineForS3Url:
Condition: LinkToS3
Value: !Sub https://console.aws.amazon.com/codepipeline/home?region=${AWS::Region}#/view/${PipelineS3}