@serverless/aws-cloudfront
Advanced tools
Comparing version 3.2.0 to 5.0.0
@@ -0,20 +1,18 @@ | ||
const { getForwardedValues } = require('./cacheBahaviorUtils') | ||
module.exports = (pathPattern, pathPatternConfig, originId) => { | ||
const { ttl, allowedHttpMethods } = pathPatternConfig | ||
const allowedMethods = allowedHttpMethods || ['GET', 'HEAD'] | ||
const { | ||
allowedHttpMethods = ['GET', 'HEAD'], | ||
ttl, | ||
compress = true, | ||
smoothStreaming = false, | ||
viewerProtocolPolicy = 'https-only', | ||
fieldLevelEncryptionId = '' | ||
} = pathPatternConfig | ||
return { | ||
ForwardedValues: { | ||
Cookies: { | ||
Forward: 'all' | ||
}, | ||
QueryString: true, | ||
Headers: { | ||
Quantity: 0, | ||
Items: [] | ||
}, | ||
QueryStringCacheKeys: { | ||
Quantity: 0, | ||
Items: [] | ||
} | ||
}, | ||
ForwardedValues: getForwardedValues(pathPatternConfig.forward, { | ||
cookies: 'all', | ||
queryString: true | ||
}), | ||
MinTTL: ttl, | ||
@@ -27,6 +25,6 @@ PathPattern: pathPattern, | ||
}, | ||
ViewerProtocolPolicy: 'https-only', | ||
ViewerProtocolPolicy: viewerProtocolPolicy, | ||
AllowedMethods: { | ||
Quantity: allowedMethods.length, | ||
Items: allowedMethods, | ||
Quantity: allowedHttpMethods.length, | ||
Items: allowedHttpMethods, | ||
CachedMethods: { | ||
@@ -37,7 +35,7 @@ Items: ['GET', 'HEAD'], | ||
}, | ||
Compress: true, | ||
SmoothStreaming: false, | ||
Compress: compress, | ||
SmoothStreaming: smoothStreaming, | ||
DefaultTTL: ttl, | ||
MaxTTL: ttl, | ||
FieldLevelEncryptionId: '', | ||
FieldLevelEncryptionId: fieldLevelEncryptionId, | ||
LambdaFunctionAssociations: { | ||
@@ -44,0 +42,0 @@ Quantity: 0, |
const addLambdaAtEdgeToCacheBehavior = require('./addLambdaAtEdgeToCacheBehavior') | ||
const { getForwardedValues } = require('./cacheBahaviorUtils') | ||
module.exports = (originId, defaults = {}) => { | ||
const allowedMethods = defaults.allowedHttpMethods || ['HEAD', 'GET'] | ||
const { | ||
allowedHttpMethods = ['HEAD', 'GET'], | ||
forward = {}, | ||
ttl = 86400, | ||
compress = false, | ||
smoothStreaming = false, | ||
viewerProtocolPolicy = 'redirect-to-https', | ||
fieldLevelEncryptionId = '' | ||
} = defaults | ||
const defaultCacheBehavior = { | ||
TargetOriginId: originId, | ||
ForwardedValues: { | ||
QueryString: false, | ||
Cookies: { | ||
Forward: 'none' | ||
}, | ||
Headers: { | ||
Quantity: 0, | ||
Items: [] | ||
}, | ||
QueryStringCacheKeys: { | ||
Quantity: 0, | ||
Items: [] | ||
} | ||
}, | ||
ForwardedValues: getForwardedValues(forward), | ||
TrustedSigners: { | ||
@@ -27,7 +23,7 @@ Enabled: false, | ||
}, | ||
ViewerProtocolPolicy: 'redirect-to-https', | ||
ViewerProtocolPolicy: viewerProtocolPolicy, | ||
MinTTL: 0, | ||
AllowedMethods: { | ||
Quantity: allowedMethods.length, | ||
Items: allowedMethods, | ||
Quantity: allowedHttpMethods.length, | ||
Items: allowedHttpMethods, | ||
CachedMethods: { | ||
@@ -38,6 +34,6 @@ Quantity: 2, | ||
}, | ||
SmoothStreaming: false, | ||
DefaultTTL: defaults.ttl || 86400, | ||
SmoothStreaming: smoothStreaming, | ||
DefaultTTL: ttl, | ||
MaxTTL: 31536000, | ||
Compress: false, | ||
Compress: compress, | ||
LambdaFunctionAssociations: { | ||
@@ -47,3 +43,3 @@ Quantity: 0, | ||
}, | ||
FieldLevelEncryptionId: '' | ||
FieldLevelEncryptionId: fieldLevelEncryptionId | ||
} | ||
@@ -50,0 +46,0 @@ |
{ | ||
"name": "@serverless/aws-cloudfront", | ||
"version": "3.2.0", | ||
"version": "5.0.0", | ||
"main": "./serverless.js", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
@@ -56,2 +56,13 @@ # aws-cloudfront | ||
allowedHttpMethods: ['HEAD', 'GET'] | ||
forward: # optional | ||
# array of header names, 'none' or 'all' | ||
headers: ['Accept', 'Accept-Language'] | ||
# array of cookie names, 'none' or 'all' | ||
cookies: ['my-cookie] | ||
queryString: true | ||
queryStringCacheKeys: ['queryKey'] | ||
viewerProtocolPolicy: 'https-only' # optional | ||
smoothStreaming: true # optional | ||
compress: true # optional | ||
fieldLevelEncryptionId: '123' # optional | ||
lambda@edge: # added to cloudfront default cache behavior | ||
@@ -64,3 +75,3 @@ viewer-request: arn:aws:lambda:us-east-1:123:function:myFunc:version | ||
#### Custom cache behavior | ||
Custom cache behaviors support the same config parameters as the default cache behavior (see the example above). | ||
```yml | ||
@@ -78,2 +89,8 @@ # serverless.yml | ||
allowedHttpMethods: ['GET', 'HEAD'] # optional | ||
forward: # optional | ||
headers: 'all' | ||
cookies: ['auth-token'] | ||
queryString: true | ||
compress: false # optional | ||
# ... | ||
``` | ||
@@ -80,0 +97,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
84233
33
1122
142