Skip to content

Commit

Permalink
Feat(pipeline): Disable Dev Automatic Deployment (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamputraintan authored Nov 24, 2024
1 parent 41b7d1c commit 53b32d7
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 44 deletions.
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
}
}
47 changes: 24 additions & 23 deletions lib/pipeline/statefulPipelineStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,7 @@ export class StatefulPipelineStack extends cdk.Stack {
});

/**
* Deployment to Beta (Dev) account
*/
const betaConfig = getEnvironmentConfig(AppStage.BETA);
if (!betaConfig) throw new Error(`No 'Beta' account configuration`);
pipeline.addStage(
new OrcaBusStatefulDeploymentStage(
this,
'OrcaBusBeta',
betaConfig.stackProps.statefulConfig,
{
account: betaConfig.accountId,
region: betaConfig.region,
}
)
);

/**
* Deployment to Gamma (Staging) account
* Deployment to Gamma (Staging) account directly without approval
*/
const gammaConfig = getEnvironmentConfig(AppStage.GAMMA);
if (!gammaConfig) throw new Error(`No 'Gamma' account configuration`);
Expand All @@ -123,13 +106,9 @@ export class StatefulPipelineStack extends cdk.Stack {
account: gammaConfig.accountId,
region: gammaConfig.region,
}
),
{ pre: [new pipelines.ManualApprovalStep('PromoteToGamma')] }
)
);

// Some stack have dependencies to the 'shared stack' so we need to deploy it first beforehand
// should only be a one-off initial deployment

/**
* Deployment to Prod account
*/
Expand All @@ -148,6 +127,28 @@ export class StatefulPipelineStack extends cdk.Stack {
{ pre: [new pipelines.ManualApprovalStep('PromoteToProd')] }
);

/**
* Deployment to Beta (Dev)
* This shouldn't be deployed automatically. Some dev work may be deployed manually from local
* for testing but then could got overwritten by the pipeline if someone has pushed to the main
* branch. This is put at the end of the pipeline just to have a way of deployment with
* a click of a button.
*/
const betaConfig = getEnvironmentConfig(AppStage.BETA);
if (!betaConfig) throw new Error(`No 'Beta' account configuration`);
pipeline.addStage(
new OrcaBusStatefulDeploymentStage(
this,
'OrcaBusBeta',
betaConfig.stackProps.statefulConfig,
{
account: betaConfig.accountId,
region: betaConfig.region,
}
),
{ pre: [new pipelines.ManualApprovalStep('PromoteToDev')] }
);

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

Expand Down
45 changes: 24 additions & 21 deletions lib/pipeline/statelessPipelineStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,25 +178,7 @@ export class StatelessPipelineStack extends cdk.Stack {
});

/**
* Deployment to Beta (Dev) account
*/
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
);

/**
* Deployment to Gamma (Staging) account
* Deployment to Gamma (Staging) account directly without approval
*/
const gammaConfig = getEnvironmentConfig(AppStage.GAMMA);
if (!gammaConfig) throw new Error(`No 'Gamma' account configuration`);
Expand All @@ -210,7 +192,7 @@ export class StatelessPipelineStack extends cdk.Stack {
region: gammaConfig.region,
}
),
{ pre: [new pipelines.ManualApprovalStep('PromoteToGamma')] }
{ pre: [stripAssetsFromAssembly] } // See above for the reason
);

/**
Expand All @@ -231,9 +213,30 @@ export class StatelessPipelineStack extends cdk.Stack {
{ pre: [new pipelines.ManualApprovalStep('PromoteToProd')] }
);

/**
* Deployment to Beta (Dev)
* This shouldn't be deployed automatically. Some dev work may be deployed manually from local
* for testing but then could got overwritten by the pipeline if someone has pushed to the main
* branch. This is put at the end of the pipeline just to have a way of deployment with
* a click of a button.
*/
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: [new pipelines.ManualApprovalStep('PromoteToDev')] }
);

// 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

0 comments on commit 53b32d7

Please sign in to comment.