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