Skip to main content

cloudflared

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

Overview

Namecloudflared
TypeResource
Idcloudflare.zero_trust.cloudflared

Fields

The following fields are returned by SELECT queries:

Get a Cloudflare Tunnel response

NameDatatypeDescription
idstring (uuid)UUID of the tunnel. (example: f70ff985-a4ef-4643-bbbc-4a0ed4fc8415)
namestringA user-friendly name for a tunnel. (example: blog)
account_tagstringCloudflare account ID (example: 699d98642c564d2e855e9661899b7252)
config_srcstringIndicates 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)
connectionsarrayThe 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_atstring (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_atstring (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_atstring (date-time)Timestamp of when the resource was created. (example: 2021-01-25T18:22:34.317854Z)
deleted_atstring (date-time)Timestamp of when the resource was deleted. If null, the resource has not been deleted. (example: 2009-11-10T23:00:00.000000Z)
metadataobjectMetadata associated with the tunnel.
remote_configbooleanIf 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.)
statusstringThe 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_typestringThe 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:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, tunnel_idFetches a single Cloudflare Tunnel.
listselectaccount_idname, is_deleted, existed_at, uuid, was_active_at, was_inactive_at, include_prefix, exclude_prefix, status, per_page, pageLists and filters Cloudflare Tunnels in an account.
createinsertaccount_id, nameCreates a new Cloudflare Tunnel in an account.
editupdatetunnel_id, account_idUpdates an existing Cloudflare Tunnel.
deletedeleteaccount_id, tunnel_idDeletes 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.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
tunnel_idstringThe Cloudflare Tunnel ID.
exclude_prefixstring
existed_atstring (url-encoded-date-time)
include_prefixstring
is_deletedboolean
namestring
pagenumber
per_pagenumber
statusstring
uuidstring (uuid)
was_active_atstring (date-time)
was_inactive_atstring (date-time)

SELECT examples

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
;

INSERT examples

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
;

UPDATE examples

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

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
;