Skip to content

Commit

Permalink
Correct run order of UI deployment steps
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswilty committed Sep 13, 2024
1 parent e2ea6f5 commit 6aca3b4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cloud/lib/constructs/DeployS3Step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
);

Expand Down
52 changes: 30 additions & 22 deletions cloud/lib/pipeline-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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/*`],
}),
],
}),
])
);
}
}

0 comments on commit 6aca3b4

Please sign in to comment.