gcp.servicenetworking.Connection
Explore with Pulumi AI
Manages a private VPC connection with a GCP service provider. For more information see the official documentation and API.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
// Create a VPC network
const peeringNetwork = new gcp.compute.Network("peering_network", {name: "peering-network"});
// Create an IP address
const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
name: "private-ip-alloc",
purpose: "VPC_PEERING",
addressType: "INTERNAL",
prefixLength: 16,
network: peeringNetwork.id,
});
// Create a private connection
const _default = new gcp.servicenetworking.Connection("default", {
network: peeringNetwork.id,
service: "servicenetworking.googleapis.com",
reservedPeeringRanges: [privateIpAlloc.name],
});
// (Optional) Import or export custom routes
const peeringRoutes = new gcp.compute.NetworkPeeringRoutesConfig("peering_routes", {
peering: _default.peering,
network: peeringNetwork.name,
importCustomRoutes: true,
exportCustomRoutes: true,
});
import pulumi
import pulumi_gcp as gcp
# Create a VPC network
peering_network = gcp.compute.Network("peering_network", name="peering-network")
# Create an IP address
private_ip_alloc = gcp.compute.GlobalAddress("private_ip_alloc",
name="private-ip-alloc",
purpose="VPC_PEERING",
address_type="INTERNAL",
prefix_length=16,
network=peering_network.id)
# Create a private connection
default = gcp.servicenetworking.Connection("default",
network=peering_network.id,
service="servicenetworking.googleapis.com",
reserved_peering_ranges=[private_ip_alloc.name])
# (Optional) Import or export custom routes
peering_routes = gcp.compute.NetworkPeeringRoutesConfig("peering_routes",
peering=default.peering,
network=peering_network.name,
import_custom_routes=True,
export_custom_routes=True)
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/servicenetworking"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Create a VPC network
peeringNetwork, err := compute.NewNetwork(ctx, "peering_network", &compute.NetworkArgs{
Name: pulumi.String("peering-network"),
})
if err != nil {
return err
}
// Create an IP address
privateIpAlloc, err := compute.NewGlobalAddress(ctx, "private_ip_alloc", &compute.GlobalAddressArgs{
Name: pulumi.String("private-ip-alloc"),
Purpose: pulumi.String("VPC_PEERING"),
AddressType: pulumi.String("INTERNAL"),
PrefixLength: pulumi.Int(16),
Network: peeringNetwork.ID(),
})
if err != nil {
return err
}
// Create a private connection
_, err = servicenetworking.NewConnection(ctx, "default", &servicenetworking.ConnectionArgs{
Network: peeringNetwork.ID(),
Service: pulumi.String("servicenetworking.googleapis.com"),
ReservedPeeringRanges: pulumi.StringArray{
privateIpAlloc.Name,
},
})
if err != nil {
return err
}
// (Optional) Import or export custom routes
_, err = compute.NewNetworkPeeringRoutesConfig(ctx, "peering_routes", &compute.NetworkPeeringRoutesConfigArgs{
Peering: _default.Peering,
Network: peeringNetwork.Name,
ImportCustomRoutes: pulumi.Bool(true),
ExportCustomRoutes: pulumi.Bool(true),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
// Create a VPC network
var peeringNetwork = new Gcp.Compute.Network("peering_network", new()
{
Name = "peering-network",
});
// Create an IP address
var privateIpAlloc = new Gcp.Compute.GlobalAddress("private_ip_alloc", new()
{
Name = "private-ip-alloc",
Purpose = "VPC_PEERING",
AddressType = "INTERNAL",
PrefixLength = 16,
Network = peeringNetwork.Id,
});
// Create a private connection
var @default = new Gcp.ServiceNetworking.Connection("default", new()
{
Network = peeringNetwork.Id,
Service = "servicenetworking.googleapis.com",
ReservedPeeringRanges = new[]
{
privateIpAlloc.Name,
},
});
// (Optional) Import or export custom routes
var peeringRoutes = new Gcp.Compute.NetworkPeeringRoutesConfig("peering_routes", new()
{
Peering = @default.Peering,
Network = peeringNetwork.Name,
ImportCustomRoutes = true,
ExportCustomRoutes = true,
});
});
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.GlobalAddress;
import com.pulumi.gcp.compute.GlobalAddressArgs;
import com.pulumi.gcp.servicenetworking.Connection;
import com.pulumi.gcp.servicenetworking.ConnectionArgs;
import com.pulumi.gcp.compute.NetworkPeeringRoutesConfig;
import com.pulumi.gcp.compute.NetworkPeeringRoutesConfigArgs;
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) {
// Create a VPC network
var peeringNetwork = new Network("peeringNetwork", NetworkArgs.builder()
.name("peering-network")
.build());
// Create an IP address
var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()
.name("private-ip-alloc")
.purpose("VPC_PEERING")
.addressType("INTERNAL")
.prefixLength(16)
.network(peeringNetwork.id())
.build());
// Create a private connection
var default_ = new Connection("default", ConnectionArgs.builder()
.network(peeringNetwork.id())
.service("servicenetworking.googleapis.com")
.reservedPeeringRanges(privateIpAlloc.name())
.build());
// (Optional) Import or export custom routes
var peeringRoutes = new NetworkPeeringRoutesConfig("peeringRoutes", NetworkPeeringRoutesConfigArgs.builder()
.peering(default_.peering())
.network(peeringNetwork.name())
.importCustomRoutes(true)
.exportCustomRoutes(true)
.build());
}
}
resources:
# Create a VPC network
peeringNetwork:
type: gcp:compute:Network
name: peering_network
properties:
name: peering-network
# Create an IP address
privateIpAlloc:
type: gcp:compute:GlobalAddress
name: private_ip_alloc
properties:
name: private-ip-alloc
purpose: VPC_PEERING
addressType: INTERNAL
prefixLength: 16
network: ${peeringNetwork.id}
# Create a private connection
default:
type: gcp:servicenetworking:Connection
properties:
network: ${peeringNetwork.id}
service: servicenetworking.googleapis.com
reservedPeeringRanges:
- ${privateIpAlloc.name}
# (Optional) Import or export custom routes
peeringRoutes:
type: gcp:compute:NetworkPeeringRoutesConfig
name: peering_routes
properties:
peering: ${default.peering}
network: ${peeringNetwork.name}
importCustomRoutes: true
exportCustomRoutes: true
Create Connection Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Connection(name: string, args: ConnectionArgs, opts?: CustomResourceOptions);
@overload
def Connection(resource_name: str,
args: ConnectionArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Connection(resource_name: str,
opts: Optional[ResourceOptions] = None,
network: Optional[str] = None,
reserved_peering_ranges: Optional[Sequence[str]] = None,
service: Optional[str] = None,
deletion_policy: Optional[str] = None)
func NewConnection(ctx *Context, name string, args ConnectionArgs, opts ...ResourceOption) (*Connection, error)
public Connection(string name, ConnectionArgs args, CustomResourceOptions? opts = null)
public Connection(String name, ConnectionArgs args)
public Connection(String name, ConnectionArgs args, CustomResourceOptions options)
type: gcp:servicenetworking:Connection
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 ConnectionArgs
- 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 ConnectionArgs
- 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 ConnectionArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ConnectionArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ConnectionArgs
- 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 exampleconnectionResourceResourceFromServicenetworkingconnection = new Gcp.ServiceNetworking.Connection("exampleconnectionResourceResourceFromServicenetworkingconnection", new()
{
Network = "string",
ReservedPeeringRanges = new[]
{
"string",
},
Service = "string",
DeletionPolicy = "string",
});
example, err := servicenetworking.NewConnection(ctx, "exampleconnectionResourceResourceFromServicenetworkingconnection", &servicenetworking.ConnectionArgs{
Network: pulumi.String("string"),
ReservedPeeringRanges: pulumi.StringArray{
pulumi.String("string"),
},
Service: pulumi.String("string"),
DeletionPolicy: pulumi.String("string"),
})
var exampleconnectionResourceResourceFromServicenetworkingconnection = new Connection("exampleconnectionResourceResourceFromServicenetworkingconnection", ConnectionArgs.builder()
.network("string")
.reservedPeeringRanges("string")
.service("string")
.deletionPolicy("string")
.build());
exampleconnection_resource_resource_from_servicenetworkingconnection = gcp.servicenetworking.Connection("exampleconnectionResourceResourceFromServicenetworkingconnection",
network="string",
reserved_peering_ranges=["string"],
service="string",
deletion_policy="string")
const exampleconnectionResourceResourceFromServicenetworkingconnection = new gcp.servicenetworking.Connection("exampleconnectionResourceResourceFromServicenetworkingconnection", {
network: "string",
reservedPeeringRanges: ["string"],
service: "string",
deletionPolicy: "string",
});
type: gcp:servicenetworking:Connection
properties:
deletionPolicy: string
network: string
reservedPeeringRanges:
- string
service: string
Connection 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 Connection resource accepts the following input properties:
- Network string
- Name of VPC network connected with service producers using VPC peering.
- Reserved
Peering List<string>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- Service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- Deletion
Policy string
- Network string
- Name of VPC network connected with service producers using VPC peering.
- Reserved
Peering []stringRanges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- Service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- Deletion
Policy string
- network String
- Name of VPC network connected with service producers using VPC peering.
- reserved
Peering List<String>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service String
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy String
- network string
- Name of VPC network connected with service producers using VPC peering.
- reserved
Peering string[]Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy string
- network str
- Name of VPC network connected with service producers using VPC peering.
- reserved_
peering_ Sequence[str]ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service str
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion_
policy str
- network String
- Name of VPC network connected with service producers using VPC peering.
- reserved
Peering List<String>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service String
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy String
Outputs
All input properties are implicitly available as output properties. Additionally, the Connection resource produces the following output properties:
Look up Existing Connection Resource
Get an existing Connection 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?: ConnectionState, opts?: CustomResourceOptions): Connection
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
deletion_policy: Optional[str] = None,
network: Optional[str] = None,
peering: Optional[str] = None,
reserved_peering_ranges: Optional[Sequence[str]] = None,
service: Optional[str] = None) -> Connection
func GetConnection(ctx *Context, name string, id IDInput, state *ConnectionState, opts ...ResourceOption) (*Connection, error)
public static Connection Get(string name, Input<string> id, ConnectionState? state, CustomResourceOptions? opts = null)
public static Connection get(String name, Output<String> id, ConnectionState 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.
- Deletion
Policy string - Network string
- Name of VPC network connected with service producers using VPC peering.
- Peering string
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- Reserved
Peering List<string>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- Service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- Deletion
Policy string - Network string
- Name of VPC network connected with service producers using VPC peering.
- Peering string
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- Reserved
Peering []stringRanges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- Service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy String - network String
- Name of VPC network connected with service producers using VPC peering.
- peering String
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- reserved
Peering List<String>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service String
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy string - network string
- Name of VPC network connected with service producers using VPC peering.
- peering string
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- reserved
Peering string[]Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service string
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion_
policy str - network str
- Name of VPC network connected with service producers using VPC peering.
- peering str
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- reserved_
peering_ Sequence[str]ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service str
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
- deletion
Policy String - network String
- Name of VPC network connected with service producers using VPC peering.
- peering String
- (Computed) The name of the VPC Network Peering connection that was created by the service producer.
- reserved
Peering List<String>Ranges - Named IP address range(s) of PEERING type reserved for this service provider. Note that invoking this method with a different range when connection is already established will not reallocate already provisioned service producer subnetworks.
- service String
- Provider peering service that is managing peering connectivity for a service provider organization. For Google services that support this functionality it is 'servicenetworking.googleapis.com'.
Import
ServiceNetworkingConnection can be imported using any of these accepted formats
{{peering-network}}:{{service}}
projects/{{project}}/global/networks/{{peering-network}}:{{service}}
When using the pulumi import
command, NAME_HERE can be imported using one of the formats above. For example:
$ pulumi import gcp:servicenetworking/connection:Connection default {{peering-network}}:{{service}}
$ pulumi import gcp:servicenetworking/connection:Connection default /projects/{{project}}/global/networks/{{peering-network}}:{{service}}
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-beta
Terraform Provider.