Skip to content

Commit

Permalink
Merge pull request #1399 from aligent/feature/TNT-1508-behaviour-rema…
Browse files Browse the repository at this point in the history
…p-options

Static hosting behaviour remap options
  • Loading branch information
TheOrangePuff authored Sep 15, 2024
2 parents 4d62d2a + 1ced5b3 commit cd8d654
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ export interface StaticHostingProps {
*/
enableStaticFileRemap?: boolean;

/**
* Optional additional properties for static file remap behaviours
*
* @default none
*/
staticFileRemapOptions?: Partial<BehaviorOptions>;

/**
* Paths to remap on the default behaviour. For example you might remap deployed_sitemap.xml -> sitemap.xml
* Created a behaviour in CloudFront to handle the remap. If the paths are different
Expand Down Expand Up @@ -288,6 +295,7 @@ export interface StaticHostingProps {
interface remapPath {
from: string;
to?: string;
behaviour?: Partial<BehaviorOptions>;
}

export interface ResponseHeaderMappings {
Expand Down Expand Up @@ -523,6 +531,7 @@ export class StaticHosting extends Construct {
origin: backendOrigin,
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
edgeLambdas: this.createRemapBehavior(path.from, path.to),
...path.behaviour,
};
}
}
Expand All @@ -533,6 +542,7 @@ export class StaticHosting extends Construct {
additionalBehaviors[`*.${path}`] = {
origin: s3Origin,
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
...props.staticFileRemapOptions,
};
}
}
Expand All @@ -545,6 +555,7 @@ export class StaticHosting extends Construct {
origin: s3Origin,
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
edgeLambdas: this.createRemapBehavior(path.from, path.to),
...path.behaviour,
};
}
}
Expand Down

0 comments on commit cd8d654

Please sign in to comment.