1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. servicenetworking
  5. Connection
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

gcp.servicenetworking.Connection

Explore with Pulumi AI

gcp logo
Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi

    Manages a private VPC connection with a GCP service provider. For more information see the official documentation and API.

    Example Usage

    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("peeringNetwork");
    
        // Create an IP address
        var privateIpAlloc = new Gcp.Compute.GlobalAddress("privateIpAlloc", new()
        {
            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("peeringRoutes", new()
        {
            Peering = @default.Peering,
            Network = peeringNetwork.Name,
            ImportCustomRoutes = true,
            ExportCustomRoutes = true,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/compute"
    	"github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/servicenetworking"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		peeringNetwork, err := compute.NewNetwork(ctx, "peeringNetwork", nil)
    		if err != nil {
    			return err
    		}
    		privateIpAlloc, err := compute.NewGlobalAddress(ctx, "privateIpAlloc", &compute.GlobalAddressArgs{
    			Purpose:      pulumi.String("VPC_PEERING"),
    			AddressType:  pulumi.String("INTERNAL"),
    			PrefixLength: pulumi.Int(16),
    			Network:      peeringNetwork.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		_, 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
    		}
    		_, err = compute.NewNetworkPeeringRoutesConfig(ctx, "peeringRoutes", &compute.NetworkPeeringRoutesConfigArgs{
    			Peering:            _default.Peering,
    			Network:            peeringNetwork.Name,
    			ImportCustomRoutes: pulumi.Bool(true),
    			ExportCustomRoutes: pulumi.Bool(true),
    		})
    		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.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) {
            var peeringNetwork = new Network("peeringNetwork");
    
            var privateIpAlloc = new GlobalAddress("privateIpAlloc", GlobalAddressArgs.builder()        
                .purpose("VPC_PEERING")
                .addressType("INTERNAL")
                .prefixLength(16)
                .network(peeringNetwork.id())
                .build());
    
            var default_ = new Connection("default", ConnectionArgs.builder()        
                .network(peeringNetwork.id())
                .service("servicenetworking.googleapis.com")
                .reservedPeeringRanges(privateIpAlloc.name())
                .build());
    
            var peeringRoutes = new NetworkPeeringRoutesConfig("peeringRoutes", NetworkPeeringRoutesConfigArgs.builder()        
                .peering(default_.peering())
                .network(peeringNetwork.name())
                .importCustomRoutes(true)
                .exportCustomRoutes(true)
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_gcp as gcp
    
    # Create a VPC network
    peering_network = gcp.compute.Network("peeringNetwork")
    # Create an IP address
    private_ip_alloc = gcp.compute.GlobalAddress("privateIpAlloc",
        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("peeringRoutes",
        peering=default.peering,
        network=peering_network.name,
        import_custom_routes=True,
        export_custom_routes=True)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as gcp from "@pulumi/gcp";
    
    // Create a VPC network
    const peeringNetwork = new gcp.compute.Network("peeringNetwork", {});
    // Create an IP address
    const privateIpAlloc = new gcp.compute.GlobalAddress("privateIpAlloc", {
        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("peeringRoutes", {
        peering: _default.peering,
        network: peeringNetwork.name,
        importCustomRoutes: true,
        exportCustomRoutes: true,
    });
    
    resources:
      # Create a VPC network
      peeringNetwork:
        type: gcp:compute:Network
      # Create an IP address
      privateIpAlloc:
        type: gcp:compute:GlobalAddress
        properties:
          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
        properties:
          peering: ${default.peering}
          network: ${peeringNetwork.name}
          importCustomRoutes: true
          exportCustomRoutes: true
    

    Create Connection Resource

    new Connection(name: string, args: ConnectionArgs, opts?: CustomResourceOptions);
    @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)
    @overload
    def Connection(resource_name: str,
                   args: ConnectionArgs,
                   opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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.

    ReservedPeeringRanges List<string>

    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'.

    Network string

    Name of VPC network connected with service producers using VPC peering.

    ReservedPeeringRanges []string

    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'.

    network String

    Name of VPC network connected with service producers using VPC peering.

    reservedPeeringRanges List<String>

    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'.

    network string

    Name of VPC network connected with service producers using VPC peering.

    reservedPeeringRanges string[]

    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'.

    network str

    Name of VPC network connected with service producers using VPC peering.

    reserved_peering_ranges Sequence[str]

    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'.

    network String

    Name of VPC network connected with service producers using VPC peering.

    reservedPeeringRanges List<String>

    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'.

    Outputs

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

    Id string

    The provider-assigned unique ID for this managed resource.

    Peering string

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    Id string

    The provider-assigned unique ID for this managed resource.

    Peering string

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    id String

    The provider-assigned unique ID for this managed resource.

    peering String

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    id string

    The provider-assigned unique ID for this managed resource.

    peering string

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    id str

    The provider-assigned unique ID for this managed resource.

    peering str

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    id String

    The provider-assigned unique ID for this managed resource.

    peering String

    (Computed) The name of the VPC Network Peering connection that was created by the service producer.

    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,
            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.
    The following state arguments are supported:
    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.

    ReservedPeeringRanges List<string>

    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'.

    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.

    ReservedPeeringRanges []string

    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'.

    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.

    reservedPeeringRanges List<String>

    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'.

    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.

    reservedPeeringRanges string[]

    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'.

    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_ranges Sequence[str]

    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'.

    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.

    reservedPeeringRanges List<String>

    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

     $ pulumi import gcp:servicenetworking/connection:Connection peering_connection {{peering-network}}:{{service}}
    
     $ pulumi import gcp:servicenetworking/connection:Connection peering_connection /projects/{{project}}/global/networks/{{peering-network}}:{{service}}
    

    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.

    gcp logo
    Google Cloud Classic v6.66.0 published on Monday, Sep 18, 2023 by Pulumi