1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. SharedVPCServiceProject
Google Cloud v8.25.1 published on Wednesday, Apr 9, 2025 by Pulumi

gcp.compute.SharedVPCServiceProject

Explore with Pulumi AI

Enables the Google Compute Engine Shared VPC feature for a project, assigning it as a Shared VPC service project associated with a given host project.

For more information, see, the Project API documentation, where the Shared VPC feature is referred to by its former name “XPN”.

Example Usage

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

const service1 = new gcp.compute.SharedVPCServiceProject("service1", {
    hostProject: "host-project-id",
    serviceProject: "service-project-id-1",
});
Copy
import pulumi
import pulumi_gcp as gcp

service1 = gcp.compute.SharedVPCServiceProject("service1",
    host_project="host-project-id",
    service_project="service-project-id-1")
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := compute.NewSharedVPCServiceProject(ctx, "service1", &compute.SharedVPCServiceProjectArgs{
			HostProject:    pulumi.String("host-project-id"),
			ServiceProject: pulumi.String("service-project-id-1"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var service1 = new Gcp.Compute.SharedVPCServiceProject("service1", new()
    {
        HostProject = "host-project-id",
        ServiceProject = "service-project-id-1",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.SharedVPCServiceProject;
import com.pulumi.gcp.compute.SharedVPCServiceProjectArgs;
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 service1 = new SharedVPCServiceProject("service1", SharedVPCServiceProjectArgs.builder()
            .hostProject("host-project-id")
            .serviceProject("service-project-id-1")
            .build());

    }
}
Copy
resources:
  service1:
    type: gcp:compute:SharedVPCServiceProject
    properties:
      hostProject: host-project-id
      serviceProject: service-project-id-1
Copy

For a complete Shared VPC example with both host and service projects, see gcp.compute.SharedVPCHostProject.

Create SharedVPCServiceProject Resource

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

Constructor syntax

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

@overload
def SharedVPCServiceProject(resource_name: str,
                            opts: Optional[ResourceOptions] = None,
                            host_project: Optional[str] = None,
                            service_project: Optional[str] = None,
                            deletion_policy: Optional[str] = None)
func NewSharedVPCServiceProject(ctx *Context, name string, args SharedVPCServiceProjectArgs, opts ...ResourceOption) (*SharedVPCServiceProject, error)
public SharedVPCServiceProject(string name, SharedVPCServiceProjectArgs args, CustomResourceOptions? opts = null)
public SharedVPCServiceProject(String name, SharedVPCServiceProjectArgs args)
public SharedVPCServiceProject(String name, SharedVPCServiceProjectArgs args, CustomResourceOptions options)
type: gcp:compute:SharedVPCServiceProject
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SharedVPCServiceProjectArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SharedVPCServiceProjectArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SharedVPCServiceProjectArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SharedVPCServiceProjectArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SharedVPCServiceProjectArgs
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 sharedVPCServiceProjectResource = new Gcp.Compute.SharedVPCServiceProject("sharedVPCServiceProjectResource", new()
{
    HostProject = "string",
    ServiceProject = "string",
    DeletionPolicy = "string",
});
Copy
example, err := compute.NewSharedVPCServiceProject(ctx, "sharedVPCServiceProjectResource", &compute.SharedVPCServiceProjectArgs{
	HostProject:    pulumi.String("string"),
	ServiceProject: pulumi.String("string"),
	DeletionPolicy: pulumi.String("string"),
})
Copy
var sharedVPCServiceProjectResource = new SharedVPCServiceProject("sharedVPCServiceProjectResource", SharedVPCServiceProjectArgs.builder()
    .hostProject("string")
    .serviceProject("string")
    .deletionPolicy("string")
    .build());
Copy
shared_vpc_service_project_resource = gcp.compute.SharedVPCServiceProject("sharedVPCServiceProjectResource",
    host_project="string",
    service_project="string",
    deletion_policy="string")
Copy
const sharedVPCServiceProjectResource = new gcp.compute.SharedVPCServiceProject("sharedVPCServiceProjectResource", {
    hostProject: "string",
    serviceProject: "string",
    deletionPolicy: "string",
});
Copy
type: gcp:compute:SharedVPCServiceProject
properties:
    deletionPolicy: string
    hostProject: string
    serviceProject: string
Copy

SharedVPCServiceProject 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 SharedVPCServiceProject resource accepts the following input properties:

HostProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of a host project to associate.
ServiceProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project that will serve as a Shared VPC service project.
DeletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
HostProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of a host project to associate.
ServiceProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project that will serve as a Shared VPC service project.
DeletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject
This property is required.
Changes to this property will trigger replacement.
String
The ID of a host project to associate.
serviceProject
This property is required.
Changes to this property will trigger replacement.
String
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy String
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of a host project to associate.
serviceProject
This property is required.
Changes to this property will trigger replacement.
string
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
host_project
This property is required.
Changes to this property will trigger replacement.
str
The ID of a host project to associate.
service_project
This property is required.
Changes to this property will trigger replacement.
str
The ID of the project that will serve as a Shared VPC service project.
deletion_policy str
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject
This property is required.
Changes to this property will trigger replacement.
String
The ID of a host project to associate.
serviceProject
This property is required.
Changes to this property will trigger replacement.
String
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy String
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing SharedVPCServiceProject Resource

Get an existing SharedVPCServiceProject 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?: SharedVPCServiceProjectState, opts?: CustomResourceOptions): SharedVPCServiceProject
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        deletion_policy: Optional[str] = None,
        host_project: Optional[str] = None,
        service_project: Optional[str] = None) -> SharedVPCServiceProject
func GetSharedVPCServiceProject(ctx *Context, name string, id IDInput, state *SharedVPCServiceProjectState, opts ...ResourceOption) (*SharedVPCServiceProject, error)
public static SharedVPCServiceProject Get(string name, Input<string> id, SharedVPCServiceProjectState? state, CustomResourceOptions? opts = null)
public static SharedVPCServiceProject get(String name, Output<String> id, SharedVPCServiceProjectState state, CustomResourceOptions options)
resources:  _:    type: gcp:compute:SharedVPCServiceProject    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
DeletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
HostProject Changes to this property will trigger replacement. string
The ID of a host project to associate.
ServiceProject Changes to this property will trigger replacement. string
The ID of the project that will serve as a Shared VPC service project.
DeletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
HostProject Changes to this property will trigger replacement. string
The ID of a host project to associate.
ServiceProject Changes to this property will trigger replacement. string
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy String
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject Changes to this property will trigger replacement. String
The ID of a host project to associate.
serviceProject Changes to this property will trigger replacement. String
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy string
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject Changes to this property will trigger replacement. string
The ID of a host project to associate.
serviceProject Changes to this property will trigger replacement. string
The ID of the project that will serve as a Shared VPC service project.
deletion_policy str
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
host_project Changes to this property will trigger replacement. str
The ID of a host project to associate.
service_project Changes to this property will trigger replacement. str
The ID of the project that will serve as a Shared VPC service project.
deletionPolicy String
The deletion policy for the shared VPC service. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: "ABANDON".
hostProject Changes to this property will trigger replacement. String
The ID of a host project to associate.
serviceProject Changes to this property will trigger replacement. String
The ID of the project that will serve as a Shared VPC service project.

Import

Google Compute Engine Shared VPC service project feature can be imported using the host_project and service_project, e.g.

  • {{host_project}/{{service_project}}

When using the pulumi import command, Google Compute Engine Shared VPC service project can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/sharedVPCServiceProject:SharedVPCServiceProject default {{host_project}/{{service_project}}
Copy

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.