"The specified key does not exist" while creating CloudFront distribution - amazon-web-services

I have created an s3 bucket and uploaded an image in it. My s3 url is working and fine but when I try this with cloudfront url it shows me this error.
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>s3://avanish2302/justice.jpg/</Key>
<RequestId>B8BF8D5981519FF9</RequestId>
<HostId>RQ2CwxcujOp648JZD9dg6HD/4DVOtEs7/sJ86qWvR0oVfQn7FtAzH0+XN7mwwtwEdOriOJQ/V6w=</HostId>
</Error>
I have tried copying the object path from the s3 and pasted in the object path while creating cloudfront.
Its strange that when I tried it before using the same steps, it used to work fine but now when I follow the same steps, it shows me this error.
My s3 bucket and object are set to public. Does anyone have this problem?

They key should not have s3:// in front of it. You configured that as your origin already. The key is location of the file in the bucket (justice.jpg, no trailing slash). Also, see this https://www.fernandomc.com/posts/amazon-s3-static-sites-and-cloudfront-configuration/

Related

Error in object URL of static website in S3 bucket: Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature

I have created a static website in an S3 bucket AWS. I have created two files in bucket one in index.html and 2nd is error.html. When I open index.html and click on object URL in AWS it gives below error:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>InvalidArgument</Code>
<Message>Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4.</Message>
<ArgumentName>Authorization</ArgumentName>
<ArgumentValue>null</ArgumentValue>
<RequestId>R69TKNDJTYZ8E0SW</RequestId>
<HostId>OAOZKRsA6ATOgH6jBr5jO1fS0zi+GSh4at34nLq8V/Ug8Icvuy8c6NOlCoNqqjpBcORg8bDlzJ0=</HostId>
</Error>
I have checked every possible solution but nothing works. My bucket has public access like below my bucket name it is written in red Publicly accessible. But still I could not find what is issue.

Unable to access S3 objects via Cloudfront URL

I am unable to access S3 objects and Bucket via cloud front URL.
I have created CLOUDFRONT Distribution ( Web ) and setup origin path to media folder in my S3 bucket. ( /media)
CF url is pointing to bucket/media , but i am unable to access it from my web application as well as browser.
I am trying to access like below:
http://d1xdpXXXXX.cloudfront.net/media/images/Tiger.jpg
Tiger.jpg can be accessed via s3 url.
I also tried http://d1xdpXXXXX.cloudfront.net but i am getting below error:
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>d1xdpwiqgrffrd.cloudfront.net</BucketName>
<RequestId>484BBB2F7907172F</RequestId>
<HostId>+bLr4Qx+uawbq4YNIOuKGCQVDGQQQsifGnNt9J5Pn+r3mqbDiVYcpNZRUfnCyPnHxewfMVp3QYc=</HostId>
</Error>
Please help.
CF Distribution settings
Access denied error
You have already added the path in cloudfront origin.
So, you don't have to add that in cloudfront url you are using to download.
Just use
http://d1xdpXXXXX.cloudfront.net/images/Tiger.jpg
as /media is already part of the distribution.

AWS Cloudfront can't access S3 files deployed with CodeBuild

I'm working on getting a static website deployed with AWS Codebuild, hosted in an S3 bucket, and accessed via Cloudfront. Everything seems to work except from accessing from Cloudfront. From Cloudfront, I can access files that I manually upload, and using the bucket URL, I can access all the files. Looking through the individual file settings/permissions, they all look to be the same, regardless of whether they were manually uploaded, or deployed via Codebuild. I've tried invalidating the Cloudfront cache, and re-deployed via Codebuild several times.
Additional Information:
I provided the S3 bucket as an origin when setting up the Cloudfront distribution.
Accessing via Cloudfront gives the following error:
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>0211CBE618946F</RequestId>
<HostId>
7sRZhaJS4x2W7Iaeo4y8KAjvsOJcNWh3PxCdgnhXPE22oyp1RxZhwpjrqbsWapsUSaqBK+jqE=
</HostId>
</Error>
What else should I check?
For some reason, adding a default root object fixed the issue.
FWIW, I initially changed the value to dist/index.html, which allowed me to access the deployed bucket contents via the Cloudfront URL, but required the index.html suffix. Once I changed it to index.html, everything worked fine.

GCP static website returns Error: NoSuchBucket

I created a GCP storage bucket named for a domain managed by Google Domains. I have uploaded the files, created a CNAME record for c.storage.googleapis.com, and changed the ACLs to public-read. However, I'm still getting the error:
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist.</Message>
</Error>
Note that I wasn't asked to verify the domain when I created the bucket. I assume this is normal for a domain managed by Google Domains as it says "automatically verified."
I'm not sure how to debug this issue.
I got it. I just needed to add www. to the beginning of the bucket name.
In other words:
www.domain.com instead of domain.com

Cloudfront url synchronized with s3 path

I was using s3 for for my static websites, we had three websites/paths in s3:
example.com
example.com/website1
example.com/website2
Website1 and Website2 were folders inside the bucket example.com as expected. But now we need https urls so we decided to go with aws cloudfront for the redirects. Cloudfront generated for example a url like this, https://123455678.cloudfront.net .
When I navigate to the url, it gets the example.com correctly, but when I try to put like https://123455678.cloudfront.net/website1 it seems like its not entering the /website1 path in the s3. So it gives me this error because it's not finding the index.html inside the /website1 path.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>C5259E1658595A69</RequestId>
<HostId>
B1HYQsr0Xv4M1avKlJ3G8t0rkVfCvbOoJadxm5z1BwapblBeERm3c6Ni+jZWxB8FlXEaF6bUAik=
</HostId>
</Error>
I guess I have to do something in the origins and behaviours of my cloudfront distribution, but I can't figure out what to do there...
I fixed my problem by changing the origin domain name in my cloudfront distribution to my s3 bucket endpoint, located in the properties of my bucket in Static Website Hosting area.
Saved, waited for cloudfront to use the updated changes and it worked. Also my Default Root Object is set to index.html .
Hope it helps someone =)