Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(pipeline): Disable Dev Automatic Deployment #714

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
]
},
"context": {
"@aws-cdk/core:suppressTemplateIndentation": true
Copy link
Member Author

@williamputraintan williamputraintan Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reduces the pipeline template by ~200KB. Currently, without we are sitting at ~800KB, so nearly there (limit is 1MB)

aws/aws-cdk#22529

}
}
101 changes: 61 additions & 40 deletions lib/pipeline/statelessPipelineStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,62 +178,83 @@ export class StatelessPipelineStack extends cdk.Stack {
});

/**
* Deployment to Beta (Dev) account
* Creating deployment stages for each environment (not integrated with the pipeline yet)
*/

// Beta (Dev)
const betaConfig = getEnvironmentConfig(AppStage.BETA);
if (!betaConfig) throw new Error(`No 'Beta' account configuration`);
pipeline.addStage(
new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusBeta',
betaConfig.stackProps.statelessConfig,
{
account: betaConfig.accountId,
region: betaConfig.region,
}
),
{ pre: [stripAssetsFromAssembly] } // I think this should only be done once across stages
const betaDeploymentStage = new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusBeta',
betaConfig.stackProps.statelessConfig,
{
account: betaConfig.accountId,
region: betaConfig.region,
}
);

/**
* Deployment to Gamma (Staging) account
*/
// Gamma (Staging)
const gammaConfig = getEnvironmentConfig(AppStage.GAMMA);
if (!gammaConfig) throw new Error(`No 'Gamma' account configuration`);
pipeline.addStage(
new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusGamma',
gammaConfig.stackProps.statelessConfig,
{
account: gammaConfig.accountId,
region: gammaConfig.region,
}
),
{ pre: [new pipelines.ManualApprovalStep('PromoteToGamma')] }
const gammaDeploymentStage = new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusGamma',
gammaConfig.stackProps.statelessConfig,
{
account: gammaConfig.accountId,
region: gammaConfig.region,
}
);

/**
* Deployment to Prod account
*/
// Prod
const prodConfig = getEnvironmentConfig(AppStage.PROD);
if (!prodConfig) throw new Error(`No 'Prod' account configuration`);
const prodDeploymentStage = new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusProd',
prodConfig.stackProps.statelessConfig,
{
account: prodConfig.accountId,
region: prodConfig.region,
}
);

/**
* Assembly stages into the pipelines
*/

// Direct auto deployment to the gamma account
pipeline.addStage(
new OrcaBusStatelessDeploymentStage(
this,
'OrcaBusProd',
prodConfig.stackProps.statelessConfig,
{
account: prodConfig.accountId,
region: prodConfig.region,
}
),
{ pre: [new pipelines.ManualApprovalStep('PromoteToProd')] }
gammaDeploymentStage,
// See the comment on creating stripAssetsFromAssembly above for why the pre step here
{
pre: [stripAssetsFromAssembly],
}
);

// Creating a wave so dev and prod deployed in parallel
// We disable deploying to dev automatically to avoid stack deployed manually for testing to be
// overwritten by the pipeline.
// The dev and prod put at the end of the pipeline so that if dev could still be easily deployed
// by a click of a button. The prod deployment should not be blocked by the dev deployment, so
// we put this two in parallel.
const betaProdWave = pipeline.addWave(
'BetaProdDeployment',
// See the comment on creating stripAssetsFromAssembly above for why the pre step here
{
pre: [stripAssetsFromAssembly],
}
);
betaProdWave.addStage(betaDeploymentStage, {
pre: [new pipelines.ManualApprovalStep('PromoteToBeta')],
});
betaProdWave.addStage(prodDeploymentStage, {
pre: [new pipelines.ManualApprovalStep('PromoteToProd')],
});

// need to build pipeline so we could add notification at the pipeline construct
pipeline.buildPipeline();

pipeline.pipeline.artifactBucket.grantReadWrite(stripAssetsFromAssembly.project);

// notification for success/failure
Expand Down