How to use the @aws-cdk/aws-cloudfront.CfnCloudFrontOriginAccessIdentity function in @aws-cdk/aws-cloudfront

To help you get started, we’ve selected a few @aws-cdk/aws-cloudfront examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jeshan / scale-your-cloudformation / lib / cdk-stack.js View on Github external
super(scope, 'scale-your-cloudformation');

        const domainName = 'scaleyourcloudformation.com';
        const cert = new Certificate(this, 'cert', {
            domainName,
            validationMethod: ValidationMethod.DNS,
        });

        const websiteBucket = new Bucket(this, 'WebsiteBucket', {
            domainName,
            removalPolicy: RemovalPolicy.DESTROY,
            websiteIndexDocument: 'index.html',
            websiteErrorDocument: 'error.html',
        });

        const originId = new CfnCloudFrontOriginAccessIdentity(
            this,
            'OriginAccessIdentity',
            {
                cloudFrontOriginAccessIdentityConfig: {
                    comment: `CloudFront OriginAccessIdentity for ${websiteBucket.bucketName}`,
                },
            },
        );

        websiteBucket.grantRead(
            new CanonicalUserPrincipal(originId.attrS3CanonicalUserId),
        );

        let s3OriginConfig = {
            originAccessIdentityId: originId.ref,
            s3BucketSource: websiteBucket,
github cloudcomponents / cdk-components / packages / cdk-static-website / src / website-bucket.ts View on Github external
bucketName,
            removalPolicy = RemovalPolicy.RETAIN,
            disableUpload = false,
            source,
            websiteIndexDocument,
            websiteErrorDocument,
        } = props;

        const bucket = new Bucket(this, 'WebsiteBucket', {
            bucketName,
            removalPolicy,
            websiteIndexDocument: websiteIndexDocument || 'index.html',
            websiteErrorDocument: websiteErrorDocument || 'error.html',
        });

        const originId = new CfnCloudFrontOriginAccessIdentity(
            this,
            'OriginAccessIdentity',
            {
                cloudFrontOriginAccessIdentityConfig: {
                    comment: `CloudFront OriginAccessIdentity for ${bucket.bucketName}`,
                },
            },
        );

        bucket.grantRead(
            new CanonicalUserPrincipal(originId.attrS3CanonicalUserId),
        );

        if (!disableUpload) {
            const placeHolderSource = path.join(__dirname, '..', 'website');