Questions tagged with Amazon Simple Storage Service

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

CORs Error from s3 Static pages

We are serving React Javascript static pages from an s3 bucket. The bucket has set CORs permissions to allow for api calls to two different api-gateway HTTP endpoints. ``` [ { "AllowedHeaders": [ "api-key" ], "AllowedMethods": [ "GET", "POST", "PUT", "DELETE", "HEAD" ], "AllowedOrigins": [ "http://*", "https://rest-api.com", "https://http-api.com" ], "ExposeHeaders": [ "Access-Control-Allow-Origin" ] } ] ``` In the HTTP API We have CORs enabled: ![Enter image description here](/media/postImages/original/IM_EcnFa_WSU63Bwu_k6zU7w) I can run the API and frontend locally - make the call the HTTP API to upload the file and it works, but when the files are hosted in s3 we get the error. ![Enter image description here](/media/postImages/original/IMl4CGJszJT52n54Ys-_cgxQ) THe call isn't even making it to the lambda function because its not getting logged in Cloudwatch, and the only information getting logged to Cloudwatch from the HTTP API is a 500 error but no reason is given. I do have an `OPTIONS` method specified on this specific endpoint with a lambda integration. ![Enter image description here](/media/postImages/original/IMA22Ya2uGS-6-2COkQUODhg) And this stage (`test`) is set up for autodeployments. Even though its not reaching the lamda - we are handling the options request there: ``` try { if (event.routeKey.includes('OPTIONS')) { return { statusCode: 200, headers: { "Access-Control-Allow-Headers" : "*", "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "OPTIONS,POST" } }; } ``` I must be overlooking something. TIA
0
answers
0
votes
3
views
asked 5 hours ago

Get AccessDenied from all sub-paths using Cloudfront with S3 Origin and Access Control

First of all I have several static sites setup like this and only one is having problems, so I've been trying to compare what differs but I cannot find anything. But let's focus on the one that isn't working, blog.mastodon.se. Any sub-path like /om gets an AccessDenied error. There is a file called /om/index.html that is supposed to be loaded. Another static site I have called sydit.se has the same setup and works fine. If you for example go to sydit.se/about. The blog.mastodon.se CloudFront distro is setup with mostly defaults, only added a Certificate from ACM, index.html as default root object, use only North American and European price class. Under origins I've chosen the S3 endpoint that is listed by default (blog.mastodon.se.s3.eu-north-1.amazonaws.com), Origin access control, and I've installed this bucket policy in the bucket. ``` { "Version": "2008-10-17", "Id": "PolicyForCloudFrontPrivateContent", "Statement": [ { "Sid": "AllowCloudFrontServicePrincipal", "Effect": "Allow", "Principal": { "Service": "cloudfront.amazonaws.com" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::blog.mastodon.se/*", "Condition": { "StringEquals": { "AWS:SourceArn": "arn:aws:cloudfront::redact:distribution/redact" } } } ] } ``` The bucket itself is also default, no static site hosting enabled, no public access, just this policy.
2
answers
0
votes
15
views
stemid
asked 3 days ago