Skip to main content

domains

Creates, updates, deletes, gets or lists a domains resource.

Overview

Namedomains
TypeResource
Idcloudflare.workers.domains

Fields

The following fields are returned by SELECT queries:

Get domain response.

NameDatatypeDescription
idstringImmutable ID of the domain. (example: dbe10b4bc17c295377eabd600e1787fd)
cert_idstring (uuid)ID of the TLS certificate issued for the domain. (example: 9fdf92c8-64c2-4a3d-b1af-e15304961145)
zone_idstringID of the zone containing the domain hostname. (example: 593c9c94de529bbbfaac7c53ced0447d, x-stainless-terraform-configurability: computed_optional)
zone_namestringName of the zone containing the domain hostname. (example: example.com, x-stainless-terraform-configurability: computed_optional)
environmentstringWorker environment associated with the domain. (example: production, x-stainless-terraform-configurability: computed_optional)
hostnamestringHostname of the domain. Can be either the zone apex or a subdomain of the zone. Requests to this hostname will be routed to the configured Worker. (example: app.example.com)
servicestringName of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. (example: my-worker)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, domain_idGets information about a domain.
listselectaccount_idzone_id, zone_name, service, hostname, environmentLists all domains for an account.
updatereplaceaccount_id, zone_id, zone_name, hostname, service, environmentAttaches a domain that routes traffic to a Worker.
deletedeleteaccount_id, domain_idDetaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
domain_idstring
environmentstring
hostnamestring
servicestring
zone_idstring
zone_namestring

SELECT examples

Gets information about a domain.

SELECT
id,
cert_id,
zone_id,
zone_name,
environment,
hostname,
service
FROM cloudflare.workers.domains
WHERE account_id = '{{ account_id }}' -- required
AND domain_id = '{{ domain_id }}' -- required
;

REPLACE examples

Attaches a domain that routes traffic to a Worker.

REPLACE cloudflare.workers.domains
SET
environment = '{{ environment }}',
hostname = '{{ hostname }}',
service = '{{ service }}',
zone_id = '{{ zone_id }}',
zone_name = '{{ zone_name }}'
WHERE
account_id = '{{ account_id }}' --required
AND zone_id = '{{ zone_id }}' --required
AND zone_name = '{{ zone_name }}' --required
AND hostname = '{{ hostname }}' --required
AND service = '{{ service }}' --required
AND environment = '{{ environment }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Detaches a domain from a Worker. Both the Worker and all of its previews are no longer routable using this domain.

DELETE FROM cloudflare.workers.domains
WHERE account_id = '{{ account_id }}' --required
AND domain_id = '{{ domain_id }}' --required
;