domains
Creates, updates, deletes, gets or lists a domains resource.
Overview
| Name | domains |
| Type | Resource |
| Id | cloudflare.workers.domains |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get domain response.
| Name | Datatype | Description |
|---|---|---|
id | string | Immutable ID of the domain. (example: dbe10b4bc17c295377eabd600e1787fd) |
cert_id | string (uuid) | ID of the TLS certificate issued for the domain. (example: 9fdf92c8-64c2-4a3d-b1af-e15304961145) |
zone_id | string | ID of the zone containing the domain hostname. (example: 593c9c94de529bbbfaac7c53ced0447d, x-stainless-terraform-configurability: computed_optional) |
zone_name | string | Name of the zone containing the domain hostname. (example: example.com, x-stainless-terraform-configurability: computed_optional) |
environment | string | Worker environment associated with the domain. (example: production, x-stainless-terraform-configurability: computed_optional) |
hostname | string | Hostname 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) |
service | string | Name of the Worker associated with the domain. Requests to the configured hostname will be routed to this Worker. (example: my-worker) |
List domains response.
| Name | Datatype | Description |
|---|---|---|
id | string | Immutable ID of the domain. (example: dbe10b4bc17c295377eabd600e1787fd) |
cert_id | string (uuid) | ID of the TLS certificate issued for the domain. (example: 9fdf92c8-64c2-4a3d-b1af-e15304961145) |
zone_id | string | ID of the zone containing the domain hostname. (example: 593c9c94de529bbbfaac7c53ced0447d, x-stainless-terraform-configurability: computed_optional) |
zone_name | string | Name of the zone containing the domain hostname. (example: example.com, x-stainless-terraform-configurability: computed_optional) |
environment | string | Worker environment associated with the domain. (example: production, x-stainless-terraform-configurability: computed_optional) |
hostname | string | Hostname 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) |
service | string | Name 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:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | account_id, domain_id | Gets information about a domain. | |
list | select | account_id | zone_id, zone_name, service, hostname, environment | Lists all domains for an account. |
update | replace | account_id, zone_id, zone_name, hostname, service, environment | Attaches a domain that routes traffic to a Worker. | |
delete | delete | account_id, domain_id | Detaches 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.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
domain_id | string | |
environment | string | |
hostname | string | |
service | string | |
zone_id | string | |
zone_name | string |
SELECT examples
- get
- list
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
;
Lists all domains for an account.
SELECT
id,
cert_id,
zone_id,
zone_name,
environment,
hostname,
service
FROM cloudflare.workers.domains
WHERE account_id = '{{ account_id }}' -- required
AND zone_id = '{{ zone_id }}'
AND zone_name = '{{ zone_name }}'
AND service = '{{ service }}'
AND hostname = '{{ hostname }}'
AND environment = '{{ environment }}'
;
REPLACE examples
- update
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
- delete
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
;