HostProjectRegistration class
Host project registration refers to the registration of a Google cloud project with API hub as a host project. This is the project where API hub is provisioned. It acts as the consumer project for the API hub instance provisioned. Multiple runtime projects can be attached to the host project and these attachments define the scope of API hub.
Example Usage
Apihub Host Project Registration Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as time from "@pulumiverse/time";
const project = new gcp.organizations.Project("project", {
name: "apihub-proj",
projectId: "apihub-proj",
orgId: "123456789",
billingAccount: "000000-0000000-0000000-000000",
deletionPolicy: "DELETE",
});
const wait60Seconds = new time.Sleep("wait_60_seconds", {createDuration: "60s"}, {
dependsOn: [project],
});
// Enable API hub API
const apihubService = new gcp.projects.Service("apihub_service", {
project: project.projectId,
service: "apihub.googleapis.com",
}, {
dependsOn: [wait60Seconds],
});
const apihubHostProject = new gcp.apihub.HostProjectRegistration("apihub_host_project", {
project: project.projectId,
location: "asia-south1",
hostProjectRegistrationId: project.projectId,
gcpProject: pulumi.interpolate`projects/${project.projectId}`,
}, {
dependsOn: [apihubService],
});
import pulumi
import pulumi_gcp as gcp
import pulumiverse_time as time
project = gcp.organizations.Project("project",
name="apihub-proj",
project_id="apihub-proj",
org_id="123456789",
billing_account="000000-0000000-0000000-000000",
deletion_policy="DELETE")
wait60_seconds = time.Sleep("wait_60_seconds", create_duration="60s",
opts = pulumi.ResourceOptions(depends_on=[project]))
# Enable API hub API
apihub_service = gcp.projects.Service("apihub_service",
project=project.project_id,
service="apihub.googleapis.com",
opts = pulumi.ResourceOptions(depends_on=[wait60_seconds]))
apihub_host_project = gcp.apihub.HostProjectRegistration("apihub_host_project",
project=project.project_id,
location="asia-south1",
host_project_registration_id=project.project_id,
gcp_project=project.project_id.apply(lambda project_id: f"projects/{project_id}"),
opts = pulumi.ResourceOptions(depends_on=[apihub_service]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
using Time = Pulumiverse.Time;
return await Deployment.RunAsync(() =>
{
var project = new Gcp.Organizations.Project("project", new()
{
Name = "apihub-proj",
ProjectId = "apihub-proj",
OrgId = "123456789",
BillingAccount = "000000-0000000-0000000-000000",
DeletionPolicy = "DELETE",
});
var wait60Seconds = new Time.Sleep("wait_60_seconds", new()
{
CreateDuration = "60s",
}, new CustomResourceOptions
{
DependsOn =
{
project,
},
});
// Enable API hub API
var apihubService = new Gcp.Projects.Service("apihub_service", new()
{
Project = project.ProjectId,
ServiceName = "apihub.googleapis.com",
}, new CustomResourceOptions
{
DependsOn =
{
wait60Seconds,
},
});
var apihubHostProject = new Gcp.ApiHub.HostProjectRegistration("apihub_host_project", new()
{
Project = project.ProjectId,
Location = "asia-south1",
HostProjectRegistrationId = project.ProjectId,
GcpProject = project.ProjectId.Apply(projectId => $"projects/{projectId}"),
}, new CustomResourceOptions
{
DependsOn =
{
apihubService,
},
});
});
package main
import (
"fmt"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/apihub"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/organizations"
"github.com/pulumi/pulumi-gcp/sdk/v9/go/gcp/projects"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumiverse/pulumi-time/sdk/go/time"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
project, err := organizations.NewProject(ctx, "project", &organizations.ProjectArgs{
Name: pulumi.String("apihub-proj"),
ProjectId: pulumi.String("apihub-proj"),
OrgId: pulumi.String("123456789"),
BillingAccount: pulumi.String("000000-0000000-0000000-000000"),
DeletionPolicy: pulumi.String("DELETE"),
})
if err != nil {
return err
}
wait60Seconds, err := time.NewSleep(ctx, "wait_60_seconds", &time.SleepArgs{
CreateDuration: pulumi.String("60s"),
}, pulumi.DependsOn([]pulumi.Resource{
project,
}))
if err != nil {
return err
}
// Enable API hub API
apihubService, err := projects.NewService(ctx, "apihub_service", &projects.ServiceArgs{
Project: project.ProjectId,
Service: pulumi.String("apihub.googleapis.com"),
}, pulumi.DependsOn([]pulumi.Resource{
wait60Seconds,
}))
if err != nil {
return err
}
_, err = apihub.NewHostProjectRegistration(ctx, "apihub_host_project", &apihub.HostProjectRegistrationArgs{
Project: project.ProjectId,
Location: pulumi.String("asia-south1"),
HostProjectRegistrationId: project.ProjectId,
GcpProject: project.ProjectId.ApplyT(func(projectId string) (string, error) {
return fmt.Sprintf("projects/%v", projectId), nil
}).(pulumi.StringOutput),
}, pulumi.DependsOn([]pulumi.Resource{
apihubService,
}))
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
gcp = {
source = "pulumi/gcp"
}
time = {
source = "pulumi/time"
}
}
}
resource "gcp_organizations_project" "project" {
name = "apihub-proj"
project_id = "apihub-proj"
org_id = "123456789"
billing_account = "000000-0000000-0000000-000000"
deletion_policy = "DELETE"
}
resource "time_sleep" "wait_60_seconds" {
depends_on = [gcp_organizations_project.project]
create_duration = "60s"
}
# Enable API hub API
resource "gcp_projects_service" "apihub_service" {
depends_on = [time_sleep.wait_60_seconds]
project = gcp_organizations_project.project.project_id
service = "apihub.googleapis.com"
}
resource "gcp_apihub_hostprojectregistration" "apihub_host_project" {
depends_on = [gcp_projects_service.apihub_service]
project = gcp_organizations_project.project.project_id
location = "asia-south1"
host_project_registration_id = gcp_organizations_project.project.project_id
gcp_project ="projects/${gcp_organizations_project.project.project_id}"
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.organizations.Project;
import com.pulumi.gcp.organizations.ProjectArgs;
import com.pulumiverse.time.Sleep;
import com.pulumiverse.time.SleepArgs;
import com.pulumi.gcp.projects.Service;
import com.pulumi.gcp.projects.ServiceArgs;
import com.pulumi.gcp.apihub.HostProjectRegistration;
import com.pulumi.gcp.apihub.HostProjectRegistrationArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
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 project = new Project("project", ProjectArgs.builder()
.name("apihub-proj")
.projectId("apihub-proj")
.orgId("123456789")
.billingAccount("000000-0000000-0000000-000000")
.deletionPolicy("DELETE")
.build());
var wait60Seconds = new Sleep("wait60Seconds", SleepArgs.builder()
.createDuration("60s")
.build(), CustomResourceOptions.builder()
.dependsOn(project)
.build());
// Enable API hub API
var apihubService = new Service("apihubService", ServiceArgs.builder()
.project(project.projectId())
.service("apihub.googleapis.com")
.build(), CustomResourceOptions.builder()
.dependsOn(wait60Seconds)
.build());
var apihubHostProject = new HostProjectRegistration("apihubHostProject", HostProjectRegistrationArgs.builder()
.project(project.projectId())
.location("asia-south1")
.hostProjectRegistrationId(project.projectId())
.gcpProject(project.projectId().applyValue(_projectId -> String.format("projects/%s", _projectId)))
.build(), CustomResourceOptions.builder()
.dependsOn(apihubService)
.build());
}
}
resources:
project:
type: gcp:organizations:Project
properties:
name: apihub-proj
projectId: apihub-proj
orgId: '123456789'
billingAccount: 000000-0000000-0000000-000000
deletionPolicy: DELETE
wait60Seconds:
type: time:Sleep
name: wait_60_seconds
properties:
createDuration: 60s
options:
dependsOn:
- ${project}
# Enable API hub API
apihubService:
type: gcp:projects:Service
name: apihub_service
properties:
project: ${project.projectId}
service: apihub.googleapis.com
options:
dependsOn:
- ${wait60Seconds}
apihubHostProject:
type: gcp:apihub:HostProjectRegistration
name: apihub_host_project
properties:
project: ${project.projectId}
location: asia-south1
hostProjectRegistrationId: ${project.projectId}
gcpProject: projects/${project.projectId}
options:
dependsOn:
- ${apihubService}
Import
HostProjectRegistration can be imported using any of these accepted formats:
projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}{{project}}/{{location}}/{{host_project_registration_id}}{{location}}/{{host_project_registration_id}}
When using the pulumi import command, HostProjectRegistration can be imported using one of the formats above. For example:
$ pulumi import gcp:apihub/hostProjectRegistration:HostProjectRegistration default projects/{{project}}/locations/{{location}}/hostProjectRegistrations/{{host_project_registration_id}}
$ pulumi import gcp:apihub/hostProjectRegistration:HostProjectRegistration default {{project}}/{{location}}/{{host_project_registration_id}}
$ pulumi import gcp:apihub/hostProjectRegistration:HostProjectRegistration default {{location}}/{{host_project_registration_id}}
Constructors
- HostProjectRegistration(String name, {HostProjectRegistrationArgs? args, CustomResourceOptions? options})
-
Creates a new HostProjectRegistration.
nameThe Pulumi resource name.argsArguments used to configure this HostProjectRegistration. The set of arguments for HostProjectRegistration.optionsResource options controlling this resource's behavior. - HostProjectRegistration.reference(String urn)
- Creates a typed reference to an existing HostProjectRegistration resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
createTime
↔ Output<
String> -
Output only. The time at which the host project registration was created.
latefinal
-
gcpProject
↔ Output<
String> -
Required. Immutable. Google cloud project name in the format: "projects/abc" or "projects/123".
As input, project name with either project id or number are accepted.
As output, this field will contain project number.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
hostProjectRegistrationId
↔ Output<
String> -
Required. The ID to use for the Host Project Registration, which will become the
final component of the host project registration's resource name. The ID
must be the same as the Google cloud project specified in the
host_project_registration.gcp_project field.
latefinal
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
location
↔ Output<
String> -
Part of
parent. See documentation ofprojectsId.latefinal -
name
↔ Output<
String> -
Identifier. The name of the host project registration.
Format:
"projects/{project}/locations/{location}/hostProjectRegistrations/{host_project_registration}".
latefinal
-
project
↔ Output<
String> -
The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {HostProjectRegistrationState? state, CustomResourceOptions? options}) → HostProjectRegistration -
Gets an existing HostProjectRegistration resource's state with the given
nameandid.