Skip to content

Commit

Permalink
feat(cloudfront): add ability to set ResponseHeadersPolicyId (#2285)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisneal committed Jan 25, 2022
1 parent e492064 commit 15b282d
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 3 deletions.
Expand Up @@ -57,6 +57,7 @@ Object {
"MaxTTL": 0,
"MinTTL": 0,
"PathPattern": "/sample/path",
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mycustomorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -112,6 +113,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mycustomorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -225,6 +227,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "uuid",
"SmoothStreaming": true,
"TargetOriginId": "mycustomorigin.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -67,6 +67,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mycustomorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -164,6 +165,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mycustomoriginupdated.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -70,6 +70,7 @@ Object {
"MaxTTL": 10,
"MinTTL": 10,
"PathPattern": "/some/path",
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -125,6 +126,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -50,6 +50,7 @@ Object {
"MaxTTL": 10,
"MinTTL": 10,
"PathPattern": "/some/path",
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -105,6 +106,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -56,6 +56,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -153,6 +154,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -50,6 +50,7 @@ Object {
"MaxTTL": 10,
"MinTTL": 10,
"PathPattern": "/some/path",
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -105,6 +106,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -196,6 +198,7 @@ Object {
"MaxTTL": 10,
"MinTTL": 10,
"PathPattern": "/some/other/path",
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down Expand Up @@ -250,6 +253,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "exampleorigin.com",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -56,6 +56,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -149,6 +150,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -236,6 +238,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "anotherbucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -326,6 +329,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -413,6 +417,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "anotherbucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -503,6 +508,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket.with.dots",
"TrustedSigners": Object {
Expand Down Expand Up @@ -590,6 +596,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "anotherbucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -680,6 +687,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket.s3.s3",
"TrustedSigners": Object {
Expand Down Expand Up @@ -767,6 +775,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "anotherbucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -857,6 +866,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "mybucket",
"TrustedSigners": Object {
Expand Down Expand Up @@ -944,6 +954,7 @@ Object {
},
"MaxTTL": 31536000,
"MinTTL": 0,
"ResponseHeadersPolicyId": "",
"SmoothStreaming": false,
"TargetOriginId": "anotherbucket",
"TrustedSigners": Object {
Expand Down
Expand Up @@ -44,7 +44,8 @@ describe("Input origin as a custom url", () => {
viewerProtocolPolicy: "https-only",
smoothStreaming: true,
compress: true,
fieldLevelEncryptionId: "123"
fieldLevelEncryptionId: "123",
responseHeadersPolicyId: "uuid"
},
origins: ["https://mycustomorigin.com"]
});
Expand Down
Expand Up @@ -14,6 +14,7 @@ export default (
smoothStreaming = false,
viewerProtocolPolicy = "https-only",
fieldLevelEncryptionId = "",
responseHeadersPolicyId = "",
trustedSigners = {
Enabled: false,
Quantity: 0
Expand Down Expand Up @@ -43,6 +44,7 @@ export default (
DefaultTTL: defaultTTL,
MaxTTL: maxTTL,
FieldLevelEncryptionId: fieldLevelEncryptionId,
ResponseHeadersPolicyId: responseHeadersPolicyId,
LambdaFunctionAssociations: {
Quantity: 0,
Items: []
Expand Down
Expand Up @@ -11,6 +11,7 @@ type DefaultCacheBehavior = {
smoothStreaming?: boolean;
viewerProtocolPolicy?: string;
fieldLevelEncryptionId?: string;
responseHeadersPolicyId?: string;
};

export default (originId, defaults: DefaultCacheBehavior = {}) => {
Expand All @@ -23,7 +24,8 @@ export default (originId, defaults: DefaultCacheBehavior = {}) => {
compress = false,
smoothStreaming = false,
viewerProtocolPolicy = "redirect-to-https",
fieldLevelEncryptionId = ""
fieldLevelEncryptionId = "",
responseHeadersPolicyId = ""
} = defaults;

const defaultCacheBehavior = {
Expand Down Expand Up @@ -52,7 +54,8 @@ export default (originId, defaults: DefaultCacheBehavior = {}) => {
Quantity: 0,
Items: []
},
FieldLevelEncryptionId: fieldLevelEncryptionId
FieldLevelEncryptionId: fieldLevelEncryptionId,
ResponseHeadersPolicyId: responseHeadersPolicyId
};

addLambdaAtEdgeToCacheBehavior(defaultCacheBehavior, defaults["lambda@edge"]);
Expand Down

0 comments on commit 15b282d

Please sign in to comment.