1

I have got my hosted zone exmple.com. I also created the s3 bucket example-photos for storing my photos. Normally, photos in s3 bucket are available under the following url https://example-photos.s3.eu-central-1.amazonaws.com/photo1.png However, I would like to create a subdomain bucket.example.com and let the photos from example-photos bucket be available under the subdomain url like https://bucket.example.com/photo1.png

What record should I create in Route 53 then?

  • Did you follow the instructions on [Tutorial: Configuring a static website using a custom domain registered with Route 53 - Amazon Simple Storage Service](https://docs.aws.amazon.com/AmazonS3/latest/userguide/website-hosting-custom-domain-walkthrough.html)? For a start, the bucket needs the same name as the domain. – John Rotenstein Feb 27 '23 at 23:19

1 Answers1

0

To make your photos in the S3 bucket available under the subdomain URL, you need to create a CNAME record in Route 53 that points the subdomain to the endpoint of your S3 bucket. The CNAME record tells Route 53 to resolve the subdomain to the S3 endpoint, allowing you to access your photos at the subdomain URL.

{
    "Comment": "CNAME record for S3 bucket",
    "Changes": [
        {
            "Action": "CREATE",
            "ResourceRecordSet": {
                "Name": "bucket.example.com",
                "Type": "CNAME",
                "TTL": 300,
                "ResourceRecords": [
                    {
                        "Value": "example-photos.s3.eu-central-1.amazonaws.com"
                    }
                ]
            }
        }
    ]
}

aws route53 change-resource-record-sets --hosted-zone-id YOUR_HOSTED_ZONE_ID --change-batch file://recordset.json

  • I got the error ` NoSuchBucket The specified bucket does not exist ` when trying to open `bucket.example.com` page. My bucket is public btw – user123145152323 Feb 27 '23 at 19:15
  • 1
    @user123145152323 Check out this [answer](https://stackoverflow.com/questions/34316277/cname-to-s3-bucket-amazon). This is your case. I hope it helps. Thank you – edhar.rybak Feb 28 '23 at 14:52