Skip to content

Commit

Permalink
feat(AWS CloudFront): Recognize behavior.ResponseHeadersPolicyId
Browse files Browse the repository at this point in the history
(PR #11633)
  • Loading branch information
jasonrowsell committed Dec 27, 2022
1 parent 671aa61 commit 906ea31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/plugins/aws/package/compile/events/cloud-front.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class AwsCompileCloudFrontEvents {
Compress: { type: 'boolean' },
FieldLevelEncryptionId: { type: 'string' },
OriginRequestPolicyId: { type: 'string' },
ResponseHeadersPolicyId: { type: 'string' },
SmoothStreaming: { type: 'boolean' },
TrustedSigners: { type: 'array', items: { type: 'string' } },
ViewerProtocolPolicy: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js',
},
},
};
const responseHeadersPolicyId = '5cc3b908-e619-4b99-88e5-2cf7f45965bd';

const getAssociatedCacheBehavior = (pathPattern) =>
cfResources.CloudFrontDistribution.Properties.DistributionConfig.CacheBehaviors.find(
Expand Down Expand Up @@ -1869,6 +1870,7 @@ describe('test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js',
pathPattern: 'managedPolicySetViaBehavior',
behavior: {
CachePolicyId: cachePolicyId,
ResponseHeadersPolicyId: responseHeadersPolicyId,
},
},
},
Expand Down Expand Up @@ -2056,6 +2058,12 @@ describe('test/unit/lib/plugins/aws/package/compile/events/cloudFront.test.js',
);
});

it('Should attach a response headers policy to a cloudfront behavior when specified by id via `behavior.ResponseHeadersPolicyId` in lambda config', () => {
expect(
getAssociatedCacheBehavior('managedPolicySetViaBehavior').ResponseHeadersPolicyId
).to.eq(responseHeadersPolicyId);
});

it('Should attach a cache policy specified via `cachePolicy.id` to a cloudfront behavior when specified via both of `cachePolicy.id` and `behavior.CachePolicyId` in lambda config', () => {
expect(
getAssociatedCacheBehavior('policySetViaCachePolicyIdAndBehavior').CachePolicyId
Expand Down

0 comments on commit 906ea31

Please sign in to comment.