DEV Community

Discussion on: Host Static website using AWS CDK for Terraform and CloudFront: Part 2

Collapse
 
shotlom profile image
Sholto Maud • Edited

interesting articles - I get access denied on my url
Could you perhaps test your repo, because I think you may need to comment out the "Output the bucket url to access the website" section which fails when I try.

Collapse
 
thakkaryash94 profile image
Yash Thakkar

Yes, we need to comment out the bucket access url because we are not serving s3 bucket as a url anymore. That's why we printing CloudFront URL. I kept it for the part 1, but for part 2, we need to comment out the s3 bucket url and can only access using CloudFront URL.

Collapse
 
shotlom profile image
Sholto Maud

I get access denied on my url - how did you make sure your Cloudfront can have access to the S3? Also, do you Route53 for your dns?

Thread Thread
 
thakkaryash94 profile image
Yash Thakkar

We have setup CloudFront Origin Access Identity(OAI) and also updated the S3 bucket permission as below.
{
"AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${cloudfrontOriginAccessIdentity.id}"
}

So with this, only CloudFront will be able to access the bucket using OAI.