1. Packages
  2. Cloudflare Provider
  3. API Docs
  4. Tunnel
Cloudflare v5.49.1 published on Tuesday, Feb 18, 2025 by Pulumi

cloudflare.Tunnel

Explore with Pulumi AI

Tunnel exposes applications running on your local web server on any network with an internet connection without manually adding DNS records or configuring a firewall or router.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as cloudflare from "@pulumi/cloudflare";

const example = new cloudflare.Tunnel("example", {
    accountId: "f037e56e89293a057740de681ac9abbe",
    name: "my-tunnel",
    secret: "AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg=",
});
Copy
import pulumi
import pulumi_cloudflare as cloudflare

example = cloudflare.Tunnel("example",
    account_id="f037e56e89293a057740de681ac9abbe",
    name="my-tunnel",
    secret="AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg=")
Copy
package main

import (
	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudflare.NewTunnel(ctx, "example", &cloudflare.TunnelArgs{
			AccountId: pulumi.String("f037e56e89293a057740de681ac9abbe"),
			Name:      pulumi.String("my-tunnel"),
			Secret:    pulumi.String("AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg="),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Cloudflare = Pulumi.Cloudflare;

return await Deployment.RunAsync(() => 
{
    var example = new Cloudflare.Tunnel("example", new()
    {
        AccountId = "f037e56e89293a057740de681ac9abbe",
        Name = "my-tunnel",
        Secret = "AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg=",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.cloudflare.Tunnel;
import com.pulumi.cloudflare.TunnelArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new Tunnel("example", TunnelArgs.builder()
            .accountId("f037e56e89293a057740de681ac9abbe")
            .name("my-tunnel")
            .secret("AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg=")
            .build());

    }
}
Copy
resources:
  example:
    type: cloudflare:Tunnel
    properties:
      accountId: f037e56e89293a057740de681ac9abbe
      name: my-tunnel
      secret: AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg=
Copy

Create Tunnel Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Tunnel(name: string, args: TunnelArgs, opts?: CustomResourceOptions);
@overload
def Tunnel(resource_name: str,
           args: TunnelArgs,
           opts: Optional[ResourceOptions] = None)

@overload
def Tunnel(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           account_id: Optional[str] = None,
           name: Optional[str] = None,
           secret: Optional[str] = None,
           config_src: Optional[str] = None)
func NewTunnel(ctx *Context, name string, args TunnelArgs, opts ...ResourceOption) (*Tunnel, error)
public Tunnel(string name, TunnelArgs args, CustomResourceOptions? opts = null)
public Tunnel(String name, TunnelArgs args)
public Tunnel(String name, TunnelArgs args, CustomResourceOptions options)
type: cloudflare:Tunnel
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. TunnelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. TunnelArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. TunnelArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. TunnelArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. TunnelArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var tunnelResource = new Cloudflare.Tunnel("tunnelResource", new()
{
    AccountId = "string",
    Name = "string",
    Secret = "string",
    ConfigSrc = "string",
});
Copy
example, err := cloudflare.NewTunnel(ctx, "tunnelResource", &cloudflare.TunnelArgs{
	AccountId: pulumi.String("string"),
	Name:      pulumi.String("string"),
	Secret:    pulumi.String("string"),
	ConfigSrc: pulumi.String("string"),
})
Copy
var tunnelResource = new Tunnel("tunnelResource", TunnelArgs.builder()
    .accountId("string")
    .name("string")
    .secret("string")
    .configSrc("string")
    .build());
Copy
tunnel_resource = cloudflare.Tunnel("tunnelResource",
    account_id="string",
    name="string",
    secret="string",
    config_src="string")
Copy
const tunnelResource = new cloudflare.Tunnel("tunnelResource", {
    accountId: "string",
    name: "string",
    secret: "string",
    configSrc: "string",
});
Copy
type: cloudflare:Tunnel
properties:
    accountId: string
    configSrc: string
    name: string
    secret: string
Copy

Tunnel Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Tunnel resource accepts the following input properties:

AccountId
This property is required.
Changes to this property will trigger replacement.
string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
Name
This property is required.
Changes to this property will trigger replacement.
string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
Secret
This property is required.
Changes to this property will trigger replacement.
string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
ConfigSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
AccountId
This property is required.
Changes to this property will trigger replacement.
string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
Name
This property is required.
Changes to this property will trigger replacement.
string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
Secret
This property is required.
Changes to this property will trigger replacement.
string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
ConfigSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
accountId
This property is required.
Changes to this property will trigger replacement.
String
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
name
This property is required.
Changes to this property will trigger replacement.
String
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret
This property is required.
Changes to this property will trigger replacement.
String
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
accountId
This property is required.
Changes to this property will trigger replacement.
string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
name
This property is required.
Changes to this property will trigger replacement.
string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret
This property is required.
Changes to this property will trigger replacement.
string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
account_id
This property is required.
Changes to this property will trigger replacement.
str
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
name
This property is required.
Changes to this property will trigger replacement.
str
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret
This property is required.
Changes to this property will trigger replacement.
str
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
config_src Changes to this property will trigger replacement. str
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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
accountId
This property is required.
Changes to this property will trigger replacement.
String
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
name
This property is required.
Changes to this property will trigger replacement.
String
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret
This property is required.
Changes to this property will trigger replacement.
String
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.

Outputs

All input properties are implicitly available as output properties. Additionally, the Tunnel resource produces the following output properties:

Cname string
Usable CNAME for accessing the Tunnel.
Id string
The provider-assigned unique ID for this managed resource.
TunnelToken string
Token used by a connector to authenticate and run the tunnel.
Cname string
Usable CNAME for accessing the Tunnel.
Id string
The provider-assigned unique ID for this managed resource.
TunnelToken string
Token used by a connector to authenticate and run the tunnel.
cname String
Usable CNAME for accessing the Tunnel.
id String
The provider-assigned unique ID for this managed resource.
tunnelToken String
Token used by a connector to authenticate and run the tunnel.
cname string
Usable CNAME for accessing the Tunnel.
id string
The provider-assigned unique ID for this managed resource.
tunnelToken string
Token used by a connector to authenticate and run the tunnel.
cname str
Usable CNAME for accessing the Tunnel.
id str
The provider-assigned unique ID for this managed resource.
tunnel_token str
Token used by a connector to authenticate and run the tunnel.
cname String
Usable CNAME for accessing the Tunnel.
id String
The provider-assigned unique ID for this managed resource.
tunnelToken String
Token used by a connector to authenticate and run the tunnel.

Look up Existing Tunnel Resource

Get an existing Tunnel resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: TunnelState, opts?: CustomResourceOptions): Tunnel
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        cname: Optional[str] = None,
        config_src: Optional[str] = None,
        name: Optional[str] = None,
        secret: Optional[str] = None,
        tunnel_token: Optional[str] = None) -> Tunnel
func GetTunnel(ctx *Context, name string, id IDInput, state *TunnelState, opts ...ResourceOption) (*Tunnel, error)
public static Tunnel Get(string name, Input<string> id, TunnelState? state, CustomResourceOptions? opts = null)
public static Tunnel get(String name, Output<String> id, TunnelState state, CustomResourceOptions options)
resources:  _:    type: cloudflare:Tunnel    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
AccountId Changes to this property will trigger replacement. string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
Cname string
Usable CNAME for accessing the Tunnel.
ConfigSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
Name Changes to this property will trigger replacement. string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
Secret Changes to this property will trigger replacement. string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
TunnelToken string
Token used by a connector to authenticate and run the tunnel.
AccountId Changes to this property will trigger replacement. string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
Cname string
Usable CNAME for accessing the Tunnel.
ConfigSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
Name Changes to this property will trigger replacement. string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
Secret Changes to this property will trigger replacement. string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
TunnelToken string
Token used by a connector to authenticate and run the tunnel.
accountId Changes to this property will trigger replacement. String
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
cname String
Usable CNAME for accessing the Tunnel.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
name Changes to this property will trigger replacement. String
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret Changes to this property will trigger replacement. String
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
tunnelToken String
Token used by a connector to authenticate and run the tunnel.
accountId Changes to this property will trigger replacement. string
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
cname string
Usable CNAME for accessing the Tunnel.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
name Changes to this property will trigger replacement. string
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret Changes to this property will trigger replacement. string
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
tunnelToken string
Token used by a connector to authenticate and run the tunnel.
account_id Changes to this property will trigger replacement. str
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
cname str
Usable CNAME for accessing the Tunnel.
config_src Changes to this property will trigger replacement. str
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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
name Changes to this property will trigger replacement. str
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret Changes to this property will trigger replacement. str
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
tunnel_token str
Token used by a connector to authenticate and run the tunnel.
accountId Changes to this property will trigger replacement. String
The account identifier to target for the resource. Modifying this attribute will force creation of a new resource.
cname String
Usable CNAME for accessing the Tunnel.
configSrc Changes to this property will trigger replacement. 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 or using tunnelconfig, tunnelroute or tunnelvirtualnetwork resources. Available values: local, cloudflare. Modifying this attribute will force creation of a new resource.
name Changes to this property will trigger replacement. String
A user-friendly name chosen when the tunnel is created. Modifying this attribute will force creation of a new resource.
secret Changes to this property will trigger replacement. String
32 or more bytes, encoded as a base64 string. The Create Argo Tunnel endpoint sets this as the tunnel's password. Anyone wishing to run the tunnel needs this password. Modifying this attribute will force creation of a new resource.
tunnelToken String
Token used by a connector to authenticate and run the tunnel.

Import

$ pulumi import cloudflare:index/tunnel:Tunnel example <account_id>/<tunnel_id>
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Cloudflare pulumi/pulumi-cloudflare
License
Apache-2.0
Notes
This Pulumi package is based on the cloudflare Terraform Provider.