Skip to content

Commit

Permalink
feat: option configure partition with env var
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mbergkvist committed Feb 28, 2024
1 parent bedd765 commit e099211
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
};

Expand All @@ -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<string, any> = {
Expand Down

0 comments on commit e099211

Please sign in to comment.