in cdk/lib/cdk-pipeline-stack.ts [45:107]
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const githubOrg = process.env.GITHUB_ORG || "kevasync";
const githubRepo = process.env.GITHUB_REPO || "awsmug-serverless-graphql-api";
const githubBranch = process.env.GITHUB_BRANCH || "master";
const devAccountId = process.env.DEV_ACCOUNT_ID || "";
const stgAccountId = process.env.STG_ACCOUNT_ID || "";
const prdAccountId = process.env.PRD_ACCOUNT_ID || "";
const primaryRegion = process.env.PRIMARY_REGION || "us-west-2";
const secondaryRegion = process.env.SECONDARY_REGION || "us-east-1";
const pipeline = new CodePipeline(this, "Pipeline", {
crossAccountKeys: true,
pipelineName: "AWSMugPipeline",
synth: new ShellStep("deploy", {
input: CodePipelineSource.gitHub(`${githubOrg}/${githubRepo}`, githubBranch),
commands: [
"npm ci",
"npm run build",
"npx cdk synth"
]
}),
});
const devQaWave = pipeline.addWave("DEV-and-QA-Deployments");
const dev = new AppStage(this, "dev", {
env: { account: devAccountId, region: primaryRegion }
});
const qa = new AppStage(this, "qa", {
env: { account: devAccountId, region: secondaryRegion }
});
devQaWave.addStage(dev);
devQaWave.addStage(qa);
const primaryRdsRegionWave = pipeline.addWave("Primary-DB-Region-Deployments", {
pre: [new ManualApprovalStep("ProdManualApproval")]
});
const stgPrimary = new AppStage(this, "stg-primary", {
env: { account: stgAccountId, region: primaryRegion },
secretReplicationRegions: [secondaryRegion]
});
const prdPrimary = new AppStage(this, "prd-primary", {
env: { account: prdAccountId, region: primaryRegion },
secretReplicationRegions: [secondaryRegion]
});
primaryRdsRegionWave.addStage(stgPrimary);
primaryRdsRegionWave.addStage(prdPrimary);
const secondaryRdsRegionWave = pipeline.addWave("Secondary-DB-Region-Deployments");
const stgBackup = new AppStage(this, "stg-backup", {
env: { account: stgAccountId, region: secondaryRegion },
primaryRdsInstance: stgPrimary.rdsStack.postgresRDSInstance
});
const prdBackup = new AppStage(this, "prd-backup", {
env: { account: prdAccountId, region: secondaryRegion },
primaryRdsInstance: prdPrimary.rdsStack.postgresRDSInstance
});
secondaryRdsRegionWave.addStage(stgBackup);
secondaryRdsRegionWave.addStage(prdBackup);
}