-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Behaviour Prefixes (for CDK v2 upgrade) #1401
Changes from 1 commit
6b14c30
5a60fe1
0d7f5d8
faa19f8
ace316a
4dc214d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,11 +140,14 @@ export interface StaticHostingProps { | |
enableStaticFileRemap?: boolean; | ||
|
||
/** | ||
* Any prefixes to remapping that should be included in the path such as au or nz | ||
* Overrides default behaviour paths with a prefix and takes in options to apply to each static file behaviour | ||
* | ||
* @default true | ||
*/ | ||
behaviourPrefixes?: { prefix: string; edgeLambdas: EdgeLambda[] }[]; | ||
defaultBehaviourPrefixes?: { | ||
prefix: string; | ||
behaviourOverride: Partial<BehaviorOptions>; | ||
}[]; | ||
|
||
/** | ||
* Optional additional properties for static file remap behaviours | ||
|
@@ -558,7 +561,7 @@ export class StaticHosting extends Construct { | |
} | ||
|
||
if (enableStaticFileRemap) { | ||
const staticFileRemapPrefixes = props.behaviourPrefixes?.map( | ||
const staticFileRemapPrefixes = props.defaultBehaviourPrefixes?.map( | ||
prefix => `${prefix.prefix}/` | ||
) || [""]; | ||
TheOrangePuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
staticFileRemapPrefixes.forEach(prefix => { | ||
|
@@ -571,11 +574,11 @@ export class StaticHosting extends Construct { | |
}); | ||
} | ||
|
||
props.behaviourPrefixes?.forEach(prefix => { | ||
props.defaultBehaviourPrefixes?.forEach(prefix => { | ||
TheOrangePuff marked this conversation as resolved.
Show resolved
Hide resolved
|
||
additionalBehaviors[`${prefix.prefix}*`] = { | ||
origin: s3Origin, | ||
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS, | ||
edgeLambdas: prefix.edgeLambdas, | ||
edgeLambdas: prefix.behaviourOverride.edgeLambdas, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of just passing the edge lambda you can do this: additionalBehaviors[`${prefix.prefix}*`] = {
origin: s3Origin,
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
originRequestPolicy: originRequestPolicy,
cachePolicy: originCachePolicy,
responseHeadersPolicy: responseHeadersPolicy,
...prefix.behaviourOverride,
}; Because that will then allow you to override any of the properties if you need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @finn-holland-aligent this one hasn't been resolved yet |
||
originRequestPolicy: originRequestPolicy, | ||
cachePolicy: originCachePolicy, | ||
responseHeadersPolicy: responseHeadersPolicy, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The options don't apply to the static file behaviour do they?