Point a name at a resource
Answer a name, the zone apex included, with the current address of one of your apps, load balancers, bucket websites or CDN distributions, using an ALIAS record.
An ALIAS record has no values of its own: the nameservers answer it with the address of its
target as it is now, so nobody updates the record when the target moves. Unlike a CNAME, it works
at the apex. Replace zone-id with the id of your hosted zone.
What each target answers
| Target | Answer |
|---|---|
| App | A: the address the app is served on (its load balancer's IPv4, or its machine's public address). Nothing while the app is being deleted. |
| Load balancer | A with its IPv4 and AAAA with its IPv6. |
| Bucket website | The addresses the static websites of buckets are served on. The name is added to the bucket's website domains. |
| CDN distribution | A and AAAA of the distribution's healthy edge nodes, with a TTL of at most 30 seconds. List the name among the distribution's custom names too, or it gets no certificate. |
A target that has no address yet leaves the name existing but without an answer. When the target is
deleted, the ALIAS record is deleted with it.
Records the platform writes for you
- Adding a custom domain to an app, when the domain is inside one of your hosted zones, writes an
ALIASto the app at that name (TTL 60). The app's domains panel then says "Answered by your hosted zone …, nothing to create". A domain added before its zone existed has no record: the panel names theALIASto add, or remove and re-add the domain. - Adding a custom domain to a bucket website inside one of your zones writes an
ALIASto the bucket, when the name has no other records. - Adding a custom name to a CDN distribution inside one of your zones writes an
ALIASwhen the name is the apex and has no other address records, or aCNAMEwhen the name is below the apex and has no other records.
Prerequisites
- Permission for
dns:ChangeRecordson the zone. Without it, Add record is unavailable. - In the console, also
dns:ListZonesto open Hosted zones (without it the page shows an access-denied notice) anddns:GetZoneto open the zone (without it the zone's page is not found), and, to see the targets,deploy:DescribeApp(apps),lb:DescribeLoadBalancers,s3:ListBucketsorcdn:ListDistributions. Withoutdeploy:DescribeAppand no other target, the dialog says "An ALIAS points at a deployed app, and listing this organization’s apps needs deploy:DescribeApp. Ask an administrator, or choose another record type." - The target exists in your organization.
Add the ALIAS record
- Open the zone. On the Records tab, choose Add record.
- For Name, enter
@for the apex, or a name such as www. - For Type, choose ALIAS.
- For Points at, choose the app, load balancer, bucket website or CDN distribution.
- Choose Add.
The table shows the record's value as "→" and the target.
dcloud dns records set zone-id --name @ --type ALIAS --load-balancer-id lb-idUse --app-id, --bucket (a bucket name) or --distribution-id for the other targets.
POST /dns/api/zones/zone-id/records
{ "name": "@", "type": "ALIAS", "loadBalancerId": "6f1d2c3b-4a5e-4f60-8a7b-9c0d1e2f3a4b" }Send exactly one of appId, loadBalancerId, bucket or distributionId, and no values.
resource "dcloud_dns_record" "apex" {
zone_id = dcloud_dns_zone.main.id
name = "@"
type = "ALIAS"
load_balancer_id = dcloud_lb.web.id
}Or app_id, bucket or distribution_id.
To point an existing ALIAS at another target, edit it and choose another Points at, or send
the new target to PUT /dns/api/zones/{id}/records/{recordId}.
When the record is refused
All with 400:
- "An ALIAS record points at exactly one of: an app, a load balancer, a bucket website, a CDN distribution" when you send none or more than one target.
- "App not found", "Load balancer not found", "Bucket not found" or "Distribution not found".
- "www.example.com is already the domain of another bucket's website".
- "A health check goes on an A, AAAA or CNAME record; an ALIAS follows its target".
- "An ALIAS follows its target and cannot be routed".