diff --git a/.changeset/tender-zebras-perform.md b/.changeset/tender-zebras-perform.md new file mode 100644 index 00000000..bf3a5189 --- /dev/null +++ b/.changeset/tender-zebras-perform.md @@ -0,0 +1,5 @@ +--- +"@codedazur/cdk-site-distribution": patch +--- + +The CloudFront functions are created in series to reduce the chances of hitting the service rate limit. diff --git a/packages/cdk-site-distribution/src/constructs/SiteDistribution.ts b/packages/cdk-site-distribution/src/constructs/SiteDistribution.ts index 36a0f887..3158c87c 100644 --- a/packages/cdk-site-distribution/src/constructs/SiteDistribution.ts +++ b/packages/cdk-site-distribution/src/constructs/SiteDistribution.ts @@ -132,9 +132,21 @@ export class SiteDistribution extends Construct { } protected createFunctions() { + const viewerRequest = this.createViewerRequestFunction(); + const viewerResponse = this.createViewerResponseFunction(); + + /** + * Although the response function doesn't actually depend on the request + * function, we define a dependency to avoid a service rate limit that may + * occur when both are created simultaneously. + */ + if (viewerRequest && viewerResponse) { + viewerResponse.node.addDependency(viewerRequest); + } + return { - viewerRequest: this.createViewerRequestFunction(), - viewerResponse: this.createViewerResponseFunction(), + viewerRequest, + viewerResponse, }; } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..f2284290 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@codedazur/tsconfig/base.json" +}