Skip to content

Commit

Permalink
DO-1531: retain original props to make upgrading easier
Browse files Browse the repository at this point in the history
  • Loading branch information
gowrizrh committed Sep 26, 2023
1 parent 33a4e26 commit 668d5af
Showing 1 changed file with 46 additions and 17 deletions.
63 changes: 46 additions & 17 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,51 @@ import {
import { CSP } from "../types/csp";

export interface StaticHostingProps {
domainNames: string[];
exportPrefix?: string;
enforceSSL?: boolean;
disableCSP?: boolean;
enableS3AccessLogging?: boolean;
s3ExtendedProps?: BucketProps;
createPublisherUser?: boolean;
createPublisherGroup?: boolean;
enableCloudFrontAccessLogging?: boolean;
errorResponsePagePath?: string;
webAclId?: string;
defaultRootObject?: string;
domainName: string;
subDomainName: string;
certificateArn: string;
defaultBehaviorEdgeLambdas: EdgeLambda[];
additionalBehaviors?: Record<string, BehaviorOptions>;
enableErrorConfig?: boolean;
createDnsRecord?: boolean;
createPublisherGroup?: boolean;
createPublisherUser?: boolean;
extraDistributionCnames?: ReadonlyArray<string>;
enableCloudFrontAccessLogging?: boolean;
enableS3AccessLogging?: boolean;
zoneName?: string;
enableErrorConfig?: boolean;
defaultRootObject?: string;
enforceSSL?: boolean;

/**
* Disable the use of the CSP header. Default value is false.
*/
disableCSP?: boolean;

/**
* AWS limits the max header size to 1kb, this is too small for complex csp headers.
* The main purpose of this csp header is to provide a method of setting a report-uri.
*/
csp?: CSP;

/**
* This will generate a csp based *purely* on the provided csp object.
* Therefore disabling the automatic adding of common use-case properties.
*/
explicitCSP?: boolean;

/**
* Extend the default props for S3 bucket
*/
s3ExtendedProps?: BucketProps;

/**
* Optional WAF ARN
*/
webAclArn?: string;
responseHeadersPolicies?: ResponseHeaderMappings;
additionalBehaviors?: Record<string, BehaviorOptions>;
errorResponsePagePath?: string;
defaultBehaviorEdgeLambdas: EdgeLambda[];

/**
* After switching constructs, you need to maintain the same logical ID
Expand Down Expand Up @@ -90,7 +114,8 @@ export class StaticHosting extends Construct {
? props.exportPrefix
: "StaticHosting";

const siteName = props.domainNames[0];
const siteName = `${props.subDomainName}.${props.domainName}`;
const siteNameArray: Array<string> = [siteName];
const enforceSSL = props.enforceSSL !== false;
const disableCSP = props.disableCSP === true;

Expand Down Expand Up @@ -246,9 +271,13 @@ export class StaticHosting extends Construct {
}
}

const domainNames: Array<string> = props.extraDistributionCnames
? siteNameArray.concat(props.extraDistributionCnames)
: siteNameArray;

const distributionProps: DistributionProps = {
domainNames: props.domainNames,
webAclId: props.webAclId,
domainNames: domainNames,
webAclId: props.webAclArn,
defaultRootObject: props.defaultRootObject,
httpVersion: HttpVersion.HTTP3,
sslSupportMethod: SSLMethod.SNI,
Expand Down

0 comments on commit 668d5af

Please sign in to comment.