gcp.compute.VPNGateway
Explore with Pulumi AI
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
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var network1 = new Gcp.Compute.Network("network1");
var targetGateway = new Gcp.Compute.VPNGateway("targetGateway", new()
{
Network = network1.Id,
});
var vpnStaticIp = new Gcp.Compute.Address("vpnStaticIp");
var frEsp = new Gcp.Compute.ForwardingRule("frEsp", new()
{
IpProtocol = "ESP",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var frUdp500 = new Gcp.Compute.ForwardingRule("frUdp500", new()
{
IpProtocol = "UDP",
PortRange = "500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var frUdp4500 = new Gcp.Compute.ForwardingRule("frUdp4500", new()
{
IpProtocol = "UDP",
PortRange = "4500",
IpAddress = vpnStaticIp.IPAddress,
Target = targetGateway.Id,
});
var tunnel1 = new Gcp.Compute.VPNTunnel("tunnel1", new()
{
PeerIp = "15.0.0.120",
SharedSecret = "a secret message",
TargetVpnGateway = targetGateway.Id,
}, new CustomResourceOptions
{
DependsOn = new[]
{
frEsp,
frUdp500,
frUdp4500,
},
});
var route1 = new Gcp.Compute.Route("route1", new()
{
Network = network1.Name,
DestRange = "15.0.0.0/24",
Priority = 1000,
NextHopVpnTunnel = tunnel1.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/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", nil)
if err != nil {
return err
}
targetGateway, err := compute.NewVPNGateway(ctx, "targetGateway", &compute.VPNGatewayArgs{
Network: network1.ID(),
})
if err != nil {
return err
}
vpnStaticIp, err := compute.NewAddress(ctx, "vpnStaticIp", nil)
if err != nil {
return err
}
frEsp, err := compute.NewForwardingRule(ctx, "frEsp", &compute.ForwardingRuleArgs{
IpProtocol: pulumi.String("ESP"),
IpAddress: vpnStaticIp.Address,
Target: targetGateway.ID(),
})
if err != nil {
return err
}
frUdp500, err := compute.NewForwardingRule(ctx, "frUdp500", &compute.ForwardingRuleArgs{
IpProtocol: pulumi.String("UDP"),
PortRange: pulumi.String("500"),
IpAddress: vpnStaticIp.Address,
Target: targetGateway.ID(),
})
if err != nil {
return err
}
frUdp4500, err := compute.NewForwardingRule(ctx, "frUdp4500", &compute.ForwardingRuleArgs{
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{
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{
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
})
}
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.VPNGateway;
import com.pulumi.gcp.compute.VPNGatewayArgs;
import com.pulumi.gcp.compute.Address;
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");
var targetGateway = new VPNGateway("targetGateway", VPNGatewayArgs.builder()
.network(network1.id())
.build());
var vpnStaticIp = new Address("vpnStaticIp");
var frEsp = new ForwardingRule("frEsp", ForwardingRuleArgs.builder()
.ipProtocol("ESP")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var frUdp500 = new ForwardingRule("frUdp500", ForwardingRuleArgs.builder()
.ipProtocol("UDP")
.portRange("500")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var frUdp4500 = new ForwardingRule("frUdp4500", ForwardingRuleArgs.builder()
.ipProtocol("UDP")
.portRange("4500")
.ipAddress(vpnStaticIp.address())
.target(targetGateway.id())
.build());
var tunnel1 = new VPNTunnel("tunnel1", VPNTunnelArgs.builder()
.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()
.network(network1.name())
.destRange("15.0.0.0/24")
.priority(1000)
.nextHopVpnTunnel(tunnel1.id())
.build());
}
}
import pulumi
import pulumi_gcp as gcp
network1 = gcp.compute.Network("network1")
target_gateway = gcp.compute.VPNGateway("targetGateway", network=network1.id)
vpn_static_ip = gcp.compute.Address("vpnStaticIp")
fr_esp = gcp.compute.ForwardingRule("frEsp",
ip_protocol="ESP",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
fr_udp500 = gcp.compute.ForwardingRule("frUdp500",
ip_protocol="UDP",
port_range="500",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
fr_udp4500 = gcp.compute.ForwardingRule("frUdp4500",
ip_protocol="UDP",
port_range="4500",
ip_address=vpn_static_ip.address,
target=target_gateway.id)
tunnel1 = gcp.compute.VPNTunnel("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",
network=network1.name,
dest_range="15.0.0.0/24",
priority=1000,
next_hop_vpn_tunnel=tunnel1.id)
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const network1 = new gcp.compute.Network("network1", {});
const targetGateway = new gcp.compute.VPNGateway("targetGateway", {network: network1.id});
const vpnStaticIp = new gcp.compute.Address("vpnStaticIp", {});
const frEsp = new gcp.compute.ForwardingRule("frEsp", {
ipProtocol: "ESP",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const frUdp500 = new gcp.compute.ForwardingRule("frUdp500", {
ipProtocol: "UDP",
portRange: "500",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const frUdp4500 = new gcp.compute.ForwardingRule("frUdp4500", {
ipProtocol: "UDP",
portRange: "4500",
ipAddress: vpnStaticIp.address,
target: targetGateway.id,
});
const tunnel1 = new gcp.compute.VPNTunnel("tunnel1", {
peerIp: "15.0.0.120",
sharedSecret: "a secret message",
targetVpnGateway: targetGateway.id,
}, {
dependsOn: [
frEsp,
frUdp500,
frUdp4500,
],
});
const route1 = new gcp.compute.Route("route1", {
network: network1.name,
destRange: "15.0.0.0/24",
priority: 1000,
nextHopVpnTunnel: tunnel1.id,
});
resources:
targetGateway:
type: gcp:compute:VPNGateway
properties:
network: ${network1.id}
network1:
type: gcp:compute:Network
vpnStaticIp:
type: gcp:compute:Address
frEsp:
type: gcp:compute:ForwardingRule
properties:
ipProtocol: ESP
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
frUdp500:
type: gcp:compute:ForwardingRule
properties:
ipProtocol: UDP
portRange: '500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
frUdp4500:
type: gcp:compute:ForwardingRule
properties:
ipProtocol: UDP
portRange: '4500'
ipAddress: ${vpnStaticIp.address}
target: ${targetGateway.id}
tunnel1:
type: gcp:compute:VPNTunnel
properties:
peerIp: 15.0.0.120
sharedSecret: a secret message
targetVpnGateway: ${targetGateway.id}
options:
dependson:
- ${frEsp}
- ${frUdp500}
- ${frUdp4500}
route1:
type: gcp:compute:Route
properties:
network: ${network1.name}
destRange: 15.0.0.0/24
priority: 1000
nextHopVpnTunnel: ${tunnel1.id}
Create VPNGateway Resource
new VPNGateway(name: string, args: VPNGatewayArgs, opts?: CustomResourceOptions);
@overload
def VPNGateway(resource_name: str,
opts: Optional[ResourceOptions] = None,
description: Optional[str] = None,
name: Optional[str] = None,
network: Optional[str] = None,
project: Optional[str] = None,
region: Optional[str] = None)
@overload
def VPNGateway(resource_name: str,
args: VPNGatewayArgs,
opts: Optional[ResourceOptions] = 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.
- 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.
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
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.- 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.- 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.- 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.- 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.- 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.- 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,
project: Optional[str] = None,
region: Optional[str] = None,
self_link: Optional[str] = None) -> VPNGateway
func 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)
Resource lookup is not supported in YAML
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Import
VpnGateway can be imported using any of these accepted formats* projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}
* {{project}}/{{region}}/{{name}}
* {{region}}/{{name}}
* {{name}}
In Terraform v1.5.0 and later, use an import
block to import VpnGateway using one of the formats above. For exampletf import {
id = “projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}”
to = google_compute_vpn_gateway.default }
$ pulumi import gcp:compute/vPNGateway:VPNGateway When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), 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}}
Package Details
- Repository
- Google Cloud (GCP) Classic pulumi/pulumi-gcp
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
google-beta
Terraform Provider.