diff --git a/cdk.json b/cdk.json index 003f2d2ca..af5c90bc8 100644 --- a/cdk.json +++ b/cdk.json @@ -16,5 +16,6 @@ ] }, "context": { + "@aws-cdk/core:suppressTemplateIndentation": true } } diff --git a/lib/pipeline/statefulPipelineStack.ts b/lib/pipeline/statefulPipelineStack.ts index c849e6ca7..0464c0dac 100644 --- a/lib/pipeline/statefulPipelineStack.ts +++ b/lib/pipeline/statefulPipelineStack.ts @@ -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`); @@ -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 */ @@ -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(); diff --git a/lib/pipeline/statelessPipelineStack.ts b/lib/pipeline/statelessPipelineStack.ts index 6d28c3bd7..a2b6eea1e 100644 --- a/lib/pipeline/statelessPipelineStack.ts +++ b/lib/pipeline/statelessPipelineStack.ts @@ -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`); @@ -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 ); /** @@ -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