Created
March 20, 2022 02:40
-
-
Save JoshM1994/f7b0b64676eb346a9975cbba6e529bdb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cfDist = new cloudfront.CloudFrontWebDistribution(this, 'CfDistribution', { | |
comment: 'CDK Cloudfront Secure S3', | |
viewerCertificate: ViewerCertificate.fromAcmCertificate(cert, { | |
aliases: [DOMAIN_NAME, WWW_DOMAIN_NAME], | |
}), | |
defaultRootObject: ROOT_INDEX_FILE, | |
viewerProtocolPolicy: ViewerProtocolPolicy.REDIRECT_TO_HTTPS, | |
httpVersion: HttpVersion.HTTP2, | |
priceClass: PriceClass.PRICE_CLASS_100, // the cheapest | |
originConfigs: [ | |
{ | |
s3OriginSource: { | |
originAccessIdentity: accessIdentity, | |
s3BucketSource: siteBucket, | |
originPath: `/${PROD_FOLDER}`, | |
}, | |
behaviors: [ | |
{ | |
compress: true, | |
isDefaultBehavior: true, | |
}, | |
], | |
}, | |
], | |
// Allows React to handle all errors internally | |
errorConfigurations: [ | |
{ | |
errorCachingMinTtl: 300, // in seconds | |
errorCode: 403, | |
responseCode: 200, | |
responsePagePath: `/${ROOT_INDEX_FILE}`, | |
}, | |
{ | |
errorCachingMinTtl: 300, // in seconds | |
errorCode: 404, | |
responseCode: 200, | |
responsePagePath: `/${ROOT_INDEX_FILE}`, | |
}, | |
], | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment