0

I have a React-website running on a CloudFront, hosted in a S3 bucket. The website has been working properly for a long period, but now I've updated it, and then it kept showing the old site, until i reload the page - then the new one will show.

To fix this, I tried to invalidate some of the files, as I thought it was a cache thing. Here's what I invalidated: enter image description here

After doing this, my website now shows a blank page the first time it loads - in the developer console it gives me this: enter image description here

So now it seems like I cant reach the files (Failed to load resource: the server responded with a status of 403 ()). The thing is, that if I reload the page, the right site will show.. So I'm a little confused.. I tried to change the bucketpermissions to this:

{
    "Version": "2008-10-17",
    "Statement": [
        {
            "Sid": "Allow Public Access to All Objects",
            "Effect": "Allow",
            "Principal": {
                "AWS": "*"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my.bucket.name/*"
        }
    ]
}
  • with the right bucketname obviously :-)

Maybe the permissions will take long time to have an effect? It's just strange that the old website worked as expected, until I updated the files..

Anyone has an idea of a fix?

Have a lovely day :-)

Update: Here's an image of the network tab from chrome, when loading the page: enter image description here

Nicolai Harbo
  • 1,064
  • 12
  • 25
  • Permission changes don't take much time so it shouldn't be the cause. Also after running the invalidation it return the latest index.html and static paths. If you go to network tab in chrome, are all the assets shows not found error? – Ashan Sep 20 '17 at 09:16
  • Thanks for taking time to answer @Ashan - I cant add images here, so I've updated the question with an image of the network tab :-) – Nicolai Harbo Sep 20 '17 at 11:22
  • You may also need to invalidate the path `/`. – Michael - sqlbot Sep 20 '17 at 12:38
  • If I've mischaracterized this as a duplicate, this question can be reopened, with my apologies. Please advise. I intended only to cast a "possible duplicate" vote but my [tag:amazon-s3] reputation score converted it to a unilateral close. – Michael - sqlbot Sep 20 '17 at 12:43
  • Sorry, I'm not sure if I understand what you mean :) But if there's a question about this already, then I would like a link to the answeret thread :) - Although, I think I found a solution to the problem - or, at least to my own problem.. I created a new bucket, the same way as the first one, and then I changed the origin in cloudfront, to the origin the bucket gives me in "static website hosting" .. :) Not sure if this is a proper solution, but it works.. :) – Nicolai Harbo Sep 20 '17 at 12:51
  • So here's the solution that worked for me: I found out that the auto-populated origin field in CloudFront for my S3 bucket wasn't the website endpoint. To fix, copy the website endpoint URL from S3 and is that as the CF origin. Example: example.com.s3.amazonaws.com example.com.s3-website-us-east-1.amazonaws.com – Nicolai Harbo Sep 20 '17 at 12:54

0 Answers0