From 68a4ee550d7941d2a4e30885f55162df131a6311 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Fri, 16 Dec 2022 09:53:55 +1030 Subject: [PATCH 01/13] DO_1419: Initial configs --- package-lock.json | 2 +- packages/static-hosting/lib/static-hosting.ts | 25 +++++++++++++++++++ packages/static-hosting/package.json | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index b0132bd1..1d3acb3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7870,7 +7870,7 @@ }, "packages/static-hosting": { "name": "@aligent/cdk-static-hosting", - "version": "0.1.5", + "version": "0.1.13", "license": "GPL-3.0-only", "dependencies": { "@aws-cdk/aws-cloudfront": "1.180.0", diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index e44e190a..8c1f23b3 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -68,6 +68,11 @@ export interface StaticHostingProps { * Optional WAF ARN */ webAclArn?: string; + + /** + * Response Header policies + */ + responseHeaders?: ResponseHeaderMappings[]; } interface remapPath { @@ -75,6 +80,11 @@ interface remapPath { to: string } +export interface ResponseHeaderMappings { + header: ResponseHeadersPolicy, + behaviors: string[] +} + export class StaticHosting extends Construct { private staticFiles = ["js", "css", "json", "svg", "jpg", "jpeg", "png"]; @@ -302,6 +312,21 @@ export class StaticHosting extends Construct { exportName: `${exportPrefix}CSPHeader` }); } + + /** + * Response Header policies + */ + if (props.responseHeaders) { + const cfnDistribution = distribution.node.defaultChild as CfnDistribution; + props.responseHeaders.forEach( (policyMapping) => { + policyMapping.behaviors.forEach(behavior => { + cfnDistribution.addOverride( + `Properties.DistributionConfig.CacheBehaviors[${props.behaviors?.findIndex(behavior => behavior.pathPattern == behavior)}].ResponseHeadersPolicyId`, + policyMapping.header.responseHeadersPolicyId + ); + }); + }); + } if (publisherGroup) { const cloudFrontInvalidationPolicyStatement = new PolicyStatement({ diff --git a/packages/static-hosting/package.json b/packages/static-hosting/package.json index 3144ead8..5992ce9e 100644 --- a/packages/static-hosting/package.json +++ b/packages/static-hosting/package.json @@ -1,6 +1,6 @@ { "name": "@aligent/cdk-static-hosting", - "version": "0.1.5", + "version": "0.1.13", "main": "index.js", "license": "GPL-3.0-only", "homepage": "https://github.com/aligent/aws-cdk-static-hosting-stack#readme", From e22a2027bc0e509a32fbaa9549f50b2224db713f Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Fri, 16 Dec 2022 11:06:29 +1030 Subject: [PATCH 02/13] DO_1419: fixed a logical issue --- packages/static-hosting/lib/static-hosting.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 8c1f23b3..248081f9 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -82,7 +82,7 @@ interface remapPath { export interface ResponseHeaderMappings { header: ResponseHeadersPolicy, - behaviors: string[] + pathPatterns: string[] } export class StaticHosting extends Construct { @@ -312,19 +312,17 @@ export class StaticHosting extends Construct { exportName: `${exportPrefix}CSPHeader` }); } - + /** * Response Header policies */ if (props.responseHeaders) { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; props.responseHeaders.forEach( (policyMapping) => { - policyMapping.behaviors.forEach(behavior => { - cfnDistribution.addOverride( - `Properties.DistributionConfig.CacheBehaviors[${props.behaviors?.findIndex(behavior => behavior.pathPattern == behavior)}].ResponseHeadersPolicyId`, - policyMapping.header.responseHeadersPolicyId - ); - }); + policyMapping.pathPatterns.forEach(path => cfnDistribution.addOverride( + `Properties.DistributionConfig.CacheBehaviors[${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})}].ResponseHeadersPolicyId`, + policyMapping.header.responseHeadersPolicyId + )); }); } From 47f624e3739ef7256e059dc000c5df0e45daf64b Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 19 Dec 2022 09:39:18 +1030 Subject: [PATCH 03/13] DO_1419: fixed array index ref --- packages/static-hosting/lib/static-hosting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 248081f9..61440220 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -320,7 +320,7 @@ export class StaticHosting extends Construct { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; props.responseHeaders.forEach( (policyMapping) => { policyMapping.pathPatterns.forEach(path => cfnDistribution.addOverride( - `Properties.DistributionConfig.CacheBehaviors[${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})}].ResponseHeadersPolicyId`, + `Properties.DistributionConfig.CacheBehaviors.${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})}.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId )); }); From 0bea5d605c6fa76c016c5519b0591df071805f4d Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 19 Dec 2022 13:40:11 +1030 Subject: [PATCH 04/13] DO_1419: Fixing some indexing referecing issues --- packages/static-hosting/lib/static-hosting.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 61440220..8ce3c99f 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -318,9 +318,20 @@ export class StaticHosting extends Construct { */ if (props.responseHeaders) { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; + + /** + * If we prepend the custom origin config, + * it would change the array indexes. + */ + let numberOfCustomBehaviors = 0; + if (props.prependCustomOriginBehaviours) { + numberOfCustomBehaviors = props.customOriginConfigs?.reduce((acc, current) => acc + current.behaviors.length, 0)!; + } props.responseHeaders.forEach( (policyMapping) => { policyMapping.pathPatterns.forEach(path => cfnDistribution.addOverride( - `Properties.DistributionConfig.CacheBehaviors.${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})}.ResponseHeadersPolicyId`, + `Properties.DistributionConfig.CacheBehaviors.` + + `${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})! + numberOfCustomBehaviors}` + + `.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId )); }); From 1fef6c11db926935545cc76270a57a117863ec03 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 19 Dec 2022 13:40:22 +1030 Subject: [PATCH 05/13] DO_1419: Fixing some indexing referecing issues --- packages/static-hosting/lib/static-hosting.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 8ce3c99f..9bd40d0c 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -320,7 +320,7 @@ export class StaticHosting extends Construct { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; /** - * If we prepend the custom origin config, + * If we prepend custom origin configs, * it would change the array indexes. */ let numberOfCustomBehaviors = 0; From 39c7785a7324263be01c49b377aa4d64a15130ac Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 19 Dec 2022 17:03:01 +1030 Subject: [PATCH 06/13] DO_1419: Include policy mappings for default behaviour --- packages/static-hosting/lib/static-hosting.ts | 43 +++++++++++++++---- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 9bd40d0c..d5ea429f 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -82,7 +82,8 @@ interface remapPath { export interface ResponseHeaderMappings { header: ResponseHeadersPolicy, - pathPatterns: string[] + pathPatterns: string[], + attachedToDefault?: boolean } export class StaticHosting extends Construct { @@ -315,6 +316,8 @@ export class StaticHosting extends Construct { /** * Response Header policies + * This feature helps to attached custom ResponseHeadersPolicies to + * the cache behaviors */ if (props.responseHeaders) { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; @@ -327,16 +330,40 @@ export class StaticHosting extends Construct { if (props.prependCustomOriginBehaviours) { numberOfCustomBehaviors = props.customOriginConfigs?.reduce((acc, current) => acc + current.behaviors.length, 0)!; } + props.responseHeaders.forEach( (policyMapping) => { - policyMapping.pathPatterns.forEach(path => cfnDistribution.addOverride( - `Properties.DistributionConfig.CacheBehaviors.` + - `${props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})! + numberOfCustomBehaviors}` + - `.ResponseHeadersPolicyId`, + /** + * If the policy should be attached to default behavior + */ + if (policyMapping.attachedToDefault) { + cfnDistribution.addOverride( + `Properties.DistributionConfig.CacheBehaviors.` + + `DefaultCacheBehavior` + + `.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId - )); + )}; + /** + * If the policy should be attached to + * specified path patterns + */ + policyMapping.pathPatterns.forEach(path => { + /** + * Looking for the index of the behavior + * according to the path pattern + * If the path patter is not found, it would be ignored + */ + let behaviorIndex = props.behaviors?.findIndex(behavior => {return behavior.pathPattern === path})! + numberOfCustomBehaviors; + + if (behaviorIndex >= numberOfCustomBehaviors){ + cfnDistribution.addOverride( + `Properties.DistributionConfig.CacheBehaviors.` + + `${behaviorIndex}` + + `.ResponseHeadersPolicyId`, + policyMapping.header.responseHeadersPolicyId + )}; + }); }); - } - + if (publisherGroup) { const cloudFrontInvalidationPolicyStatement = new PolicyStatement({ effect: Effect.ALLOW, From 537bd5b7eace409c168fa62689b7e25e0b59a395 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Mon, 19 Dec 2022 17:14:46 +1030 Subject: [PATCH 07/13] DO_1419: fixed a syntax issue --- packages/static-hosting/lib/static-hosting.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index d5ea429f..8e24a0be 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -363,6 +363,7 @@ export class StaticHosting extends Construct { )}; }); }); + } if (publisherGroup) { const cloudFrontInvalidationPolicyStatement = new PolicyStatement({ From 2684c0cfc717d40faae8fa33c8afeb6747d82678 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 08:55:05 +1030 Subject: [PATCH 08/13] DO-1419: Update the docs --- packages/static-hosting/README.md | 46 ++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/packages/static-hosting/README.md b/packages/static-hosting/README.md index cbdf2d77..f105b757 100644 --- a/packages/static-hosting/README.md +++ b/packages/static-hosting/README.md @@ -2,10 +2,11 @@ ## Overview -This repository defines a CDK construct for hosting a static website on AWS using S3 and CloudFront. +This repository defines a CDK construct for hosting a static website on AWS using S3 and CloudFront. It can be imported and used within CDK applications. ## Example + The following CDK snippet can be used to provision a static hosting stack using this construct. ``` @@ -43,3 +44,46 @@ new HostingStack(app, 'hosting-stack', { }); ``` + +### Response Header Policies + +You can initialize [Response Headers Policies], map them and pass to the construct. + +1. Create a policy + + ```sh + // Creating a custom response headers policy -- all parameters optional + const reportUriPolicy = new ResponseHeadersPolicy(this, 'ReportUriPolicy', { + responseHeadersPolicyName: 'ReportUriPolicy', + comment: 'To enable CSP Reporting', + customHeadersBehavior: { + customHeaders: [ + { + header: 'content-security-policy-report-only', + value: `default-src 'none'; form-action 'none'; frame-ancestors 'none'; report-uri https://some-report-uri-domain.report-uri.com/r/t/csp/wizard`, + override: true + }, + ], + }, + }); + ``` + +2. Attached policy to desired cache behavior or path + + ```sh + const responseHeaders: ResponseHeaderMappings[] = [{ + header: reportUriPolicy, + pathPatterns: ['/au*', '/nz*'] + attachToDefault: false + }]; + ``` + + If you should attached the policy to the Default Behavior, set `attachToDefault: true` + +3. Include the config as props + + ```sh + new StaticHosting(this, 'pwa-stack', {...staticProps, ...{behaviors, customOriginConfigs, responseHeaders}}); + ``` + +[Response Headers Policies]:https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-cloudfront.ResponseHeadersPolicy.html From aedd21712e94e501aabd6a82a1c7337fa07377b7 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 09:21:03 +1030 Subject: [PATCH 09/13] DO-1419: Fixed override instruction on the default behavior --- packages/static-hosting/lib/static-hosting.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 8e24a0be..ca8eacad 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -72,7 +72,7 @@ export interface StaticHostingProps { /** * Response Header policies */ - responseHeaders?: ResponseHeaderMappings[]; + responseHeadersPolicies?: ResponseHeaderMappings[]; } interface remapPath { @@ -83,7 +83,7 @@ interface remapPath { export interface ResponseHeaderMappings { header: ResponseHeadersPolicy, pathPatterns: string[], - attachedToDefault?: boolean + attachToDefault?: boolean } export class StaticHosting extends Construct { @@ -319,7 +319,7 @@ export class StaticHosting extends Construct { * This feature helps to attached custom ResponseHeadersPolicies to * the cache behaviors */ - if (props.responseHeaders) { + if (props.responseHeadersPolicies) { const cfnDistribution = distribution.node.defaultChild as CfnDistribution; /** @@ -331,15 +331,15 @@ export class StaticHosting extends Construct { numberOfCustomBehaviors = props.customOriginConfigs?.reduce((acc, current) => acc + current.behaviors.length, 0)!; } - props.responseHeaders.forEach( (policyMapping) => { + props.responseHeadersPolicies.forEach( (policyMapping) => { /** * If the policy should be attached to default behavior */ - if (policyMapping.attachedToDefault) { + if (policyMapping.attachToDefault) { cfnDistribution.addOverride( - `Properties.DistributionConfig.CacheBehaviors.` + - `DefaultCacheBehavior` + - `.ResponseHeadersPolicyId`, + `Properties.DistributionConfig.` + + `DefaultCacheBehavior.` + + `ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId )}; /** @@ -363,6 +363,12 @@ export class StaticHosting extends Construct { )}; }); }); + + new CfnOutput(this, 'Response Header Policies', { + description: 'Response Header Policies', + value: JSON.stringify(props.responseHeadersPolicies), + exportName: `${exportPrefix}CSPHeader` + }); } if (publisherGroup) { From 566e52a078059471e010da2489ef71ab0465ccc1 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 10:02:20 +1030 Subject: [PATCH 10/13] DO-1419: Expand cfn outputs --- packages/static-hosting/lib/static-hosting.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index ca8eacad..34b58593 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -341,7 +341,16 @@ export class StaticHosting extends Construct { `DefaultCacheBehavior.` + `ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId - )}; + ); + new CfnOutput(this, `response header policies${policyMapping.header.responseHeadersPolicyId}`, { + description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, + value: `{ + path: "default", + policy: "${policyMapping.header.responseHeadersPolicyId}" + }`, + exportName: `${exportPrefix}_header_policy_default` + }); + }; /** * If the policy should be attached to * specified path patterns @@ -360,15 +369,18 @@ export class StaticHosting extends Construct { `${behaviorIndex}` + `.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId - )}; + ); + new CfnOutput(this, `response header policies${policyMapping.header.responseHeadersPolicyId}`, { + description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, + value: `{ + path: "${path}", + policy: "${policyMapping.header.responseHeadersPolicyId}" + }`, + exportName: `${exportPrefix}_header_policy_${path.replace(/\W/g, '')}` + }); + }; }); }); - - new CfnOutput(this, 'Response Header Policies', { - description: 'Response Header Policies', - value: JSON.stringify(props.responseHeadersPolicies), - exportName: `${exportPrefix}CSPHeader` - }); } if (publisherGroup) { From 27eb07db930307a78be196a523397ce3206ca017 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 10:13:31 +1030 Subject: [PATCH 11/13] DO-1419: Fix CFN outout issue --- packages/static-hosting/lib/static-hosting.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index 34b58593..a2d7699a 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -342,7 +342,7 @@ export class StaticHosting extends Construct { `ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId ); - new CfnOutput(this, `response header policies${policyMapping.header.responseHeadersPolicyId}`, { + new CfnOutput(this, `response header policies${policyMapping.header.node.id}`, { description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, value: `{ path: "default", @@ -370,7 +370,7 @@ export class StaticHosting extends Construct { `.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId ); - new CfnOutput(this, `response header policies${policyMapping.header.responseHeadersPolicyId}`, { + new CfnOutput(this, `response header policies${policyMapping.header.node.id}`, { description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, value: `{ path: "${path}", From 8b34d36d036a2c0c243a4cc0ef26279b2b5df80a Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 10:28:32 +1030 Subject: [PATCH 12/13] DO-1419: Fix CFN outout issue with the description --- packages/static-hosting/lib/static-hosting.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index a2d7699a..f650e4bf 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -342,12 +342,9 @@ export class StaticHosting extends Construct { `ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId ); - new CfnOutput(this, `response header policies${policyMapping.header.node.id}`, { - description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, - value: `{ - path: "default", - policy: "${policyMapping.header.responseHeadersPolicyId}" - }`, + new CfnOutput(this, `response header policies ${policyMapping.header.node.id} default`, { + description: `response header policy mappings`, + value: `{ path: "default", policy: "${policyMapping.header.responseHeadersPolicyId}" }`, exportName: `${exportPrefix}_header_policy_default` }); }; @@ -370,12 +367,9 @@ export class StaticHosting extends Construct { `.ResponseHeadersPolicyId`, policyMapping.header.responseHeadersPolicyId ); - new CfnOutput(this, `response header policies${policyMapping.header.node.id}`, { - description: `response header policy mappings: ${policyMapping.header.responseHeadersPolicyId} `, - value: `{ - path: "${path}", - policy: "${policyMapping.header.responseHeadersPolicyId}" - }`, + new CfnOutput(this, `response header policies ${policyMapping.header.node.id} ${path.replace(/\W/g, '')}`, { + description: `response header policy mappings`, + value: `{ path: "${path}", policy: "${policyMapping.header.responseHeadersPolicyId}"}`, exportName: `${exportPrefix}_header_policy_${path.replace(/\W/g, '')}` }); }; From 1f2edbd9369e96c82cc571bd4b2dc755ae6a0ab0 Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Tue, 20 Dec 2022 10:35:57 +1030 Subject: [PATCH 13/13] DO-1419: Fix CFN outout issue with the export name --- packages/static-hosting/lib/static-hosting.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/static-hosting/lib/static-hosting.ts b/packages/static-hosting/lib/static-hosting.ts index f650e4bf..03101dcf 100644 --- a/packages/static-hosting/lib/static-hosting.ts +++ b/packages/static-hosting/lib/static-hosting.ts @@ -345,7 +345,7 @@ export class StaticHosting extends Construct { new CfnOutput(this, `response header policies ${policyMapping.header.node.id} default`, { description: `response header policy mappings`, value: `{ path: "default", policy: "${policyMapping.header.responseHeadersPolicyId}" }`, - exportName: `${exportPrefix}_header_policy_default` + exportName: `${exportPrefix}HeaderPolicy-default` }); }; /** @@ -370,7 +370,7 @@ export class StaticHosting extends Construct { new CfnOutput(this, `response header policies ${policyMapping.header.node.id} ${path.replace(/\W/g, '')}`, { description: `response header policy mappings`, value: `{ path: "${path}", policy: "${policyMapping.header.responseHeadersPolicyId}"}`, - exportName: `${exportPrefix}_header_policy_${path.replace(/\W/g, '')}` + exportName: `${exportPrefix}HeaderPolicy-${path.replace(/\W/g, '')}` }); }; });