@@ -2,7 +2,13 @@ import { BuildEnvironmentVariableType, BuildSpec } from 'aws-cdk-lib/aws-codebui
22import { PolicyStatement } from 'aws-cdk-lib/aws-iam' ;
33import { IBucket } from 'aws-cdk-lib/aws-s3' ;
44import { Stack , StackProps } from 'aws-cdk-lib/core' ;
5- import { CodeBuildStep , CodePipeline , CodePipelineSource , ShellStep } from 'aws-cdk-lib/pipelines' ;
5+ import {
6+ CodeBuildStep ,
7+ CodePipeline ,
8+ CodePipelineSource ,
9+ ShellStep ,
10+ Step ,
11+ } from 'aws-cdk-lib/pipelines' ;
612import { Construct } from 'constructs' ;
713
814import { AppStage } from './app-stage' ;
@@ -147,27 +153,29 @@ export class PipelineStack extends Stack {
147153 } ) ;
148154
149155 deployment . addPost (
150- uiBuildStep ,
151- new DeployS3Step ( 'UI-Deploy' , {
152- actionName : 'UI-Deploy' ,
153- bucketName : hostBucketName ,
154- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
155- input : uiBuildStep . primaryOutput ! ,
156- } ) ,
157- new CodeBuildStep ( 'CF-Invalidation' , {
158- commands : [
159- 'aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*"' ,
160- ] ,
161- envFromCfnOutputs : {
162- CF_DISTRIBUTION_ID : appStage . cloudFrontDistributionId ,
163- } ,
164- rolePolicyStatements : [
165- new PolicyStatement ( {
166- actions : [ 'cloudfront:CreateInvalidation' ] ,
167- resources : [ `arn:aws:cloudfront::${ env . account } :distribution/*` ] ,
168- } ) ,
169- ] ,
170- } )
156+ ...Step . sequence ( [
157+ uiBuildStep ,
158+ new DeployS3Step ( 'UI-Deploy' , {
159+ actionName : 'UI-Deploy' ,
160+ bucketName : hostBucketName ,
161+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
162+ input : uiBuildStep . primaryOutput ! ,
163+ } ) ,
164+ new CodeBuildStep ( 'CF-Invalidation' , {
165+ commands : [
166+ 'aws cloudfront create-invalidation --distribution-id $CF_DISTRIBUTION_ID --paths "/*"' ,
167+ ] ,
168+ envFromCfnOutputs : {
169+ CF_DISTRIBUTION_ID : appStage . cloudFrontDistributionId ,
170+ } ,
171+ rolePolicyStatements : [
172+ new PolicyStatement ( {
173+ actions : [ 'cloudfront:CreateInvalidation' ] ,
174+ resources : [ `arn:aws:cloudfront::${ env . account } :distribution/*` ] ,
175+ } ) ,
176+ ] ,
177+ } ) ,
178+ ] )
171179 ) ;
172180 }
173181}
0 commit comments