@@ -33,30 +33,27 @@ Parameters:
33
33
AllowedValues : [development, production]
34
34
35
35
Conditions :
36
- TargetsMainBranch : !Equals [ !Ref GitHubBranch, main ]
37
- DeployForDevelopment : !Equals [!Ref EnvironmentType, development ]
38
- DeployForProduction : !Equals [!Ref EnvironmentType, production ]
39
-
36
+ TargetsMainBranch : !Equals [!Ref GitHubBranch, main]
37
+ DeployForDevelopment : !Equals [!Ref EnvironmentType, development]
38
+ DeployForProduction : !Equals [!Ref EnvironmentType, production]
40
39
41
40
Resources :
42
-
43
41
# The Elastic Container Registry Repository will store our built docker
44
42
# images, for example, the load-test docker image.
45
43
EcrRepository :
46
44
Type : AWS::ECR::Repository
47
- Properties :
45
+ Properties :
48
46
RepositoryName : !Sub javabuilder-${GitHubBranch}
49
47
RepositoryPolicyText :
50
48
Version : " 2012-10-17"
51
- Statement :
52
- -
53
- Sid : AllowDeveloperPushPull
49
+ Statement :
50
+ - Sid : AllowDeveloperPushPull
54
51
Effect : Allow
55
- Principal :
56
- AWS :
52
+ Principal :
53
+ AWS :
57
54
- !ImportValue JavabuilderCodeBuildRoleArn
58
55
- !Sub " arn:aws:iam::${AWS::AccountId}:role/admin/Developer"
59
- Action :
56
+ Action :
60
57
- " ecr:GetDownloadUrlForLayer"
61
58
- " ecr:BatchGetImage"
62
59
- " ecr:BatchCheckLayerAvailability"
@@ -66,7 +63,7 @@ Resources:
66
63
- " ecr:CompleteLayerUpload"
67
64
68
65
EncryptionKey :
69
- Type : ' AWS::KMS::Key'
66
+ Type : " AWS::KMS::Key"
70
67
Properties :
71
68
Description : encryption key for javabuilder cicd artifacts
72
69
EnableKeyRotation : true
@@ -76,39 +73,39 @@ Resources:
76
73
- Sid : Ensure root user access
77
74
Effect : Allow
78
75
Principal :
79
- AWS : !Sub ' arn:aws:iam::${AWS::AccountId}:root'
80
- Action : ' kms:*'
81
- Resource : ' * '
76
+ AWS : !Sub " arn:aws:iam::${AWS::AccountId}:root"
77
+ Action : " kms:*"
78
+ Resource : " * "
82
79
- Sid : Allow administration of the key
83
80
Effect : Allow
84
81
Principal :
85
82
AWS : !Sub arn:aws:iam::${AWS::AccountId}:role/admin/Developer
86
83
Action :
87
- - ' kms:Create*'
88
- - ' kms:Describe*'
89
- - ' kms:Enable*'
90
- - ' kms:List*'
91
- - ' kms:Put*'
92
- - ' kms:Update*'
93
- - ' kms:Revoke*'
94
- - ' kms:Disable*'
95
- - ' kms:Get*'
96
- - ' kms:Delete*'
97
- - ' kms:ScheduleKeyDeletion'
98
- - ' kms:CancelKeyDeletion'
99
- Resource : ' * '
84
+ - " kms:Create*"
85
+ - " kms:Describe*"
86
+ - " kms:Enable*"
87
+ - " kms:List*"
88
+ - " kms:Put*"
89
+ - " kms:Update*"
90
+ - " kms:Revoke*"
91
+ - " kms:Disable*"
92
+ - " kms:Get*"
93
+ - " kms:Delete*"
94
+ - " kms:ScheduleKeyDeletion"
95
+ - " kms:CancelKeyDeletion"
96
+ Resource : " * "
100
97
- Sid : Allow use of the key
101
98
Effect : Allow
102
99
Principal :
103
100
AWS : !ImportValue JavabuilderCodeBuildRoleArn
104
101
Action :
105
- - ' kms:DescribeKey'
106
- - ' kms:Encrypt'
107
- - ' kms:Decrypt'
108
- - ' kms:ReEncrypt*'
109
- - ' kms:GenerateDataKey'
110
- - ' kms:GenerateDataKeyWithoutPlaintext'
111
- Resource : ' * '
102
+ - " kms:DescribeKey"
103
+ - " kms:Encrypt"
104
+ - " kms:Decrypt"
105
+ - " kms:ReEncrypt*"
106
+ - " kms:GenerateDataKey"
107
+ - " kms:GenerateDataKeyWithoutPlaintext"
108
+ Resource : " * "
112
109
113
110
# The CodeBuild Project is triggered by pull requests targeting $GitHubBranch
114
111
# It will perform any steps defined in the pr-buildspec.yml file.
@@ -149,7 +146,7 @@ Resources:
149
146
Type : BASE_REF
150
147
- Pattern : PULL_REQUEST_CREATED,PULL_REQUEST_UPDATED,PULL_REQUEST_REOPENED
151
148
Type : EVENT
152
-
149
+
153
150
# The CodeBuild Project is used in the CodePipeline pipeline to prepare for a release.
154
151
# It will perform any steps defined in the referenced buildspec.yml file.
155
152
LoadTestBuildProject :
@@ -172,7 +169,7 @@ Resources:
172
169
BuildSpec : cicd/3-app/load-test/load-test.buildspec.yml
173
170
Artifacts :
174
171
Type : CODEPIPELINE
175
-
172
+
176
173
# The CodeBuild Project is used in the CodePipeline pipeline to prepare for a release.
177
174
# It will perform any steps defined in the referenced buildspec.yml file.
178
175
AppBuildProject :
@@ -215,7 +212,7 @@ Resources:
215
212
# Grant the Javabuilder CodeBuild Role additional permissions for resources in
216
213
# this template. This allows us to avoid granting permission to * resources.
217
214
JavabuilderRolePolicy :
218
- Type : ' AWS::IAM::Policy'
215
+ Type : " AWS::IAM::Policy"
219
216
Properties :
220
217
PolicyName : !Sub "${AWS::StackName}-codebuild-policy"
221
218
PolicyDocument :
@@ -242,17 +239,17 @@ Resources:
242
239
243
240
Pipeline :
244
241
Type : AWS::CodePipeline::Pipeline
245
- Properties :
242
+ Properties :
246
243
Name : !Ref AWS::StackName
247
244
RoleArn : !ImportValue JavabuilderCodeBuildRoleArn
248
245
RestartExecutionOnUpdate : true
249
- ArtifactStore :
250
- Type : S3
246
+ ArtifactStore :
247
+ Type : S3
251
248
Location : !ImportValue JavabuilderCodeBuildArtifactBucket
252
249
EncryptionKey :
253
250
Id : !Ref EncryptionKey
254
251
Type : KMS
255
- Stages :
252
+ Stages :
256
253
- Name : Source
257
254
Actions :
258
255
- Name : Source
@@ -300,10 +297,10 @@ Resources:
300
297
- Name : Deploy_To_Development
301
298
Actions :
302
299
- Name : app-deploy
303
- ActionTypeId :
304
- Category : Deploy
305
- Owner : AWS
306
- Version : 1
300
+ ActionTypeId :
301
+ Category : Deploy
302
+ Owner : AWS
303
+ Version : 1
307
304
Provider : CloudFormation
308
305
InputArtifacts :
309
306
- Name : appBuildResults
@@ -313,10 +310,10 @@ Resources:
313
310
TemplatePath : appBuildResults::packaged-app-template.yml
314
311
TemplateConfiguration : appBuildResults::cicd/3-app/javabuilder/dev.config.json
315
312
ParameterOverrides : !Join
316
- - ' '
317
- - - '{ "SubdomainName" : " '
318
- - !Sub " javabuilder-dev-${GitHubBranch}"
319
- - ' " }'
313
+ - " "
314
+ - - '{ "SubdomainName" : " '
315
+ - !Sub " javabuilder-dev-${GitHubBranch}"
316
+ - ' " }'
320
317
Capabilities : CAPABILITY_AUTO_EXPAND
321
318
RoleArn : !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
322
319
- !Ref AWS::NoValue
@@ -326,23 +323,32 @@ Resources:
326
323
- Name : Deploy_To_Test
327
324
Actions :
328
325
- Name : app-deploy
329
- ActionTypeId :
330
- Category : Deploy
331
- Owner : AWS
332
- Version : 1
326
+ ActionTypeId :
327
+ Category : Deploy
328
+ Owner : AWS
329
+ Version : 1
333
330
Provider : CloudFormation
334
331
InputArtifacts :
335
332
- Name : appBuildResults
336
333
Configuration :
337
- StackName : !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
334
+ StackName :
335
+ !If [
336
+ TargetsMainBranch,
337
+ " javabuilder-test" ,
338
+ !Sub "javabuilder-${GitHubBranch}-test",
339
+ ]
338
340
ActionMode : CREATE_UPDATE
339
341
TemplatePath : appBuildResults::packaged-app-template.yml
340
342
TemplateConfiguration : appBuildResults::cicd/3-app/javabuilder/test.config.json
341
343
ParameterOverrides : !Join
342
- - ' '
343
- - - '{ "SubdomainName" : " '
344
- - !If [ TargetsMainBranch, 'javabuilder-test', !Sub 'javabuilder-${GitHubBranch}-test' ]
345
- - '" }'
344
+ - " "
345
+ - - '{ "SubdomainName" : " '
346
+ - !If [
347
+ TargetsMainBranch,
348
+ " javabuilder-test",
349
+ !Sub "javabuilder-${GitHubBranch}-test",
350
+ ]
351
+ - ' " }'
346
352
Capabilities : CAPABILITY_AUTO_EXPAND
347
353
RoleArn : !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
348
354
- !Ref AWS::NoValue
@@ -364,7 +370,12 @@ Resources:
364
370
EnvironmentVariables : !Sub
365
371
- ' [{"name":"APP_SUBDOMAIN","value":"${SUBDOMAIN}","type":"PLAINTEXT"},{"name":"APP_BASE_DOMAIN","value":"${BASE_DOMAIN}","type":"PLAINTEXT"}]'
366
372
- BASE_DOMAIN : code.org
367
- SUBDOMAIN : !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
373
+ SUBDOMAIN :
374
+ !If [
375
+ TargetsMainBranch,
376
+ " javabuilder-test" ,
377
+ !Sub "javabuilder-${GitHubBranch}-test",
378
+ ]
368
379
OutputArtifacts :
369
380
- Name : integrationTestResultsPOC
370
381
- !Ref AWS::NoValue
@@ -374,23 +385,62 @@ Resources:
374
385
- Name : Deploy_To_Production
375
386
Actions :
376
387
- Name : app-deploy
377
- ActionTypeId :
378
- Category : Deploy
379
- Owner : AWS
380
- Version : 1
388
+ ActionTypeId :
389
+ Category : Deploy
390
+ Owner : AWS
391
+ Version : 1
381
392
Provider : CloudFormation
382
393
InputArtifacts :
383
394
- Name : appBuildResults
384
395
# The value of `Configuration` must be an object with String (or simple type) properties
385
396
Configuration :
386
- StackName : !If [TargetsMainBranch, "javabuilder", !Sub "javabuilder-${GitHubBranch}"]
397
+ StackName :
398
+ !If [
399
+ TargetsMainBranch,
400
+ " javabuilder" ,
401
+ !Sub "javabuilder-${GitHubBranch}",
402
+ ]
387
403
ActionMode : CREATE_UPDATE
388
404
TemplatePath : appBuildResults::packaged-app-template.yml
389
405
TemplateConfiguration : appBuildResults::cicd/3-app/javabuilder/production.config.json
390
406
ParameterOverrides : !Join
391
- - ' '
407
+ - " "
392
408
- - '{ "SubdomainName" : " '
393
- - !If [ TargetsMainBranch, 'javabuilder', !Sub 'javabuilder-${GitHubBranch}' ]
409
+ - !If [
410
+ TargetsMainBranch,
411
+ " javabuilder",
412
+ !Sub "javabuilder-${GitHubBranch}",
413
+ ]
414
+ - ' " }'
415
+ Capabilities : CAPABILITY_AUTO_EXPAND
416
+ RoleArn : !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
417
+ - Name : app-demo-deploy
418
+ ActionTypeId :
419
+ Category : Deploy
420
+ Owner : AWS
421
+ Version : 1
422
+ Provider : CloudFormation
423
+ InputArtifacts :
424
+ - Name : appBuildResults
425
+ # The value of `Configuration` must be an object with String (or simple type) properties
426
+ Configuration :
427
+ StackName :
428
+ !If [
429
+ TargetsMainBranch,
430
+ " javabuilder-demo" ,
431
+ !Sub "javabuilder-demo-${GitHubBranch}",
432
+ ]
433
+ ActionMode : CREATE_UPDATE
434
+ TemplatePath : appBuildResults::packaged-app-template.yml
435
+ TemplateConfiguration : appBuildResults::cicd/3-app/javabuilder/production-demo.config.json
436
+ ParameterOverrides : !Join
437
+ - " "
438
+ - - '{ "SubdomainName" : " '
439
+ - !If [
440
+ TargetsMainBranch,
441
+ " javabuilder-demo",
442
+ !Sub "javabuilder-demo-${GitHubBranch}",
443
+ ]
394
444
- ' " }'
395
445
Capabilities : CAPABILITY_AUTO_EXPAND
396
446
RoleArn : !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
@@ -413,11 +463,16 @@ Resources:
413
463
EnvironmentVariables : !Sub
414
464
- ' [{"name":"APP_SUBDOMAIN","value":"${SUBDOMAIN}","type":"PLAINTEXT"},{"name":"APP_BASE_DOMAIN","value":"${BASE_DOMAIN}","type":"PLAINTEXT"}]'
415
465
- BASE_DOMAIN : code.org
416
- SUBDOMAIN : !If [TargetsMainBranch, "javabuilder", !Sub "javabuilder-${GitHubBranch}"]
466
+ SUBDOMAIN :
467
+ !If [
468
+ TargetsMainBranch,
469
+ " javabuilder" ,
470
+ !Sub "javabuilder-${GitHubBranch}",
471
+ ]
417
472
OutputArtifacts :
418
473
- Name : smokeTestResults
419
474
- !Ref AWS::NoValue
420
-
475
+
421
476
# Send pipeline events to an SNS topic.
422
477
# Note:
423
478
# Integration with Slack via AWS ChatBot is configured manually via AWS
@@ -429,7 +484,7 @@ Resources:
429
484
Name : !Sub ${AWS::StackName}-pipeline
430
485
DetailType : FULL
431
486
Resource : !Sub "arn:${AWS::Partition}:codepipeline:${AWS::Region}:${AWS::AccountId}:${Pipeline}"
432
- EventTypeIds :
487
+ EventTypeIds :
433
488
# Pipeline events
434
489
- codepipeline-pipeline-pipeline-execution-failed
435
490
- codepipeline-pipeline-pipeline-execution-succeeded
@@ -452,8 +507,8 @@ Resources:
452
507
- codepipeline-pipeline-manual-approval-needed
453
508
- codepipeline-pipeline-manual-approval-failed
454
509
- codepipeline-pipeline-manual-approval-succeeded
455
- Targets :
456
- - TargetType : SNS
510
+ Targets :
511
+ - TargetType : SNS
457
512
TargetAddress : !Ref PipelineNotificationTopic
458
513
459
514
PipelineNotificationTopic :
@@ -462,16 +517,16 @@ Resources:
462
517
# This policy is necessary for CodePipeline to be allowed to publish to the Topic.
463
518
PipelineNotificationTopicPolicy :
464
519
Type : AWS::SNS::TopicPolicy
465
- Properties :
520
+ Properties :
466
521
Topics :
467
522
- !Ref PipelineNotificationTopic
468
523
PolicyDocument :
469
- Version : ' 2012-10-17'
524
+ Version : " 2012-10-17"
470
525
Statement :
471
- - Sid : AWSCodeStarNotifications_publish
472
- Effect : Allow
473
- Principal :
474
- Service :
475
- - codestar-notifications.amazonaws.com
476
- Action : SNS:Publish
477
- Resource : !Ref PipelineNotificationTopic
526
+ - Sid : AWSCodeStarNotifications_publish
527
+ Effect : Allow
528
+ Principal :
529
+ Service :
530
+ - codestar-notifications.amazonaws.com
531
+ Action : SNS:Publish
532
+ Resource : !Ref PipelineNotificationTopic
0 commit comments