Skip to content

Instantly share code, notes, and snippets.

@AndrewBestbier
Created May 19, 2020 12:04
Show Gist options
  • Save AndrewBestbier/8948c444bed66d43b17d605cadbd3382 to your computer and use it in GitHub Desktop.
Save AndrewBestbier/8948c444bed66d43b17d605cadbd3382 to your computer and use it in GitHub Desktop.
import * as cdk from '@aws-cdk/core';
import * as s3 from '@aws-cdk/aws-s3';
import * as cloudfront from '@aws-cdk/aws-cloudfront';
export class InfrastructureStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const bucket = new s3.Bucket(this, 'WebsiteBucket', {
bucketName: 'andrew-bestbier-cdk-blog',
websiteIndexDocument: 'index.html',
});
const cloudFrontOAI = new cloudfront.OriginAccessIdentity(this, 'OAI');
bucket.grantRead(cloudFrontOAI.grantPrincipal);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment