published on Thursday, Mar 19, 2026 by Pulumi
published on Thursday, Mar 19, 2026 by Pulumi
Represents a VPN gateway running in GCP. This virtual device is managed by Google, but used only by you.
To get more information about VpnGateway, see:
Warning: Classic VPN is deprecating certain functionality on October 31, 2021. For more information, see the Classic VPN partial deprecation page.
Example Usage
Target Vpn Gateway Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const network1 = new gcp.compute.Network("network1", {name: "network-1"});
const targetGateway = new gcp.compute.VPNGateway("target_gateway", {
name: "vpn-1",
network: network1.id,
});
const vpnStaticIp = new gcp.compute.Address("vpn_static_ip", {name: "vpn-static-ip"});
const frEsp = new gcp.compute.ForwardingRule("fr_esp", {
name: "fr-esp",
ipProtocol: "ESP",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const frUdp500 = new gcp.compute.ForwardingRule("fr_udp500", {
name: "fr-udp500",
ipProtocol: "UDP",
portRange: "500",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const frUdp4500 = new gcp.compute.ForwardingRule("fr_udp4500", {
name: "fr-udp4500",
ipProtocol: "UDP",
portRange: "4500",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const tunnel1 = new gcp.compute.VPNTunnel("tunnel1", {
name: "tunnel1",
peerIp: "15.0.0.120",
sharedSecret: "a secret message",
targetVpnGateway: targetGateway.id,
}, {
dependsOn: [
frEsp,
frUdp500,
frUdp4500,
],
});
const route1 = new gcp.compute.Route("route1", {
name: "route1",
network: network1.name,
destRange: "15.0.0.0/24",
priority: 1000,
nextHopVpnTunnel: tunnel1.id,
});
import pulumi
import pulumi_gcp as gcp
network1 = gcp.compute.Network("network1", name="network-1")
target_gateway = gcp.compute.VPNGateway("target_gateway",
name="vpn-1",
network=network1.id)
vpn_static_ip = gcp.compute.Address("vpn_static_ip", name="vpn-static-ip")
fr_esp = gcp.compute.ForwardingRule("fr_esp",
name="fr-esp",
ip_protocol="ESP",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
fr_udp500 = gcp.compute.ForwardingRule("fr_udp500",
name="fr-udp500",
ip_protocol="UDP",
port_range="500",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
fr_udp4500 = gcp.compute.ForwardingRule("fr_udp4500",
name="fr-udp4500",
ip_protocol="UDP",
port_range="4500",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
tunnel1 = gcp.compute.VPNTunnel("tunnel1",
name="tunnel1",
peer_ip="15.0.0.120",
shared_secret="a secret message",
target_vpn_gateway=target_gateway.id,
opts = pulumi.ResourceOptions(depends_on=[
fr_esp,
fr_udp500,
fr_udp4500,
]))
route1 = gcp.compute.Route("route1",
name="route1",
network=network1.name,
dest_range="15.0.0.0/24",
priority=1000,
next_hop_vpn_tunnel=tunnel1.id)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
network1, err := compute.NewNetwork(ctx, "network1", &compute.NetworkArgs{
Name: pulumi.String("network-1"),
})
if err != nil {
return err
}
targetGateway, err := compute.NewVPNGateway(ctx, "target_gateway", &compute.VPNGatewayArgs{
Name: pulumi.String("vpn-1"),
Network: network1.ID(),
})
if err != nil {
return err
}
vpnStaticIp, err := compute.NewAddress(ctx, "vpn_static_ip", &compute.AddressArgs{
Name: pulumi.String("vpn-static-ip"),
})
if err != nil {
return err
}
frEsp, err := compute.NewForwardingRule(ctx, "fr_esp", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-esp"),
IpProtocol: pulumi.String("ESP"),
IpAddress: vpnStaticIp.Address,
Target: targetGateway.ID(),
})
if err != nil {
return err
}
frUdp500, err := compute.NewForwardingRule(ctx, "fr_udp500", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-udp500"),
IpProtocol: pulumi.String("UDP"),
PortRange: pulumi.String("500"),
IpAddress: vpnStaticIp.Address,
Target: targetGateway.ID(),
})
if err != nil {
return err
}
frUdp4500, err := compute.NewForwardingRule(ctx, "fr_udp4500", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-udp4500"),
IpProtocol: pulumi.String("UDP"),
PortRange: pulumi.String("4500"),
IpAddress: vpnStaticIp.Address,
Target: targetGateway.ID(),
})
if err != nil {
return err
}
tunnel1, err := compute.NewVPNTunnel(ctx, "tunnel1", &compute.VPNTunnelArgs{
Name: pulumi.String("tunnel1"),
PeerIp: pulumi.String("15.0.0.120"),
SharedSecret: pulumi.String("a secret message"),
TargetVpnGateway: targetGateway.ID(),
}, pulumi.DependsOn([]pulumi.Resource{
frEsp,
frUdp500,
frUdp4500,
}))
if err != nil {
return err
}
_, err = compute.NewRoute(ctx, "route1", &compute.RouteArgs{
Name: pulumi.String("route1"),
Network: network1.Name,
DestRange: pulumi.String("15.0.0.0/24"),
Priority: pulumi.Int(1000),
NextHopVpnTunnel: tunnel1.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var network1 = new Gcp.Compute.Network("network1", new()
{
Name = "network-1",
});
var targetGateway = new Gcp.Compute.VPNGateway("target_gateway", new()
{
Name = "vpn-1",
Network = network1.Id,
});
var vpnStaticIp = new Gcp.Compute.Address("vpn_static_ip", new()
{
Name = "vpn-static-ip",
});
var frEsp = new Gcp.Compute.ForwardingRule("fr_esp", new()
{
Name = "fr-esp",
IpProtocol = "ESP",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var frUdp500 = new Gcp.Compute.ForwardingRule("fr_udp500", new()
{
Name = "fr-udp500",
IpProtocol = "UDP",
PortRange = "500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var frUdp4500 = new Gcp.Compute.ForwardingRule("fr_udp4500", new()
{
Name = "fr-udp4500",
IpProtocol = "UDP",
PortRange = "4500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var tunnel1 = new Gcp.Compute.VPNTunnel("tunnel1", new()
{
Name = "tunnel1",
PeerIp = "15.0.0.120",
SharedSecret = "a secret message",
TargetVpnGateway = targetGateway.Id,
}, new CustomResourceOptions
{
DependsOn =
{
frEsp,
frUdp500,
frUdp4500,
},
});
var route1 = new Gcp.Compute.Route("route1", new()
{
Name = "route1",
Network = network1.Name,
DestRange = "15.0.0.0/24",
Priority = 1000,
NextHopVpnTunnel = tunnel1.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.VPNGateway;
import com.pulumi.gcp.compute.VPNGatewayArgs;
import com.pulumi.gcp.compute.Address;
import com.pulumi.gcp.compute.AddressArgs;
import com.pulumi.gcp.compute.ForwardingRule;
import com.pulumi.gcp.compute.ForwardingRuleArgs;
import com.pulumi.gcp.compute.VPNTunnel;
import com.pulumi.gcp.compute.VPNTunnelArgs;
import com.pulumi.gcp.compute.Route;
import com.pulumi.gcp.compute.RouteArgs;
import com.pulumi.resources.CustomResourceOptions;
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 network1 = new Network("network1", NetworkArgs.builder()
.name("network-1")
.build());
var targetGateway = new VPNGateway("targetGateway", VPNGatewayArgs.builder()
.name("vpn-1")
.network(network1.id())
.build());
var vpnStaticIp = new Address("vpnStaticIp", AddressArgs.builder()
.name("vpn-static-ip")
.build());
var frEsp = new ForwardingRule("frEsp", ForwardingRuleArgs.builder()
.name("fr-esp")
.ipProtocol("ESP")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var frUdp500 = new ForwardingRule("frUdp500", ForwardingRuleArgs.builder()
.name("fr-udp500")
.ipProtocol("UDP")
.portRange("500")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var frUdp4500 = new ForwardingRule("frUdp4500", ForwardingRuleArgs.builder()
.name("fr-udp4500")
.ipProtocol("UDP")
.portRange("4500")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var tunnel1 = new VPNTunnel("tunnel1", VPNTunnelArgs.builder()
.name("tunnel1")
.peerIp("15.0.0.120")
.sharedSecret("a secret message")
.targetVpnGateway(targetGateway.id())
.build(), CustomResourceOptions.builder()
.dependsOn(
frEsp,
frUdp500,
frUdp4500)
.build());
var route1 = new Route("route1", RouteArgs.builder()
.name("route1")
.network(network1.name())
.destRange("15.0.0.0/24")
.priority(1000)
.nextHopVpnTunnel(tunnel1.id())
.build());
}
}
resources:
targetGateway:
type: gcp:compute:VPNGateway
name: target_gateway
properties:
name: vpn-1
network: ${network1.id}
network1:
type: gcp:compute:Network
properties:
name: network-1
vpnStaticIp:
type: gcp:compute:Address
name: vpn_static_ip
properties:
name: vpn-static-ip
frEsp:
type: gcp:compute:ForwardingRule
name: fr_esp
properties:
name: fr-esp
ipProtocol: ESP
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
frUdp500:
type: gcp:compute:ForwardingRule
name: fr_udp500
properties:
name: fr-udp500
ipProtocol: UDP
portRange: '500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
frUdp4500:
type: gcp:compute:ForwardingRule
name: fr_udp4500
properties:
name: fr-udp4500
ipProtocol: UDP
portRange: '4500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
tunnel1:
type: gcp:compute:VPNTunnel
properties:
name: tunnel1
peerIp: 15.0.0.120
sharedSecret: a secret message
targetVpnGateway: ${targetGateway.id}
options:
dependsOn:
- ${frEsp}
- ${frUdp500}
- ${frUdp4500}
route1:
type: gcp:compute:Route
properties:
name: route1
network: ${network1.name}
destRange: 15.0.0.0/24
priority: 1000
nextHopVpnTunnel: ${tunnel1.id}
Target Vpn Gateway Tags
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const project = gcp.organizations.getProject({});
const tagKey1 = new gcp.tags.TagKey("tag_key1", {
parent: "organizations/123456789",
shortName: "tagkey",
});
const tagValue1 = new gcp.tags.TagValue("tag_value1", {
parent: tagKey1.id,
shortName: "tagvalue",
});
const network1 = new gcp.compute.Network("network1", {name: "network-1"});
const targetGatewayTags = new gcp.compute.VPNGateway("target_gateway_tags", {
name: "vpn-1",
network: network1.id,
params: {
resourceManagerTags: pulumi.all([tagKey1.id, tagValue1.id]).apply(([tagKey1Id, tagValue1Id]) => {
[tagKey1Id]: tagValue1Id,
}),
},
});
const vpnStaticIp = new gcp.compute.Address("vpn_static_ip", {name: "vpn-static-ip"});
const frEsp = new gcp.compute.ForwardingRule("fr_esp", {
name: "fr-esp",
ipProtocol: "ESP",
ipAddress: vpnStaticIp.address,
target: targetGatewayTags.id,
});
const frUdp500 = new gcp.compute.ForwardingRule("fr_udp500", {
name: "fr-udp500",
ipProtocol: "UDP",
portRange: "500",
ipAddress: vpnStaticIp.address,
target: targetGatewayTags.id,
});
const frUdp4500 = new gcp.compute.ForwardingRule("fr_udp4500", {
name: "fr-udp4500",
ipProtocol: "UDP",
portRange: "4500",
ipAddress: vpnStaticIp.address,
target: targetGatewayTags.id,
});
const tunnel1 = new gcp.compute.VPNTunnel("tunnel1", {
name: "tunnel1",
peerIp: "15.0.0.120",
sharedSecret: "a secret message",
targetVpnGateway: targetGatewayTags.id,
}, {
dependsOn: [
frEsp,
frUdp500,
frUdp4500,
],
});
const route1 = new gcp.compute.Route("route1", {
name: "route1",
network: network1.name,
destRange: "15.0.0.0/24",
priority: 1000,
nextHopVpnTunnel: tunnel1.id,
});
import pulumi
import pulumi_gcp as gcp
project = gcp.organizations.get_project()
tag_key1 = gcp.tags.TagKey("tag_key1",
parent="organizations/123456789",
short_name="tagkey")
tag_value1 = gcp.tags.TagValue("tag_value1",
parent=tag_key1.id,
short_name="tagvalue")
network1 = gcp.compute.Network("network1", name="network-1")
target_gateway_tags = gcp.compute.VPNGateway("target_gateway_tags",
name="vpn-1",
network=network1.id,
params={
"resource_manager_tags": pulumi.Output.all(
tagKey1Id=tag_key1.id,
tagValue1Id=tag_value1.id
).apply(lambda resolved_outputs: {
resolved_outputs['tagKey1Id']: resolved_outputs['tagValue1Id'],
})
,
})
vpn_static_ip = gcp.compute.Address("vpn_static_ip", name="vpn-static-ip")
fr_esp = gcp.compute.ForwardingRule("fr_esp",
name="fr-esp",
ip_protocol="ESP",
ip_address=vpn_static_ip.address,
target=target_gateway_tags.id)
fr_udp500 = gcp.compute.ForwardingRule("fr_udp500",
name="fr-udp500",
ip_protocol="UDP",
port_range="500",
ip_address=vpn_static_ip.address,
target=target_gateway_tags.id)
fr_udp4500 = gcp.compute.ForwardingRule("fr_udp4500",
name="fr-udp4500",
ip_protocol="UDP",
port_range="4500",
ip_address=vpn_static_ip.address,
target=target_gateway_tags.id)
tunnel1 = gcp.compute.VPNTunnel("tunnel1",
name="tunnel1",
peer_ip="15.0.0.120",
shared_secret="a secret message",
target_vpn_gateway=target_gateway_tags.id,
opts = pulumi.ResourceOptions(depends_on=[
fr_esp,
fr_udp500,
fr_udp4500,
]))
route1 = gcp.compute.Route("route1",
name="route1",
network=network1.name,
dest_range="15.0.0.0/24",
priority=1000,
next_hop_vpn_tunnel=tunnel1.id)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/tags"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := organizations.LookupProject(ctx, &organizations.LookupProjectArgs{
}, nil);
if err != nil {
return err
}
tagKey1, err := tags.NewTagKey(ctx, "tag_key1", &tags.TagKeyArgs{
Parent: pulumi.String("organizations/123456789"),
ShortName: pulumi.String("tagkey"),
})
if err != nil {
return err
}
tagValue1, err := tags.NewTagValue(ctx, "tag_value1", &tags.TagValueArgs{
Parent: tagKey1.ID(),
ShortName: pulumi.String("tagvalue"),
})
if err != nil {
return err
}
network1, err := compute.NewNetwork(ctx, "network1", &compute.NetworkArgs{
Name: pulumi.String("network-1"),
})
if err != nil {
return err
}
targetGatewayTags, err := compute.NewVPNGateway(ctx, "target_gateway_tags", &compute.VPNGatewayArgs{
Name: pulumi.String("vpn-1"),
Network: network1.ID(),
Params: &compute.VPNGatewayParamsArgs{
ResourceManagerTags: pulumi.All(tagKey1.ID(),tagValue1.ID()).ApplyT(func(_args []interface{}) (map[string]string, error) {
tagKey1Id := _args[0].(string)
tagValue1Id := _args[1].(string)
return map[string]string{
tagKey1Id: tagValue1Id,
}, nil
}).(pulumi.Map[string]stringOutput),
},
})
if err != nil {
return err
}
vpnStaticIp, err := compute.NewAddress(ctx, "vpn_static_ip", &compute.AddressArgs{
Name: pulumi.String("vpn-static-ip"),
})
if err != nil {
return err
}
frEsp, err := compute.NewForwardingRule(ctx, "fr_esp", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-esp"),
IpProtocol: pulumi.String("ESP"),
IpAddress: vpnStaticIp.Address,
Target: targetGatewayTags.ID(),
})
if err != nil {
return err
}
frUdp500, err := compute.NewForwardingRule(ctx, "fr_udp500", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-udp500"),
IpProtocol: pulumi.String("UDP"),
PortRange: pulumi.String("500"),
IpAddress: vpnStaticIp.Address,
Target: targetGatewayTags.ID(),
})
if err != nil {
return err
}
frUdp4500, err := compute.NewForwardingRule(ctx, "fr_udp4500", &compute.ForwardingRuleArgs{
Name: pulumi.String("fr-udp4500"),
IpProtocol: pulumi.String("UDP"),
PortRange: pulumi.String("4500"),
IpAddress: vpnStaticIp.Address,
Target: targetGatewayTags.ID(),
})
if err != nil {
return err
}
tunnel1, err := compute.NewVPNTunnel(ctx, "tunnel1", &compute.VPNTunnelArgs{
Name: pulumi.String("tunnel1"),
PeerIp: pulumi.String("15.0.0.120"),
SharedSecret: pulumi.String("a secret message"),
TargetVpnGateway: targetGatewayTags.ID(),
}, pulumi.DependsOn([]pulumi.Resource{
frEsp,
frUdp500,
frUdp4500,
}))
if err != nil {
return err
}
_, err = compute.NewRoute(ctx, "route1", &compute.RouteArgs{
Name: pulumi.String("route1"),
Network: network1.Name,
DestRange: pulumi.String("15.0.0.0/24"),
Priority: pulumi.Int(1000),
NextHopVpnTunnel: tunnel1.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var project = Gcp.Organizations.GetProject.Invoke();
var tagKey1 = new Gcp.Tags.TagKey("tag_key1", new()
{
Parent = "organizations/123456789",
ShortName = "tagkey",
});
var tagValue1 = new Gcp.Tags.TagValue("tag_value1", new()
{
Parent = tagKey1.Id,
ShortName = "tagvalue",
});
var network1 = new Gcp.Compute.Network("network1", new()
{
Name = "network-1",
});
var targetGatewayTags = new Gcp.Compute.VPNGateway("target_gateway_tags", new()
{
Name = "vpn-1",
Network = network1.Id,
Params = new Gcp.Compute.Inputs.VPNGatewayParamsArgs
{
ResourceManagerTags = Output.Tuple(tagKey1.Id, tagValue1.Id).Apply(values =>
{
var tagKey1Id = values.Item1;
var tagValue1Id = values.Item2;
return
{
{ tagKey1Id, tagValue1Id },
};
}),
},
});
var vpnStaticIp = new Gcp.Compute.Address("vpn_static_ip", new()
{
Name = "vpn-static-ip",
});
var frEsp = new Gcp.Compute.ForwardingRule("fr_esp", new()
{
Name = "fr-esp",
IpProtocol = "ESP",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGatewayTags.Id,
});
var frUdp500 = new Gcp.Compute.ForwardingRule("fr_udp500", new()
{
Name = "fr-udp500",
IpProtocol = "UDP",
PortRange = "500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGatewayTags.Id,
});
var frUdp4500 = new Gcp.Compute.ForwardingRule("fr_udp4500", new()
{
Name = "fr-udp4500",
IpProtocol = "UDP",
PortRange = "4500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGatewayTags.Id,
});
var tunnel1 = new Gcp.Compute.VPNTunnel("tunnel1", new()
{
Name = "tunnel1",
PeerIp = "15.0.0.120",
SharedSecret = "a secret message",
TargetVpnGateway = targetGatewayTags.Id,
}, new CustomResourceOptions
{
DependsOn =
{
frEsp,
frUdp500,
frUdp4500,
},
});
var route1 = new Gcp.Compute.Route("route1", new()
{
Name = "route1",
Network = network1.Name,
DestRange = "15.0.0.0/24",
Priority = 1000,
NextHopVpnTunnel = tunnel1.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.OrganizationsFunctions;
import com.pulumi.gcp.organizations.inputs.GetProjectArgs;
import com.pulumi.gcp.tags.TagKey;
import com.pulumi.gcp.tags.TagKeyArgs;
import com.pulumi.gcp.tags.TagValue;
import com.pulumi.gcp.tags.TagValueArgs;
import com.pulumi.gcp.compute.Network;
import com.pulumi.gcp.compute.NetworkArgs;
import com.pulumi.gcp.compute.VPNGateway;
import com.pulumi.gcp.compute.VPNGatewayArgs;
import com.pulumi.gcp.compute.inputs.VPNGatewayParamsArgs;
import com.pulumi.gcp.compute.Address;
import com.pulumi.gcp.compute.AddressArgs;
import com.pulumi.gcp.compute.ForwardingRule;
import com.pulumi.gcp.compute.ForwardingRuleArgs;
import com.pulumi.gcp.compute.VPNTunnel;
import com.pulumi.gcp.compute.VPNTunnelArgs;
import com.pulumi.gcp.compute.Route;
import com.pulumi.gcp.compute.RouteArgs;
import com.pulumi.resources.CustomResourceOptions;
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) {
final var project = OrganizationsFunctions.getProject(GetProjectArgs.builder()
.build());
var tagKey1 = new TagKey("tagKey1", TagKeyArgs.builder()
.parent("organizations/123456789")
.shortName("tagkey")
.build());
var tagValue1 = new TagValue("tagValue1", TagValueArgs.builder()
.parent(tagKey1.id())
.shortName("tagvalue")
.build());
var network1 = new Network("network1", NetworkArgs.builder()
.name("network-1")
.build());
var targetGatewayTags = new VPNGateway("targetGatewayTags", VPNGatewayArgs.builder()
.name("vpn-1")
.network(network1.id())
.params(VPNGatewayParamsArgs.builder()
.resourceManagerTags(Output.tuple(tagKey1.id(), tagValue1.id()).applyValue(values -> {
var tagKey1Id = values.t1;
var tagValue1Id = values.t2;
return Map.of(tagKey1Id, tagValue1Id);
}))
.build())
.build());
var vpnStaticIp = new Address("vpnStaticIp", AddressArgs.builder()
.name("vpn-static-ip")
.build());
var frEsp = new ForwardingRule("frEsp", ForwardingRuleArgs.builder()
.name("fr-esp")
.ipProtocol("ESP")
.ipAddress(vpnStaticIp.address())
.target(targetGatewayTags.id())
.build());
var frUdp500 = new ForwardingRule("frUdp500", ForwardingRuleArgs.builder()
.name("fr-udp500")
.ipProtocol("UDP")
.portRange("500")
.ipAddress(vpnStaticIp.address())
.target(targetGatewayTags.id())
.build());
var frUdp4500 = new ForwardingRule("frUdp4500", ForwardingRuleArgs.builder()
.name("fr-udp4500")
.ipProtocol("UDP")
.portRange("4500")
.ipAddress(vpnStaticIp.address())
.target(targetGatewayTags.id())
.build());
var tunnel1 = new VPNTunnel("tunnel1", VPNTunnelArgs.builder()
.name("tunnel1")
.peerIp("15.0.0.120")
.sharedSecret("a secret message")
.targetVpnGateway(targetGatewayTags.id())
.build(), CustomResourceOptions.builder()
.dependsOn(
frEsp,
frUdp500,
frUdp4500)
.build());
var route1 = new Route("route1", RouteArgs.builder()
.name("route1")
.network(network1.name())
.destRange("15.0.0.0/24")
.priority(1000)
.nextHopVpnTunnel(tunnel1.id())
.build());
}
}
resources:
targetGatewayTags:
type: gcp:compute:VPNGateway
name: target_gateway_tags
properties:
name: vpn-1
network: ${network1.id}
params:
resourceManagerTags:
${tagKey1.id}: ${tagValue1.id}
tagKey1:
type: gcp:tags:TagKey
name: tag_key1
properties:
parent: organizations/123456789
shortName: tagkey
tagValue1:
type: gcp:tags:TagValue
name: tag_value1
properties:
parent: ${tagKey1.id}
shortName: tagvalue
network1:
type: gcp:compute:Network
properties:
name: network-1
vpnStaticIp:
type: gcp:compute:Address
name: vpn_static_ip
properties:
name: vpn-static-ip
frEsp:
type: gcp:compute:ForwardingRule
name: fr_esp
properties:
name: fr-esp
ipProtocol: ESP
ipAddress: ${vpnStaticIp.address}
target: ${targetGatewayTags.id}
frUdp500:
type: gcp:compute:ForwardingRule
name: fr_udp500
properties:
name: fr-udp500
ipProtocol: UDP
portRange: '500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGatewayTags.id}
frUdp4500:
type: gcp:compute:ForwardingRule
name: fr_udp4500
properties:
name: fr-udp4500
ipProtocol: UDP
portRange: '4500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGatewayTags.id}
tunnel1:
type: gcp:compute:VPNTunnel
properties:
name: tunnel1
peerIp: 15.0.0.120
sharedSecret: a secret message
targetVpnGateway: ${targetGatewayTags.id}
options:
dependsOn:
- ${frEsp}
- ${frUdp500}
- ${frUdp4500}
route1:
type: gcp:compute:Route
properties:
name: route1
network: ${network1.name}
destRange: 15.0.0.0/24
priority: 1000
nextHopVpnTunnel: ${tunnel1.id}
variables:
project:
fn::invoke:
function: gcp:organizations:getProject
arguments: {}
Create VPNGateway Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new VPNGateway(name: string, args: VPNGatewayArgs, opts?: CustomResourceOptions);@overload
def VPNGateway(resource_name: str,
args: VPNGatewayArgs,
opts: Optional[ResourceOptions] = None)
@overload
def VPNGateway(resource_name: str,
opts: Optional[ResourceOptions] = None,
network: Optional[str] = None,
description: Optional[str] = None,
name: Optional[str] = None,
params: Optional[VPNGatewayParamsArgs] = None,
project: Optional[str] = None,
region: Optional[str] = None)func NewVPNGateway(ctx *Context, name string, args VPNGatewayArgs, opts ...ResourceOption) (*VPNGateway, error)public VPNGateway(string name, VPNGatewayArgs args, CustomResourceOptions? opts = null)
public VPNGateway(String name, VPNGatewayArgs args)
public VPNGateway(String name, VPNGatewayArgs args, CustomResourceOptions options)
type: gcp:compute:VPNGateway
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args VPNGatewayArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args VPNGatewayArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args VPNGatewayArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VPNGatewayArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args VPNGatewayArgs
- 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 vpngatewayResource = new Gcp.Compute.VPNGateway("vpngatewayResource", new()
{
Network = "string",
Description = "string",
Name = "string",
Params = new Gcp.Compute.Inputs.VPNGatewayParamsArgs
{
ResourceManagerTags =
{
{ "string", "string" },
},
},
Project = "string",
Region = "string",
});
example, err := compute.NewVPNGateway(ctx, "vpngatewayResource", &compute.VPNGatewayArgs{
Network: pulumi.String("string"),
Description: pulumi.String("string"),
Name: pulumi.String("string"),
Params: &compute.VPNGatewayParamsArgs{
ResourceManagerTags: pulumi.StringMap{
"string": pulumi.String("string"),
},
},
Project: pulumi.String("string"),
Region: pulumi.String("string"),
})
var vpngatewayResource = new VPNGateway("vpngatewayResource", VPNGatewayArgs.builder()
.network("string")
.description("string")
.name("string")
.params(VPNGatewayParamsArgs.builder()
.resourceManagerTags(Map.of("string", "string"))
.build())
.project("string")
.region("string")
.build());
vpngateway_resource = gcp.compute.VPNGateway("vpngatewayResource",
network="string",
description="string",
name="string",
params={
"resource_manager_tags": {
"string": "string",
},
},
project="string",
region="string")
const vpngatewayResource = new gcp.compute.VPNGateway("vpngatewayResource", {
network: "string",
description: "string",
name: "string",
params: {
resourceManagerTags: {
string: "string",
},
},
project: "string",
region: "string",
});
type: gcp:compute:VPNGateway
properties:
description: string
name: string
network: string
params:
resourceManagerTags:
string: string
project: string
region: string
VPNGateway 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 VPNGateway resource accepts the following input properties:
- Network string
- The network this VPN gateway is accepting traffic for.
- Description string
- An optional description of this resource.
- Name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - Params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- The region this gateway should sit in.
- Network string
- The network this VPN gateway is accepting traffic for.
- Description string
- An optional description of this resource.
- Name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - Params
VPNGateway
Params Args - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- The region this gateway should sit in.
- network String
- The network this VPN gateway is accepting traffic for.
- description String
- An optional description of this resource.
- name String
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- The region this gateway should sit in.
- network string
- The network this VPN gateway is accepting traffic for.
- description string
- An optional description of this resource.
- name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region string
- The region this gateway should sit in.
- network str
- The network this VPN gateway is accepting traffic for.
- description str
- An optional description of this resource.
- name str
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - params
VPNGateway
Params Args - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region str
- The region this gateway should sit in.
- network String
- The network this VPN gateway is accepting traffic for.
- description String
- An optional description of this resource.
- name String
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - params Property Map
- Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- The region this gateway should sit in.
Outputs
All input properties are implicitly available as output properties. Additionally, the VPNGateway resource produces the following output properties:
- Creation
Timestamp string - Creation timestamp in RFC3339 text format.
- Gateway
Id int - The unique identifier for the resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Self
Link string - The URI of the created resource.
- Creation
Timestamp string - Creation timestamp in RFC3339 text format.
- Gateway
Id int - The unique identifier for the resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Self
Link string - The URI of the created resource.
- creation
Timestamp String - Creation timestamp in RFC3339 text format.
- gateway
Id Integer - The unique identifier for the resource.
- id String
- The provider-assigned unique ID for this managed resource.
- self
Link String - The URI of the created resource.
- creation
Timestamp string - Creation timestamp in RFC3339 text format.
- gateway
Id number - The unique identifier for the resource.
- id string
- The provider-assigned unique ID for this managed resource.
- self
Link string - The URI of the created resource.
- creation_
timestamp str - Creation timestamp in RFC3339 text format.
- gateway_
id int - The unique identifier for the resource.
- id str
- The provider-assigned unique ID for this managed resource.
- self_
link str - The URI of the created resource.
- creation
Timestamp String - Creation timestamp in RFC3339 text format.
- gateway
Id Number - The unique identifier for the resource.
- id String
- The provider-assigned unique ID for this managed resource.
- self
Link String - The URI of the created resource.
Look up Existing VPNGateway Resource
Get an existing VPNGateway 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?: VPNGatewayState, opts?: CustomResourceOptions): VPNGateway@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
creation_timestamp: Optional[str] = None,
description: Optional[str] = None,
gateway_id: Optional[int] = None,
name: Optional[str] = None,
network: Optional[str] = None,
params: Optional[VPNGatewayParamsArgs] = None,
project: Optional[str] = None,
region: Optional[str] = None,
self_link: Optional[str] = None) -> VPNGatewayfunc GetVPNGateway(ctx *Context, name string, id IDInput, state *VPNGatewayState, opts ...ResourceOption) (*VPNGateway, error)public static VPNGateway Get(string name, Input<string> id, VPNGatewayState? state, CustomResourceOptions? opts = null)public static VPNGateway get(String name, Output<String> id, VPNGatewayState state, CustomResourceOptions options)resources: _: type: gcp:compute:VPNGateway get: id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Creation
Timestamp string - Creation timestamp in RFC3339 text format.
- Description string
- An optional description of this resource.
- Gateway
Id int - The unique identifier for the resource.
- Name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - Network string
- The network this VPN gateway is accepting traffic for.
- Params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- The region this gateway should sit in.
- Self
Link string - The URI of the created resource.
- Creation
Timestamp string - Creation timestamp in RFC3339 text format.
- Description string
- An optional description of this resource.
- Gateway
Id int - The unique identifier for the resource.
- Name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - Network string
- The network this VPN gateway is accepting traffic for.
- Params
VPNGateway
Params Args - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- Project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- Region string
- The region this gateway should sit in.
- Self
Link string - The URI of the created resource.
- creation
Timestamp String - Creation timestamp in RFC3339 text format.
- description String
- An optional description of this resource.
- gateway
Id Integer - The unique identifier for the resource.
- name String
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - network String
- The network this VPN gateway is accepting traffic for.
- params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- The region this gateway should sit in.
- self
Link String - The URI of the created resource.
- creation
Timestamp string - Creation timestamp in RFC3339 text format.
- description string
- An optional description of this resource.
- gateway
Id number - The unique identifier for the resource.
- name string
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - network string
- The network this VPN gateway is accepting traffic for.
- params
VPNGateway
Params - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project string
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region string
- The region this gateway should sit in.
- self
Link string - The URI of the created resource.
- creation_
timestamp str - Creation timestamp in RFC3339 text format.
- description str
- An optional description of this resource.
- gateway_
id int - The unique identifier for the resource.
- name str
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - network str
- The network this VPN gateway is accepting traffic for.
- params
VPNGateway
Params Args - Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project str
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region str
- The region this gateway should sit in.
- self_
link str - The URI of the created resource.
- creation
Timestamp String - Creation timestamp in RFC3339 text format.
- description String
- An optional description of this resource.
- gateway
Id Number - The unique identifier for the resource.
- name String
- Name of the resource. Provided by the client when the resource is
created. The name must be 1-63 characters long, and comply with
RFC1035. Specifically, the name must be 1-63 characters long and
match the regular expression
a-z?which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. - network String
- The network this VPN gateway is accepting traffic for.
- params Property Map
- Additional params passed with the request, but not persisted as part of resource payload Structure is documented below.
- project String
- The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
- region String
- The region this gateway should sit in.
- self
Link String - The URI of the created resource.
Supporting Types
VPNGatewayParams, VPNGatewayParamsArgs
- Dictionary<string, string>
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
- map[string]string
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
- Map<String,String>
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
- {[key: string]: string}
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
- Mapping[str, str]
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
- Map<String>
- Resource manager tags to be bound to the Vpn Gateway. Tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456.
Import
VpnGateway can be imported using any of these accepted formats:
projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}{{project}}/{{region}}/{{name}}{{region}}/{{name}}{{name}}
When using the pulumi import command, VpnGateway can be imported using one of the formats above. For example:
$ pulumi import gcp:compute/vPNGateway:VPNGateway default projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}
$ pulumi import gcp:compute/vPNGateway:VPNGateway default {{project}}/{{region}}/{{name}}
$ pulumi import gcp:compute/vPNGateway:VPNGateway default {{region}}/{{name}}
$ pulumi import gcp:compute/vPNGateway:VPNGateway default {{name}}
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
google-betaTerraform Provider.
published on Thursday, Mar 19, 2026 by Pulumi
