Skip to content

Commit

Permalink
fix: compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hollanddd committed Mar 6, 2021
1 parent 04a8a8e commit 831b940
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CloudFrontWebDistribution, CloudFrontWebDistributionProps, OriginAccess
import { Bucket, BlockPublicAccess } from '@aws-cdk/aws-s3';
import { Construct, RemovalPolicy, Duration } from '@aws-cdk/core';

interface WebsiteProps {
domainName?: string;
logExpiration?: Duration;
certificateArn?: string;
export interface WebsiteProps {
readonly domainName?: string;
readonly logExpiration?: Duration;
readonly certificateArn?: string;
}

export class Website extends Construct {
Expand All @@ -27,11 +27,6 @@ export class Website extends Construct {

this.bucket.grantRead(oai);

let args = { ...props };
if (!props || props.logExpiration == undefined) {
args.logExpiration = Duration.days(14);
}

let distroProps: CloudFrontWebDistributionProps = {
errorConfigurations: [{
errorCode: 404,
Expand All @@ -44,7 +39,7 @@ export class Website extends Construct {
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
lifecycleRules: [{
enabled: true,
expiration: args.logExpiration,
expiration: (props && props.logExpiration) ? props.logExpiration : Duration.days(14),
}],
}),
prefix: 'website',
Expand All @@ -61,8 +56,8 @@ export class Website extends Construct {
],
};

if (args.domainName !== undefined && args.certificateArn !== undefined) {
distroProps = this.addViewerCertificate(distroProps, [args.domainName], args.certificateArn);
if (props && props.domainName !== undefined && props.certificateArn !== undefined) {
distroProps = this.addViewerCertificate(distroProps, [props.domainName], props.certificateArn);
}

this.distribution = new CloudFrontWebDistribution(this, `${id}-distribution`, distroProps);
Expand Down

0 comments on commit 831b940

Please sign in to comment.