Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ distribution:
enabled: true # optional
defaults: # optional
ttl: 15
allowedHttpMethods: ['HEAD', 'GET']
lambda@edge: # added to cloudfront default cache behavior
viewer-request: arn:aws:lambda:us-east-1:123:function:myFunc:version
origins:
Expand Down
7 changes: 6 additions & 1 deletion __tests__/__snapshots__/custom-url-origin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ Object {
},
"Items": Array [
"HEAD",
"DELETE",
"POST",
"GET",
"OPTIONS",
"PUT",
"PATCH",
],
"Quantity": 2,
"Quantity": 7,
},
"Compress": false,
"DefaultTTL": 10,
Expand Down
1 change: 1 addition & 0 deletions __tests__/custom-url-origin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Input origin as a custom url', () => {
it('creates distribution with custom url origin and sets defaults', async () => {
await component.default({
defaults: {
allowedHttpMethods: ['HEAD', 'DELETE', 'POST', 'GET', 'OPTIONS', 'PUT', 'PATCH'],
ttl: 10,
'lambda@edge': {
'origin-request': 'arn:aws:lambda:us-east-1:123:function:originRequestFunction'
Expand Down
6 changes: 4 additions & 2 deletions lib/getDefaultCacheBehavior.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const addLambdaAtEdgeToCacheBehavior = require('./addLambdaAtEdgeToCacheBehavior')

module.exports = (originId, defaults = {}) => {
const allowedMethods = defaults.allowedHttpMethods || ['HEAD', 'GET']

const defaultCacheBehavior = {
TargetOriginId: originId,
ForwardedValues: {
Expand All @@ -25,8 +27,8 @@ module.exports = (originId, defaults = {}) => {
ViewerProtocolPolicy: 'redirect-to-https',
MinTTL: 0,
AllowedMethods: {
Quantity: 2,
Items: ['HEAD', 'GET'],
Quantity: allowedMethods.length,
Items: allowedMethods,
CachedMethods: {
Quantity: 2,
Items: ['HEAD', 'GET']
Expand Down