cloudflared
Creates, updates, deletes, gets or lists a cloudflared resource.
Overview
| Name | cloudflared |
| Type | Resource |
| Id | cloudflare.zero_trust.cloudflared |
Fields
The following fields are returned by SELECT queries:
- get
- list
Get a Cloudflare Tunnel response
| Name | Datatype | Description |
|---|---|---|
id | string (uuid) | UUID of the tunnel. (example: f70ff985-a4ef-4643-bbbc-4a0ed4fc8415) |
name | string | A user-friendly name for a tunnel. (example: blog) |
account_tag | string | Cloudflare account ID (example: 699d98642c564d2e855e9661899b7252) |
config_src | string | Indicates if this is a locally or remotely configured tunnel. If local, manage the tunnel using a YAML file on the origin machine. If cloudflare, manage the tunnel on the Zero Trust dashboard. (local, cloudflare) (default: local, example: cloudflare) |
connections | array | The Cloudflare Tunnel connections between your origin and Cloudflare's edge. (x-stainless-deprecation-message: This field will start returning an empty array. To fetch the connections of a given tunnel, please use the dedicated endpoint /accounts/{account_id}/{tunnel_type}/{tunnel_id}/connections) |
conns_active_at | string (date-time) | Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If null, the tunnel is inactive. (example: 2009-11-10T23:00:00Z) |
conns_inactive_at | string (date-time) | Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If null, the tunnel is active. (example: 2009-11-10T23:00:00Z) |
created_at | string (date-time) | Timestamp of when the resource was created. (example: 2021-01-25T18:22:34.317854Z) |
deleted_at | string (date-time) | Timestamp of when the resource was deleted. If null, the resource has not been deleted. (example: 2009-11-10T23:00:00.000000Z) |
metadata | object | Metadata associated with the tunnel. |
remote_config | boolean | If true, the tunnel can be configured remotely from the Zero Trust dashboard. If false, the tunnel must be configured locally on the origin machine. (x-stainless-deprecation-message: Use the config_src field instead.) |
status | string | The status of the tunnel. Valid values are inactive (tunnel has never been run), degraded (tunnel is active and able to serve traffic but in an unhealthy state), healthy (tunnel is active and able to serve traffic), or down (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). (inactive, degraded, healthy, down) (example: healthy) |
tun_type | string | The type of tunnel. (cfd_tunnel, warp_connector, warp, magic, ip_sec, gre, cni) (example: cfd_tunnel) |
List Cloudflare Tunnels response
| Name | Datatype | Description |
|---|---|---|
id | string (uuid) | UUID of the tunnel. (example: f70ff985-a4ef-4643-bbbc-4a0ed4fc8415) |
name | string | A user-friendly name for a tunnel. (example: blog) |
account_tag | string | Cloudflare account ID (example: 699d98642c564d2e855e9661899b7252) |
config_src | string | Indicates if this is a locally or remotely configured tunnel. If local, manage the tunnel using a YAML file on the origin machine. If cloudflare, manage the tunnel on the Zero Trust dashboard. (local, cloudflare) (default: local, example: cloudflare) |
connections | array | The Cloudflare Tunnel connections between your origin and Cloudflare's edge. (x-stainless-deprecation-message: This field will start returning an empty array. To fetch the connections of a given tunnel, please use the dedicated endpoint /accounts/{account_id}/{tunnel_type}/{tunnel_id}/connections) |
conns_active_at | string (date-time) | Timestamp of when the tunnel established at least one connection to Cloudflare's edge. If null, the tunnel is inactive. (example: 2009-11-10T23:00:00Z) |
conns_inactive_at | string (date-time) | Timestamp of when the tunnel became inactive (no connections to Cloudflare's edge). If null, the tunnel is active. (example: 2009-11-10T23:00:00Z) |
created_at | string (date-time) | Timestamp of when the resource was created. (example: 2021-01-25T18:22:34.317854Z) |
deleted_at | string (date-time) | Timestamp of when the resource was deleted. If null, the resource has not been deleted. (example: 2009-11-10T23:00:00.000000Z) |
metadata | object | Metadata associated with the tunnel. |
remote_config | boolean | If true, the tunnel can be configured remotely from the Zero Trust dashboard. If false, the tunnel must be configured locally on the origin machine. (x-stainless-deprecation-message: Use the config_src field instead.) |
status | string | The status of the tunnel. Valid values are inactive (tunnel has never been run), degraded (tunnel is active and able to serve traffic but in an unhealthy state), healthy (tunnel is active and able to serve traffic), or down (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). (inactive, degraded, healthy, down) (example: healthy) |
tun_type | string | The type of tunnel. (cfd_tunnel, warp_connector, warp, magic, ip_sec, gre, cni) (example: cfd_tunnel) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | account_id, tunnel_id | Fetches a single Cloudflare Tunnel. | |
list | select | account_id | name, is_deleted, existed_at, uuid, was_active_at, was_inactive_at, include_prefix, exclude_prefix, status, per_page, page | Lists and filters Cloudflare Tunnels in an account. |
create | insert | account_id, name | Creates a new Cloudflare Tunnel in an account. | |
edit | update | tunnel_id, account_id | Updates an existing Cloudflare Tunnel. | |
delete | delete | account_id, tunnel_id | Deletes a Cloudflare Tunnel from an account. |
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. |
tunnel_id | string | The Cloudflare Tunnel ID. |
exclude_prefix | string | |
existed_at | string (url-encoded-date-time) | |
include_prefix | string | |
is_deleted | boolean | |
name | string | |
page | number | |
per_page | number | |
status | string | |
uuid | string (uuid) | |
was_active_at | string (date-time) | |
was_inactive_at | string (date-time) |
SELECT examples
- get
- list
Fetches a single Cloudflare Tunnel.
SELECT
id,
name,
account_tag,
config_src,
connections,
conns_active_at,
conns_inactive_at,
created_at,
deleted_at,
metadata,
remote_config,
status,
tun_type
FROM cloudflare.zero_trust.cloudflared
WHERE account_id = '{{ account_id }}' -- required
AND tunnel_id = '{{ tunnel_id }}' -- required
;
Lists and filters Cloudflare Tunnels in an account.
SELECT
id,
name,
account_tag,
config_src,
connections,
conns_active_at,
conns_inactive_at,
created_at,
deleted_at,
metadata,
remote_config,
status,
tun_type
FROM cloudflare.zero_trust.cloudflared
WHERE account_id = '{{ account_id }}' -- required
AND name = '{{ name }}'
AND is_deleted = '{{ is_deleted }}'
AND existed_at = '{{ existed_at }}'
AND uuid = '{{ uuid }}'
AND was_active_at = '{{ was_active_at }}'
AND was_inactive_at = '{{ was_inactive_at }}'
AND include_prefix = '{{ include_prefix }}'
AND exclude_prefix = '{{ exclude_prefix }}'
AND status = '{{ status }}'
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- create
- Manifest
Creates a new Cloudflare Tunnel in an account.
INSERT INTO cloudflare.zero_trust.cloudflared (
config_src,
name,
tunnel_secret,
account_id
)
SELECT
'{{ config_src }}',
'{{ name }}' /* required */,
'{{ tunnel_secret }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;
# Description fields are for documentation purposes
- name: cloudflared
props:
- name: account_id
value: "{{ account_id }}"
description: Required parameter for the cloudflared resource.
- name: config_src
value: "{{ config_src }}"
description: |
Indicates if this is a locally or remotely configured tunnel. If `local`, manage the tunnel using a YAML file on the origin machine. If `cloudflare`, manage the tunnel on the Zero Trust dashboard.
valid_values: ['local', 'cloudflare']
default: local
- name: name
value: "{{ name }}"
description: |
A user-friendly name for a tunnel.
- name: tunnel_secret
value: "{{ tunnel_secret }}"
description: |
Sets the password required to run a locally-managed tunnel. Must be at least 32 bytes and encoded as a base64 string.
UPDATE examples
- edit
Updates an existing Cloudflare Tunnel.
UPDATE cloudflare.zero_trust.cloudflared
SET
name = '{{ name }}',
tunnel_secret = '{{ tunnel_secret }}'
WHERE
tunnel_id = '{{ tunnel_id }}' --required
AND account_id = '{{ account_id }}' --required
RETURNING
errors,
messages,
result,
success;
DELETE examples
- delete
Deletes a Cloudflare Tunnel from an account.
DELETE FROM cloudflare.zero_trust.cloudflared
WHERE account_id = '{{ account_id }}' --required
AND tunnel_id = '{{ tunnel_id }}' --required
;