Created
July 18, 2019 21:02
-
-
Save lampidudelj/d7aa227c3c53d8ae3499a0bb911f4f22 to your computer and use it in GitHub Desktop.
aws-cdk with s3 and cloudfront distribution
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
import cdk = require('@aws-cdk/core'); | |
import s3 = require('@aws-cdk/aws-s3'); | |
import cloudfront = require('@aws-cdk/aws-cloudfront'); | |
export class AwsCdkStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
const s3Bucket = new s3.Bucket(this, 'host-bucket', { | |
bucketName: `react-host-bucket-9f7317d0dd7c`, | |
websiteIndexDocument: 'index.html', | |
websiteErrorDocument: 'error.html', | |
publicReadAccess: true | |
}); | |
const distribution = new cloudfront.CloudFrontWebDistribution(this, 'my-distribution', { | |
originConfigs: [ | |
{ | |
s3OriginSource: { | |
s3BucketSource: s3Bucket | |
}, | |
behaviors : [ {isDefaultBehavior: true}] | |
} | |
], | |
defaultRootObject: 'index.html' | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment