Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 135 additions & 1 deletion src/content/docs/aws/services/route53.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import FeatureCoverage from "../../../../components/feature-coverage/FeatureCove
Route 53 is a highly scalable and reliable domain name system (DNS) web service provided by Amazon Web Services.
Route 53 allows you to register domain names, and associate them with IP addresses or other resources.
In addition to basic DNS functionality, Route 53 offers advanced features like health checks and DNS failover.
Route 53 integrates seamlessly with other AWS services, such as route traffic to CloudFront distributions, S3 buckets configured for static website hosting, EC2 instances, and more.
Route 53 integrates seamlessly with other AWS services, such as route traffic to CloudFront distributions, S3 buckets configured for static website hosting, Elastic Load Balancers, EC2 instances, and more.

LocalStack allows you to use the Route53 APIs in your local environment to create hosted zones and to manage DNS entries.
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Route53's integration with LocalStack.
LocalStack supports routing traffic to various AWS resources including [S3 static websites](#routing-to-s3-static-websites) and [Elastic Load Balancers](#routing-to-elastic-load-balancers) using alias records.
LocalStack also integrates with its DNS server to respond to DNS queries with these domains.

:::note
Expand Down Expand Up @@ -68,6 +69,139 @@ awslocal route53 change-resource-record-sets \
}
```

## Routing traffic to AWS resources

LocalStack Route53 supports routing traffic to various AWS resources using alias records. This allows you to point your domain names directly to AWS services without managing IP addresses.

### Routing to S3 static websites

You can route traffic from a Route53 domain to an S3 bucket configured for static website hosting using alias records. This is useful when you want to serve a static website with a custom domain name.

#### Create an S3 bucket with website hosting
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really an issue with your doc per se, but we may want to fix styling of H4 elements, because they are currently the same as H3. However, maybe there is a way to restructure this doc so that it only goes to H3? The reason is that H4 elements do not appear in the right hand page nav.

Copy link
Collaborator

@quetzalliwrites quetzalliwrites Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look at this, the only way he can restructure this doc is if he removed this h2 section:

## Routing traffic to AWS resources
LocalStack Route53 supports routing traffic to various AWS resources using alias records. This allows you to point your domain names directly to AWS services without managing IP addresses.

Then, he could turn both Routing to S3 static websites and Routing to Elastic Load Balancers into h2.

I am also ok with this doc as is, I do not consider the h4 styling problem a blocker for this content. (We could log a ticket to address the h4 styling issue.) But I also get Brian's point, there's always the argument about whether content can be improved/rewritten so that it's not necessary to go 4 levels. 😸


First, create an S3 bucket and configure it for static website hosting. Run the following commands:

```bash
DOMAIN="example.com"
BUCKET_NAME="$DOMAIN"

# Create the bucket
awslocal s3api create-bucket --bucket "$BUCKET_NAME"

# Upload your website files
awslocal s3 cp index.html s3://$BUCKET_NAME/
awslocal s3 cp error.html s3://$BUCKET_NAME/

# Configure the bucket for website hosting
awslocal s3 website s3://"$BUCKET_NAME"/ \
--index-document index.html \
--error-document error.html

# Set bucket policy to allow public read access
awslocal s3api put-bucket-policy \
--bucket $BUCKET_NAME \
--policy '{
"Version": "2012-10-17",
"Statement": [{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::'$BUCKET_NAME'/*"
}]
}'
```

#### Create a Route53 alias record

Now create a hosted zone and an alias record that points to the S3 website endpoint:

```bash
# Create the hosted zone
HOSTED_ZONE_ID=$(awslocal route53 create-hosted-zone \
--name "$DOMAIN" \
--caller-reference "$(date +%s)" \
--output text \
--query 'HostedZone.Id' | cut -d'/' -f3)

echo "Hosted Zone created with ID: $HOSTED_ZONE_ID"

# Create an alias record pointing to the S3 website endpoint
awslocal route53 change-resource-record-sets \
--hosted-zone-id "$HOSTED_ZONE_ID" \
--change-batch '{
"Comment": "Create alias record for S3 static website",
"Changes": [{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "'$DOMAIN'",
"Type": "A",
"AliasTarget": {
"HostedZoneId": "'$HOSTED_ZONE_ID'",
"DNSName": "'$BUCKET_NAME'.s3-website.localhost.localstack.cloud",
"EvaluateTargetHealth": false
}
}
}]
}'
```

The key points for S3 website alias records are:

- The `DNSName` follows the format: `<bucket-name>.s3-website.localhost.localstack.cloud`
- The `Type` must be `A` (for IPv4) or `AAAA` (for IPv6)
- Set `EvaluateTargetHealth` to `false` for S3 website endpoints

#### Verify DNS resolution

You can verify that your domain resolves to the S3 website using [DNS resolution](#dns-resolution) or by making HTTP requests:

```bash
# Using dig to verify DNS resolution
dig @localhost $DOMAIN

# Using curl to access the website
curl http://$DOMAIN:4566/
```

### Routing to Elastic Load Balancers

You can also route traffic to Elastic Load Balancers (ELB) using alias records. This is commonly used for distributing traffic across multiple instances.

#### Create an alias record for ELB

After creating your load balancer, you can create an alias record that points to it:

```bash
# Assuming you have an ELB with DNS name
ELB_DNS_NAME="my-load-balancer-123456.elb.localhost.localstack.cloud"

# Create an alias record pointing to the ELB
awslocal route53 change-resource-record-sets \
--hosted-zone-id "$HOSTED_ZONE_ID" \
--change-batch '{
"Comment": "Create alias record for ELB",
"Changes": [{
"Action": "CREATE",
"ResourceRecordSet": {
"Name": "app.example.com",
"Type": "A",
"AliasTarget": {
"HostedZoneId": "'$HOSTED_ZONE_ID'",
"DNSName": "'$ELB_DNS_NAME'",
"EvaluateTargetHealth": true
}
}
}]
}'
```

For ELB alias records:

- Use the load balancer's DNS name as the `DNSName` value
- You can set `EvaluateTargetHealth` to `true` to enable health checks
- The `Type` should be `A` for IPv4 addresses

## DNS resolution

LocalStack Pro supports the ability to respond to DNS queries for your Route53 domain names, with our [integrated DNS server](/aws/tooling/dns-server).
Expand Down