From 567a58feb4edb7f3a1099cc86cb4e020cd6c09e0 Mon Sep 17 00:00:00 2001 From: Gowri Date: Tue, 26 Sep 2023 13:26:05 +0930 Subject: [PATCH] DO-1531: merge props additional behaviours --- packages/static-hosting/lib/static-hosting.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index e5006d46..c547911d 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -333,6 +333,13 @@ export class StaticHosting extends Construct { } } + const mergedAdditionalBehaviors = {}; + + // If additional behaviours are provided via props, then merge, overriding generated behaviours if required. + if (props.additionalBehaviors) { + Object.assign(additionalBehaviors, props.additionalBehaviors); + } + const distributionProps: DistributionProps = { domainNames: domainNames, webAclId: props.webAclArn, @@ -351,7 +358,7 @@ export class StaticHosting extends Construct { props.certificateArn ), defaultBehavior: defaultBehavior, - additionalBehaviors: additionalBehaviors, + additionalBehaviors: mergedAdditionalBehaviors, errorResponses: props.enableErrorConfig ? errorResponses : [], };