Fork me on GitHub
#aws
<
2020-01-06
>
cfleming00:01:47

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 http://domain.com and http://www.domain.com 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.

kenny02:01:40

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

cfleming02:01:44

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.

cfleming02:01:25

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

kenny19:01:22

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.

cfleming20:01:14

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

cfleming00:01:56

The s3 bucket endpoint address looks like http://www.domain.com.s3-website-us-east-1.amazonaws.com. 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 http://www.domain.com.s3.us-east-1.amazonaws.com - previously when I set CloudFront up by hand I used the endpoint address from the S3 console, and it all worked ok.

cfleming01:01:20

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.

cfleming01:01:55

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: https://stackoverflow.com/a/22750923