Skip to content

Commit 548c954

Browse files
create adhoc configuration
1 parent 4d77929 commit 548c954

File tree

3 files changed

+104
-42
lines changed

3 files changed

+104
-42
lines changed

cicd/2-cicd/cicd.template.yml

Lines changed: 90 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,19 @@ Parameters:
2626
Type: String
2727
Description: The Resource Id component of the CodeStar connection ARN for the code-dot-org GitHub repository
2828
Default: 7df08bcf-9883-42e8-8f5e-d083419d4fe9
29+
Mode:
30+
Type: String
31+
Description: Whether this should create a pipeline for an 'adhoc' deployment or 'standard' pipeline.
32+
Default: standard
33+
AllowedValues: [adhoc, standard]
2934

3035
Conditions:
31-
TargetsMainBranch: !Equals
32-
- !Ref GitHubBranch
33-
- main
36+
TargetsMainBranch: !Equals [ !Ref GitHubBranch, main ]
37+
DeployToAdhoc: !Equals [!Ref Mode, adhoc ]
38+
# DeployToTest and DeployToProd are the same right now
39+
DeployToTest: !Equals [!Ref Mode, standard ]
40+
DeployToProd: !Equals [ !Ref Mode, standard ]
41+
3442

3543
Resources:
3644

@@ -290,46 +298,82 @@ Resources:
290298
OutputArtifacts:
291299
- Name: appBuildResults
292300

293-
- Name: Deploy_To_Test
294-
Actions:
295-
- Name: app-deploy
296-
ActionTypeId:
297-
Category: Deploy
298-
Owner: AWS
299-
Version: 1
300-
Provider: CloudFormation
301-
InputArtifacts:
302-
- Name: appBuildResults
303-
Configuration:
304-
StackName: !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
305-
ActionMode: CREATE_UPDATE
306-
TemplatePath: appBuildResults::packaged-app-template.yml
307-
TemplateConfiguration: appBuildResults::cicd/3-app/javabuilder/test.config.json
308-
ParameterName: { "SubDomainName": !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"] }
309-
Capabilities: CAPABILITY_AUTO_EXPAND
310-
RoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
301+
- !If
302+
- DeployToAdhoc
303+
- Name: Deploy_To_Adhoc
304+
Actions:
305+
- Name: app-deploy
306+
ActionTypeId:
307+
Category: Deploy
308+
Owner: AWS
309+
Version: 1
310+
Provider: CloudFormation
311+
InputArtifacts:
312+
- Name: appBuildResults
313+
Configuration:
314+
StackName: !Sub "javabuilder-adhoc-${GitHubBranch}"
315+
ActionMode: CREATE_UPDATE
316+
TemplatePath: appBuildResults::packaged-app-template.yml
317+
TemplateConfiguration: appBuildResults::cicd/3-app/javabuilder/adhoc.config.json
318+
ParameterOverrides: !Join
319+
- ''
320+
- - '{ "SubDomainName": "'
321+
- !Sub "javabuilder-adhoc-${GitHubBranch}"
322+
- '" }'
323+
Capabilities: CAPABILITY_AUTO_EXPAND
324+
RoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
325+
- !Ref AWS::NoValue
311326

312-
- Name: Integration_Test
313-
Actions:
314-
- Name: integration-test
315-
ActionTypeId:
316-
Category: Build
317-
Owner: AWS
318-
Provider: CodeBuild
319-
Version: 1
320-
InputArtifacts:
321-
- Name: sourceCode
322-
Configuration:
323-
ProjectName: !Ref IntegrationTestBuildProject
324-
EnvironmentVariables: !Sub
325-
- '[{"name":"APP_SUBDOMAIN","value":"${SUBDOMAIN}","type":"PLAINTEXT"},{"name":"APP_BASE_DOMAIN","value":"${BASE_DOMAIN}","type":"PLAINTEXT"}]'
326-
- BASE_DOMAIN: code.org
327-
SUBDOMAIN: !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
328-
OutputArtifacts:
329-
- Name: integrationTestResultsPOC
327+
- !If
328+
- DeployToTest
329+
- Name: Deploy_To_Test
330+
Actions:
331+
- Name: app-deploy
332+
ActionTypeId:
333+
Category: Deploy
334+
Owner: AWS
335+
Version: 1
336+
Provider: CloudFormation
337+
InputArtifacts:
338+
- Name: appBuildResults
339+
Configuration:
340+
StackName: !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
341+
ActionMode: CREATE_UPDATE
342+
TemplatePath: appBuildResults::packaged-app-template.yml
343+
TemplateConfiguration: appBuildResults::cicd/3-app/javabuilder/test.config.json
344+
ParameterOverrides: !Join
345+
- ''
346+
- - '{ "SubDomainName": "'
347+
- !If [ TargetsMainBranch, 'javabuilder-test', !Sub 'javabuilder-${GitHubBranch}-test' ]
348+
- '" }'
349+
Capabilities: CAPABILITY_AUTO_EXPAND
350+
RoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
351+
- !Ref AWS::NoValue
352+
353+
- !If
354+
- DeployToTest
355+
- Name: Integration_Test
356+
Actions:
357+
- Name: integration-test
358+
ActionTypeId:
359+
Category: Build
360+
Owner: AWS
361+
Provider: CodeBuild
362+
Version: 1
363+
InputArtifacts:
364+
- Name: sourceCode
365+
Configuration:
366+
ProjectName: !Ref IntegrationTestBuildProject
367+
EnvironmentVariables: !Sub
368+
- '[{"name":"APP_SUBDOMAIN","value":"${SUBDOMAIN}","type":"PLAINTEXT"},{"name":"APP_BASE_DOMAIN","value":"${BASE_DOMAIN}","type":"PLAINTEXT"}]'
369+
- BASE_DOMAIN: code.org
370+
SUBDOMAIN: !If [TargetsMainBranch, "javabuilder-test", !Sub "javabuilder-${GitHubBranch}-test"]
371+
OutputArtifacts:
372+
- Name: integrationTestResultsPOC
373+
- !Ref AWS::NoValue
330374

331375
- !If
332-
- TargetsMainBranch
376+
- DeployToProd
333377
- Name: Deploy_To_Production
334378
Actions:
335379
- Name: app-deploy
@@ -340,12 +384,17 @@ Resources:
340384
Provider: CloudFormation
341385
InputArtifacts:
342386
- Name: appBuildResults
387+
# The value of `Configuration` must be an object with String (or simple type) properties
343388
Configuration:
344389
StackName: !If [TargetsMainBranch, "javabuilder", !Sub "javabuilder-${GitHubBranch}"]
345390
ActionMode: CREATE_UPDATE
346391
TemplatePath: appBuildResults::packaged-app-template.yml
347392
TemplateConfiguration: appBuildResults::cicd/3-app/javabuilder/production.config.json
348-
ParameterName: { "SubDomainName": !If [TargetsMainBranch, "javabuilder", !Sub "javabuilder-${GitHubBranch}"] }
393+
ParameterOverrides: !Join
394+
- ''
395+
- - '{ "SubDomainName": "'
396+
- !If [ TargetsMainBranch, 'javabuilder', !Sub 'javabuilder-${GitHubBranch}' ]
397+
- '" }'
349398
Capabilities: CAPABILITY_AUTO_EXPAND
350399
RoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/admin/CloudFormationService
351400
- !Ref AWS::NoValue

cicd/2-cicd/deploy-cicd.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if [[ $(aws sts get-caller-identity --query Arn --output text) =~ "assumed-role/
1010
set -- "$@" --role-arn "arn:aws:iam::$(aws sts get-caller-identity --query Account --output text):role/admin/CloudFormationService"
1111
fi
1212

13+
1314
# Default to main branch, but support pipelines using other branches
1415
TARGET_BRANCH=${TARGET_BRANCH-'main'}
1516
if [ "$TARGET_BRANCH" == "main" ]
@@ -19,6 +20,7 @@ else
1920
STACK_NAME=${STACK_NAME-"javabuilder-$TARGET_BRANCH-cicd"}
2021
fi
2122

23+
MODE=${MODE-'standard'}
2224
GITHUB_BADGE_ENABLED=${GITHUB_BADGE_ENABLED-'true'}
2325

2426
TEMPLATE_FILE=cicd/2-cicd/cicd.template.yml
@@ -37,7 +39,7 @@ then
3739
aws cloudformation deploy \
3840
--stack-name $STACK_NAME \
3941
--template-file $TEMPLATE_FILE \
40-
--parameter-overrides GitHubBranch=$TARGET_BRANCH GitHubBadgeEnabled=$GITHUB_BADGE_ENABLED \
42+
--parameter-overrides GitHubBranch=$TARGET_BRANCH GitHubBadgeEnabled=$GITHUB_BADGE_ENABLED Mode=$MODE \
4143
--capabilities CAPABILITY_IAM \
4244
"$@"
4345

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Parameters": {
3+
"BaseDomainName": "code.org",
4+
"BaseDomainNameHostedZonedID": "Z2LCOI49SCXUGU",
5+
"ProvisionedConcurrentExecutions": "1",
6+
"ReservedConcurrentExecutions": "3",
7+
"LimitPerHour": "15",
8+
"LimitPerDay": "40",
9+
"SilenceAlerts": "false"
10+
}
11+
}

0 commit comments

Comments
 (0)