Fork me on GitHub

Hi everyone. I have an issue with an existing static website on S3 fronted by CloudFront. I’m migrating it to use CDK for deployment. I redirect www to apex domain, so I have both and buckets set up, and the www one redirects to the apex address. This all worked fine when set up manually but when deploying via CDK I get AccessDenied errors when accessing the www address. The apex one works fine.


Tangent: we switched from an s3 hosted website to Netlify and it's fantastic. Big win over s3.


I looked at Netlify, but I’d also have to migrate my lambda functions, Dynamo DB etc, it would end up being a pretty big rewrite. CDK actually makes AWS much more palatable once all the bits are figured out.


Plus I’m increasingly reluctant to build infrastructure on venture-backed startups. At least I know AWS isn’t going anywhere.


Haha that's fair. For us it's simply static website hosting -- no code changes needed. Switching Netlify <-> S3 would take no time at all. The automatic build previews and rollback features are fantastic.


Yeah, I’ve heard nice things about Netlify from a few people now.


The s3 bucket endpoint address looks like If I hit that address manually it works fine. However looking at the CloudFront configuration, the origin is being set up using an address like - previously when I set CloudFront up by hand I used the endpoint address from the S3 console, and it all worked ok.


Actually, the origin address seems to be a red herring. The issue seems to be that the bucket is being treated as a content bucket even though the console says it’s configured to redirect all requests. But this only happens when I access it via CloudFront. Directly hitting the endpoint URL works.


Ok, TIL that S3 has a website mode and a REST mode, and that the REST mode doesn’t do website-like things such as redirects: