Skip to content

Commit

Permalink
fix: plat-5908 add dependency to cdn-site-hosting construct (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
malcyL authored Sep 7, 2022
1 parent 2c59b4f commit 64c9d97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/cdn-site-hosting/cdn-site-hosting-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export class CdnSiteHostingConstruct extends cdk.Construct {
}
);

// Give the first deployment a dependency on the s3 bucket.
// Without this, we may start copying files into the s3 bucket before it has been created.
deployments[0].node.addDependency(this.s3Bucket);
// Now make the rest of the deployments dependent on the previous one.
deployments.forEach((deployment, deploymentIndex) => {
if (deploymentIndex > 0) {
deployment.node.addDependency(deployments[deploymentIndex - 1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ describe("CdnSiteHostingConstruct", () => {
expect(deployments.length).toBe(2);
const [[firstDeploymentId, firstDeployment], [, secondDeployment]] =
deployments;
expect(firstDeployment.DependsOn).toBeUndefined();
expect(firstDeployment.DependsOn).toBeDefined();
expect(firstDeployment.DependsOn).toContain(
"MyTestConstructSiteBucketEE4FFC1B"
);
expect(secondDeployment.DependsOn).toBeDefined();
expect(secondDeployment.DependsOn).toContain(firstDeploymentId);
});
Expand Down

0 comments on commit 64c9d97

Please sign in to comment.