Skip to content

Commit

Permalink
feat(static-website): allow custom Lambda@Edge functions (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
jogold authored Apr 3, 2024
1 parent ed59fc4 commit 1737c98
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion src/static-website/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export interface StaticWebsiteProps {
* @default - a new policy is created with best practice security headers
*/
readonly responseHeadersPolicy?: cloudfront.ResponseHeadersPolicy;

/**
* The Lambda@Edge functions to invoke before serving the contents.
*
* @default - an origin request function that redirects all requests for a path to /index.html
*/
readonly edgeLambdas?: cloudfront.EdgeLambda[];
}

/**
Expand Down Expand Up @@ -111,7 +118,7 @@ export class StaticWebsite extends Construct {
defaultBehavior: {
origin: new origins.S3Origin(this.bucket),
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
edgeLambdas: [
edgeLambdas: props.edgeLambdas ?? [
{
eventType: cloudfront.LambdaEdgeEventType.ORIGIN_REQUEST,
functionVersion: new OriginRequestFunction(this, 'OriginRequest'),
Expand Down

0 comments on commit 1737c98

Please sign in to comment.