diff --git a/cloud/lib/constructs/DeployS3Step.ts b/cloud/lib/constructs/DeployS3Step.ts index 6ef0fb86..d7e655d4 100644 --- a/cloud/lib/constructs/DeployS3Step.ts +++ b/cloud/lib/constructs/DeployS3Step.ts @@ -35,7 +35,7 @@ export class DeployS3Step extends Step implements ICodePipelineActionFactory { actionName: this.actionName, bucket: Bucket.fromBucketName(options.scope, `${this.actionName}-Bucket`, this.bucketName), input: options.artifacts.toCodePipeline(this.input), - runOrder: options.runOrder + 1, + runOrder: options.runOrder, }) ); diff --git a/cloud/lib/pipeline-stack.ts b/cloud/lib/pipeline-stack.ts index a7b8631a..2c2372b0 100644 --- a/cloud/lib/pipeline-stack.ts +++ b/cloud/lib/pipeline-stack.ts @@ -2,7 +2,13 @@ import { BuildEnvironmentVariableType, BuildSpec } from 'aws-cdk-lib/aws-codebui import { PolicyStatement } from 'aws-cdk-lib/aws-iam'; import { IBucket } from 'aws-cdk-lib/aws-s3'; import { Stack, StackProps } from 'aws-cdk-lib/core'; -import { CodeBuildStep, CodePipeline, CodePipelineSource, ShellStep } from 'aws-cdk-lib/pipelines'; +import { + CodeBuildStep, + CodePipeline, + CodePipelineSource, + ShellStep, + Step, +} from 'aws-cdk-lib/pipelines'; import { Construct } from 'constructs'; import { AppStage } from './app-stage'; @@ -147,27 +153,29 @@ export class PipelineStack extends Stack { }); deployment.addPost( - uiBuildStep, - new DeployS3Step('UI-Deploy', { - actionName: 'UI-Deploy', - bucketName: hostBucketName, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - input: uiBuildStep.primaryOutput!, - }), - new CodeBuildStep('CF-Invalidation', { - commands: [ - 'aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*"', - ], - envFromCfnOutputs: { - CF_DISTRIBUTION_ID: appStage.cloudFrontDistributionId, - }, - rolePolicyStatements: [ - new PolicyStatement({ - actions: ['cloudfront:CreateInvalidation'], - resources: [`arn:aws:cloudfront::${env.account}:distribution/*`], - }), - ], - }) + ...Step.sequence([ + uiBuildStep, + new DeployS3Step('UI-Deploy', { + actionName: 'UI-Deploy', + bucketName: hostBucketName, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + input: uiBuildStep.primaryOutput!, + }), + new CodeBuildStep('CF-Invalidation', { + commands: [ + 'aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*"', + ], + envFromCfnOutputs: { + CF_DISTRIBUTION_ID: appStage.cloudFrontDistributionId, + }, + rolePolicyStatements: [ + new PolicyStatement({ + actions: ['cloudfront:CreateInvalidation'], + resources: [`arn:aws:cloudfront::${env.account}:distribution/*`], + }), + ], + }), + ]) ); } }