UNPKG

@pulumi/gcp

Version:

A Pulumi package for creating and managing Google Cloud Platform resources.

329 lines • 12.7 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Service = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Service is a network/api interface that exposes some functionality to clients for consumption over the network. Service typically has one or more Workloads behind it. It registers identified service to the Application. * * ## Example Usage * * ### Apphub Service Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const application = new gcp.apphub.Application("application", { * location: "us-central1", * applicationId: "example-application-1", * scope: { * type: "REGIONAL", * }, * }); * const serviceProject = new gcp.organizations.Project("service_project", { * projectId: "project-1", * name: "Service Project", * orgId: "123456789", * billingAccount: "000000-0000000-0000000-000000", * deletionPolicy: "DELETE", * }); * // Enable Compute API * const computeServiceProject = new gcp.projects.Service("compute_service_project", { * project: serviceProject.projectId, * service: "compute.googleapis.com", * }); * const wait120s = new time.index.Sleep("wait_120s", {createDuration: "120s"}, { * dependsOn: [computeServiceProject], * }); * const serviceProjectAttachment = new gcp.apphub.ServiceProjectAttachment("service_project_attachment", {serviceProjectAttachmentId: serviceProject.projectId}, { * dependsOn: [wait120s], * }); * // VPC network * const ilbNetwork = new gcp.compute.Network("ilb_network", { * name: "l7-ilb-network", * project: serviceProject.projectId, * autoCreateSubnetworks: false, * }, { * dependsOn: [wait120s], * }); * // backend subnet * const ilbSubnet = new gcp.compute.Subnetwork("ilb_subnet", { * name: "l7-ilb-subnet", * project: serviceProject.projectId, * ipCidrRange: "10.0.1.0/24", * region: "us-central1", * network: ilbNetwork.id, * }); * // health check * const _default = new gcp.compute.HealthCheck("default", { * name: "l7-ilb-hc", * project: serviceProject.projectId, * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }, { * dependsOn: [wait120s], * }); * // backend service * const backend = new gcp.compute.RegionBackendService("backend", { * name: "l7-ilb-backend-subnet", * project: serviceProject.projectId, * region: "us-central1", * healthChecks: _default.id, * }); * // forwarding rule * const forwardingRule = new gcp.compute.ForwardingRule("forwarding_rule", { * name: "l7-ilb-forwarding-rule", * project: serviceProject.projectId, * region: "us-central1", * ipVersion: "IPV4", * loadBalancingScheme: "INTERNAL", * allPorts: true, * backendService: backend.id, * network: ilbNetwork.id, * subnetwork: ilbSubnet.id, * }); * // discovered service block * const catalog_service = gcp.apphub.getDiscoveredServiceOutput({ * location: "us-central1", * serviceUri: pulumi.interpolate`//compute.googleapis.com/${forwardingRule.id}`, * }); * const wait120sForResourceIngestion = new time.index.Sleep("wait_120s_for_resource_ingestion", {createDuration: "120s"}, { * dependsOn: [forwardingRule], * }); * const example = new gcp.apphub.Service("example", { * location: "us-central1", * applicationId: application.applicationId, * serviceId: forwardingRule.name, * discoveredService: catalog_service.apply(catalog_service => catalog_service.name), * }); * ``` * ### Apphub Service Full * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const application = new gcp.apphub.Application("application", { * location: "us-central1", * applicationId: "example-application-1", * scope: { * type: "REGIONAL", * }, * }); * const serviceProject = new gcp.organizations.Project("service_project", { * projectId: "project-1", * name: "Service Project", * orgId: "123456789", * billingAccount: "000000-0000000-0000000-000000", * deletionPolicy: "DELETE", * }); * // Enable Compute API * const computeServiceProject = new gcp.projects.Service("compute_service_project", { * project: serviceProject.projectId, * service: "compute.googleapis.com", * }); * const wait120s = new time.index.Sleep("wait_120s", {createDuration: "120s"}, { * dependsOn: [computeServiceProject], * }); * const serviceProjectAttachment = new gcp.apphub.ServiceProjectAttachment("service_project_attachment", {serviceProjectAttachmentId: serviceProject.projectId}, { * dependsOn: [wait120s], * }); * // VPC network * const ilbNetwork = new gcp.compute.Network("ilb_network", { * name: "l7-ilb-network", * project: serviceProject.projectId, * autoCreateSubnetworks: false, * }, { * dependsOn: [wait120s], * }); * // backend subnet * const ilbSubnet = new gcp.compute.Subnetwork("ilb_subnet", { * name: "l7-ilb-subnet", * project: serviceProject.projectId, * ipCidrRange: "10.0.1.0/24", * region: "us-central1", * network: ilbNetwork.id, * }); * // health check * const _default = new gcp.compute.HealthCheck("default", { * name: "l7-ilb-hc", * project: serviceProject.projectId, * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }, { * dependsOn: [wait120s], * }); * // backend service * const backend = new gcp.compute.RegionBackendService("backend", { * name: "l7-ilb-backend-subnet", * project: serviceProject.projectId, * region: "us-central1", * healthChecks: _default.id, * }); * // forwarding rule * const forwardingRule = new gcp.compute.ForwardingRule("forwarding_rule", { * name: "l7-ilb-forwarding-rule", * project: serviceProject.projectId, * region: "us-central1", * ipVersion: "IPV4", * loadBalancingScheme: "INTERNAL", * allPorts: true, * backendService: backend.id, * network: ilbNetwork.id, * subnetwork: ilbSubnet.id, * }); * // discovered service block * const catalog_service = gcp.apphub.getDiscoveredServiceOutput({ * location: "us-central1", * serviceUri: pulumi.interpolate`//compute.googleapis.com/${forwardingRule.id}`, * }); * const wait120sForResourceIngestion = new time.index.Sleep("wait_120s_for_resource_ingestion", {createDuration: "120s"}, { * dependsOn: [forwardingRule], * }); * const example = new gcp.apphub.Service("example", { * location: "us-central1", * applicationId: application.applicationId, * serviceId: forwardingRule.name, * discoveredService: catalog_service.apply(catalog_service => catalog_service.name), * displayName: "Example Service Full", * description: "Register service for testing", * attributes: { * environment: { * type: "STAGING", * }, * criticality: { * type: "MISSION_CRITICAL", * }, * businessOwners: [{ * displayName: "Alice", * email: "alice@google.com", * }], * developerOwners: [{ * displayName: "Bob", * email: "bob@google.com", * }], * operatorOwners: [{ * displayName: "Charlie", * email: "charlie@google.com", * }], * }, * }); * ``` * * ## Import * * Service can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/applications/{{application_id}}/services/{{service_id}}` * * * `{{project}}/{{location}}/{{application_id}}/{{service_id}}` * * * `{{location}}/{{application_id}}/{{service_id}}` * * When using the `pulumi import` command, Service can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:apphub/service:Service default projects/{{project}}/locations/{{location}}/applications/{{application_id}}/services/{{service_id}} * ``` * * ```sh * $ pulumi import gcp:apphub/service:Service default {{project}}/{{location}}/{{application_id}}/{{service_id}} * ``` * * ```sh * $ pulumi import gcp:apphub/service:Service default {{location}}/{{application_id}}/{{service_id}} * ``` */ class Service extends pulumi.CustomResource { /** * Get an existing Service resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Service(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Service. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Service.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["applicationId"] = state?.applicationId; resourceInputs["attributes"] = state?.attributes; resourceInputs["createTime"] = state?.createTime; resourceInputs["description"] = state?.description; resourceInputs["discoveredService"] = state?.discoveredService; resourceInputs["displayName"] = state?.displayName; resourceInputs["location"] = state?.location; resourceInputs["name"] = state?.name; resourceInputs["project"] = state?.project; resourceInputs["serviceId"] = state?.serviceId; resourceInputs["serviceProperties"] = state?.serviceProperties; resourceInputs["serviceReferences"] = state?.serviceReferences; resourceInputs["state"] = state?.state; resourceInputs["uid"] = state?.uid; resourceInputs["updateTime"] = state?.updateTime; } else { const args = argsOrState; if (args?.applicationId === undefined && !opts.urn) { throw new Error("Missing required property 'applicationId'"); } if (args?.discoveredService === undefined && !opts.urn) { throw new Error("Missing required property 'discoveredService'"); } if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } if (args?.serviceId === undefined && !opts.urn) { throw new Error("Missing required property 'serviceId'"); } resourceInputs["applicationId"] = args?.applicationId; resourceInputs["attributes"] = args?.attributes; resourceInputs["description"] = args?.description; resourceInputs["discoveredService"] = args?.discoveredService; resourceInputs["displayName"] = args?.displayName; resourceInputs["location"] = args?.location; resourceInputs["project"] = args?.project; resourceInputs["serviceId"] = args?.serviceId; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; resourceInputs["serviceProperties"] = undefined /*out*/; resourceInputs["serviceReferences"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["uid"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Service.__pulumiType, name, resourceInputs, opts); } } exports.Service = Service; /** @internal */ Service.__pulumiType = 'gcp:apphub/service:Service'; //# sourceMappingURL=service.js.map