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

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