From e0f268bb631edb044c52e1274e05f33097526411 Mon Sep 17 00:00:00 2001 From: Markus Bergkvist Date: Tue, 19 Dec 2023 08:51:16 +0100 Subject: [PATCH] feat: option configure partition with env var Adds support for deployment to aws-cn partition by checking an optional environemt variable, CDK_AWS_PARTITION. The partition is currently not available to the pipeline in the jobForDeploy, adding the environment variable is a non-breaking change to get the pipeline to deploy to aws-cn. --- src/pipeline.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pipeline.ts b/src/pipeline.ts index 7ca182cd..8db620e7 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -602,10 +602,11 @@ export class GitHubWorkflow extends PipelineBase { } const resolve = (s: string): string => { + const partition = process.env.CDK_AWS_PARTITION ?? 'aws'; return EnvironmentPlaceholders.replace(s, { accountId: account, region: region, - partition: 'aws', + partition: partition, }); }; @@ -614,7 +615,10 @@ export class GitHubWorkflow extends PipelineBase { if (this.assetHashMap[hash] === undefined) { throw new Error(`Template asset hash ${hash} not found.`); } - return template.replace(hash, `\${{ needs.${this.assetHashMap[hash]}.outputs.${ASSET_HASH_NAME} }}`); + const updated_template = template.replace(hash, `\${{ needs.${this.assetHashMap[hash]}.outputs.${ASSET_HASH_NAME} }}`); + return process.env.CDK_AWS_PARTITION == 'aws-cn' + ? updated_template.replace('.amazonaws.com', '.amazonaws.com.cn') + : updated_template; }; const params: Record = {