Skip to content

Commit

Permalink
Allow override of whole behaviourOptions, edited a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
finnholland committed Oct 24, 2024
1 parent 0d7f5d8 commit 6049cea
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface StaticHostingProps {
enableStaticFileRemap?: boolean;

/**
* Overrides default behaviour paths with a prefix and takes in options to apply to each static file behaviour
* Overrides default behaviour paths with a prefix and takes in behviour options to apply on the prefix behaviour
*
* @default true
*/
Expand Down Expand Up @@ -357,12 +357,12 @@ export class StaticHosting extends Construct {

const s3LoggingBucket = props.enableS3AccessLogging
? new Bucket(this, "S3LoggingBucket", {
bucketName: `${siteName}-s3-access-logs`,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: RemovalPolicy.RETAIN,
enforceSSL: enforceSSL,
})
bucketName: `${siteName}-s3-access-logs`,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: RemovalPolicy.RETAIN,
enforceSSL: enforceSSL,
})
: undefined;

if (s3LoggingBucket) {
Expand Down Expand Up @@ -397,8 +397,8 @@ export class StaticHosting extends Construct {
const publisherUser =
props.createPublisherUser !== false
? new User(this, "PublisherUser", {
userName: `publisher-${siteName}`,
})
userName: `publisher-${siteName}`,
})
: undefined;

if (publisherUser) {
Expand Down Expand Up @@ -430,12 +430,12 @@ export class StaticHosting extends Construct {

const loggingBucket = props.enableCloudFrontAccessLogging
? new Bucket(this, "LoggingBucket", {
bucketName: `${siteName}-access-logs`,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: RemovalPolicy.RETAIN,
enforceSSL: enforceSSL,
})
bucketName: `${siteName}-access-logs`,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy: RemovalPolicy.RETAIN,
enforceSSL: enforceSSL,
})
: undefined;

if (loggingBucket) {
Expand Down Expand Up @@ -576,12 +576,12 @@ export class StaticHosting extends Construct {

props.defaultBehaviourPrefixes?.forEach(prefix => {
additionalBehaviors[`${prefix.prefix}*`] = {
origin: s3Origin,
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
origin: prefix.behaviourOverride.origin ?? s3Origin,
viewerProtocolPolicy: prefix.behaviourOverride.viewerProtocolPolicy ?? ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
edgeLambdas: prefix.behaviourOverride.edgeLambdas,
originRequestPolicy: originRequestPolicy,
cachePolicy: originCachePolicy,
responseHeadersPolicy: responseHeadersPolicy,
originRequestPolicy: prefix.behaviourOverride.originRequestPolicy ?? originRequestPolicy,
cachePolicy: prefix.behaviourOverride.cachePolicy ?? originCachePolicy,
responseHeadersPolicy: prefix.behaviourOverride.responseHeadersPolicy ?? responseHeadersPolicy,
};
});

Expand Down Expand Up @@ -701,9 +701,9 @@ export class StaticHosting extends Construct {
const cspEntries = explicit
? csp
: {
"default-src": [],
...csp,
};
"default-src": [],
...csp,
};

return Object.entries(cspEntries)
.reduce((prevCspHeader, [cspType, cspHeaders]) => {
Expand Down

0 comments on commit 6049cea

Please sign in to comment.