AWS Route53 + S3 static website gives an error: alias target name does not lie within the target zone - amazon-web-services

I have registered a domain using Route53 and created a S3 bucket for my website.
Assume the following:
Route53 hosted zone is: domain.com
S3 bucket name is: staging.domain.com
Using the Route53 console I then attempted to create new record to point to my S3 bucket with the following settings:
Record name: staging.domain.com
Value/Route traffic to: Alias to S3 website endpoint
Region: (from drop-down) Africa(Cape Town)[af-south-1]
Choose S3 bucket: (from drop-down) s3-website.af-south-1.amazonaws.com (staging.domain.com)
Record type: A
After clicking on create records I am greeted with the following error:
**Error occurred
Bad request.**
(InvalidChangeBatch 400: Tried to create an alias that targets s3-website.af-south-1.amazonaws.com., type A in zone Z11KHD8FBVPUYU, but the alias target name does not lie within the target zone)
In my mind the alias target is supposed to be staging.domain.com.s3-website.af-south-1.amazonaws.com
not s3-website.af-south-1.amazonaws.com
For completeness sake I have 2 other A records listed on this domain:
dev.domain.com -> Pointing to an EC2 instance (working)
test.domain.com -> Pointing to a CloudFront distribution (working)
Any idea why this is happening or how it can be corrected?

I think drop down you are getting is correct.
See this screenshot :
New Console UI has different feature. First you have to select as region then bucket selection.
Check if you are following same seeting then you should not get error. Also one more check whether S3 bucket is enable for website hosting or not.

Related

CloudFront: The specified bucket does not exist

I have a static website hosted on S3 which works fine when accessed through my bucket's endpoint. However, when I create a CloudFront distribution and try access it through using the CloudFront domain I keep getting the error below.
d1xu3mknlk0sbd.cloudfront.net
Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName: d1xu3mknlk0sbd.cloudfront.net
RequestId: 656B653A2ED5B2B1
HostId: 9etNAX1XEJmbVKUAMylBDz3xEky+7RhAnr9b8HhpkIb9+pkMnn920v/MSAUjr78oyONEUdlba50=
I have set up my CloudFront origin domain name to the s3 url of my static site which works when I type it in the browser so why can't CloudFront find the bucket ...
Ended up solving this by changing my s3 bucket name from 'sample' to 'www.sample.com' .Strangely CloudFront started resolving the correct bucket name. Why this works remains a mystery ...

www.topstonesoftware.com is not forwarding to topstonesoftware.com on AWS static web site

I've been trying to follow the directions on the AWS page
Example: Setting up a Static Website Using a Custom Domain
I have created two S3 buckets: topstonesoftware.com and www.topstonesoftware.com. The www bucket forwards to the topstonesoftware.com bucket
I've made the Amazon Route 53 entries (see below).
For reasons that I don't understand, http://topstonesoftware.com works, but http://www.topstonesoftware.com doesn't work (e.g., entering www.topstonesoftware.com just hangs the browser and never resolves the DNS).
When I run "dig" (dig www.topstonesoftware.com) it reports that there is no error in the DNS lookup. Dig also shows the DNS query resolving to the S3 bucket for www.topstonesoftware.com:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 47363
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;www.topstonesoftware.com. IN A
;; ANSWER SECTION:
www.topstonesoftware.com. 300 IN CNAME www.topstonesoftware.com.s3-website-us-east-1.amazonaws.com.
www.topstonesoftware.com.s3-website-us-east-1.amazonaws.com. 60 IN CNAME s3-website-us-east-1.amazonaws.com.
s3-website-us-east-1.amazonaws.com. 5 IN A 52.216.17.170
I've read thought Stackoverflow and the Amazon documentation, but so far, no joy.
Here's the DNS. The alias record is for topstonesoftware.com and is the alias to the S3 bucket. The CNAME record details are shown.
Many thanks in advance.
If you review the AWS documentation from your link you will notice that the docs are using Type A - ALIAS. You are using a CNAME. Change your www entry to use Type A - ALIAS and select the correct S3 website endpoint. Sometimes it takes a minute or two to populate the drop down list.
When you create the www.example.com bucket that is paired with your example.com bucket on AWS S3, create the www.example.com bucket with public permissions. Do not add the JSON permission record that you added for the example.com bucket. For some reason, this messes up access.
When I removed my www.topstonesoftware.com bucket and recreated it with public permissions and added forwarding to topstonesoftware.com, the www.topstonesoftware.com subdomain started to work.
As noted above, a CNAME record is not needed and may, in fact, be counter productive.

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

aws - browse to website - 404 not found - no such bucket

I have created a record set for my webiste volcalc.io and www.volcalc.io which is stored in an s3 bucket.
When I try to browse to the website I see this error:
404 Not Found
Code: NoSuchBucket
Message: The specified bucket does not exist
BucketName: volcalc.io
RequestId: xxx
HostId: xxx
The bucket name is www.volcalc.io, not volcalc.io
How do I change it to make it look for bucket named www.volcalc.io?
See Setting Up a Static Website Using a Custom Domain.
To allow requests for both example.com and www.example.com, you need to create two buckets even though you will host content in only one of them. You will need to configure the other bucket to redirect requests to the bucket that hosts the content.

CNAME to s3 bucket amazon

I would like to use a subdomain instead of the direct url to my s3 bucket at amazon.com. So instead of downloading images via an url like http://bucket-images.s3-eu-west-1.amazonaws.com/path/to/image.pngI would like to use http://assets.domain.com/path/to/image.png. I tried setting a CNAME like this:
CNAME assets domain.com bucket-images.s3-eu-west-1.amazonaws.com
But after setting this CNAME I receive such error from amazon, when I visit the domain:
<Error>
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>assets.domain.com</BucketName>
<RequestId>45646DFSDFSFASDF</RequestId>
<HostId>
dfasdcvcvd546456454ds5fasdf4ad5f64asdfasdfccdfgvggtg
</HostId>
</Error>
Over here they're telling to change the bucketname: https://forums.aws.amazon.com/message.jspa?messageID=237562
But that doesn't make sense. I worked on a project earlier, who used a bucketname totally different from the subdomain. So there has to be a way... Anyone who can help me out?
For S3 you need the CNAME and bucket name to match:
The bucket name must be the same as the CNAME. So http://images.johnsmith.net/filename would be the same as http://images.johnsmith.net.s3.amazonaws.com/filename if a CNAME were created to map images.johnsmith.net to images.johnsmith.net.s3.amazonaws.com
So in your specific example you need to name the bucket assets.domain.com.
http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#VirtualHostingCustomURLs
If you need more flexibility, you can create a CloudFront distribution for your S3 bucket and assign a CNAME to your CloudFront distribution.
http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html
Addtional to #Samuel Neff's information:
Just remember to name your AWS S3 bucket same as your Cloudflare CNAME record. Otherwise it will not work.
Here I tried and worked for me:
Converted
https://s3-eu-west-2.amazonaws.com/cdn.domain.com
to
http://cdn.domain.com