UNPKG

@pulumi/gcp

Version:

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

430 lines • 17.7 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.ServiceAttachment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Represents a ServiceAttachment resource. * * To get more information about ServiceAttachment, see: * * * [API documentation](https://cloud.google.com/compute/docs/reference/beta/serviceAttachments) * * How-to Guides * * [Configuring Private Service Connect to access services](https://cloud.google.com/vpc/docs/configure-private-service-connect-services) * * ## Example Usage * * ### Service Attachment Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const producerServiceHealthCheck = new gcp.compute.HealthCheck("producer_service_health_check", { * name: "producer-service-health-check", * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }); * const producerServiceBackend = new gcp.compute.RegionBackendService("producer_service_backend", { * name: "producer-service", * region: "us-west2", * healthChecks: producerServiceHealthCheck.id, * }); * const pscIlbNetwork = new gcp.compute.Network("psc_ilb_network", { * name: "psc-ilb-network", * autoCreateSubnetworks: false, * }); * const pscIlbProducerSubnetwork = new gcp.compute.Subnetwork("psc_ilb_producer_subnetwork", { * name: "psc-ilb-producer-subnetwork", * region: "us-west2", * network: pscIlbNetwork.id, * ipCidrRange: "10.0.0.0/16", * }); * const pscIlbTargetService = new gcp.compute.ForwardingRule("psc_ilb_target_service", { * name: "producer-forwarding-rule", * region: "us-west2", * loadBalancingScheme: "INTERNAL", * backendService: producerServiceBackend.id, * allPorts: true, * network: pscIlbNetwork.name, * subnetwork: pscIlbProducerSubnetwork.name, * }); * const pscIlbNat = new gcp.compute.Subnetwork("psc_ilb_nat", { * name: "psc-ilb-nat", * region: "us-west2", * network: pscIlbNetwork.id, * purpose: "PRIVATE_SERVICE_CONNECT", * ipCidrRange: "10.1.0.0/16", * }); * const pscIlbServiceAttachment = new gcp.compute.ServiceAttachment("psc_ilb_service_attachment", { * name: "my-psc-ilb", * region: "us-west2", * description: "A service attachment configured with Terraform", * domainNames: ["gcp.tfacc.hashicorptest.com."], * enableProxyProtocol: true, * connectionPreference: "ACCEPT_AUTOMATIC", * natSubnets: [pscIlbNat.id], * targetService: pscIlbTargetService.id, * }); * const pscIlbConsumerAddress = new gcp.compute.Address("psc_ilb_consumer_address", { * name: "psc-ilb-consumer-address", * region: "us-west2", * subnetwork: "default", * addressType: "INTERNAL", * }); * const pscIlbConsumer = new gcp.compute.ForwardingRule("psc_ilb_consumer", { * name: "psc-ilb-consumer-forwarding-rule", * region: "us-west2", * target: pscIlbServiceAttachment.id, * loadBalancingScheme: "", * network: "default", * ipAddress: pscIlbConsumerAddress.id, * }); * ``` * ### Service Attachment Explicit Projects * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const producerServiceHealthCheck = new gcp.compute.HealthCheck("producer_service_health_check", { * name: "producer-service-health-check", * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }); * const producerServiceBackend = new gcp.compute.RegionBackendService("producer_service_backend", { * name: "producer-service", * region: "us-west2", * healthChecks: producerServiceHealthCheck.id, * }); * const pscIlbNetwork = new gcp.compute.Network("psc_ilb_network", { * name: "psc-ilb-network", * autoCreateSubnetworks: false, * }); * const pscIlbProducerSubnetwork = new gcp.compute.Subnetwork("psc_ilb_producer_subnetwork", { * name: "psc-ilb-producer-subnetwork", * region: "us-west2", * network: pscIlbNetwork.id, * ipCidrRange: "10.0.0.0/16", * }); * const pscIlbTargetService = new gcp.compute.ForwardingRule("psc_ilb_target_service", { * name: "producer-forwarding-rule", * region: "us-west2", * loadBalancingScheme: "INTERNAL", * backendService: producerServiceBackend.id, * allPorts: true, * network: pscIlbNetwork.name, * subnetwork: pscIlbProducerSubnetwork.name, * }); * const pscIlbNat = new gcp.compute.Subnetwork("psc_ilb_nat", { * name: "psc-ilb-nat", * region: "us-west2", * network: pscIlbNetwork.id, * purpose: "PRIVATE_SERVICE_CONNECT", * ipCidrRange: "10.1.0.0/16", * }); * const pscIlbServiceAttachment = new gcp.compute.ServiceAttachment("psc_ilb_service_attachment", { * name: "my-psc-ilb", * region: "us-west2", * description: "A service attachment configured with Terraform", * domainNames: ["gcp.tfacc.hashicorptest.com."], * enableProxyProtocol: true, * connectionPreference: "ACCEPT_MANUAL", * natSubnets: [pscIlbNat.id], * targetService: pscIlbTargetService.id, * consumerRejectLists: [ * "673497134629", * "482878270665", * ], * consumerAcceptLists: [{ * projectIdOrNum: "658859330310", * connectionLimit: 4, * }], * }); * const pscIlbConsumerAddress = new gcp.compute.Address("psc_ilb_consumer_address", { * name: "psc-ilb-consumer-address", * region: "us-west2", * subnetwork: "default", * addressType: "INTERNAL", * }); * const pscIlbConsumer = new gcp.compute.ForwardingRule("psc_ilb_consumer", { * name: "psc-ilb-consumer-forwarding-rule", * region: "us-west2", * target: pscIlbServiceAttachment.id, * loadBalancingScheme: "", * network: "default", * ipAddress: pscIlbConsumerAddress.id, * }); * ``` * ### Service Attachment Explicit Networks * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const pscIlbConsumerNetwork = new gcp.compute.Network("psc_ilb_consumer_network", { * name: "psc-ilb-consumer-network", * autoCreateSubnetworks: false, * }); * const producerServiceHealthCheck = new gcp.compute.HealthCheck("producer_service_health_check", { * name: "producer-service-health-check", * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }); * const producerServiceBackend = new gcp.compute.RegionBackendService("producer_service_backend", { * name: "producer-service", * region: "us-west2", * healthChecks: producerServiceHealthCheck.id, * }); * const pscIlbNetwork = new gcp.compute.Network("psc_ilb_network", { * name: "psc-ilb-network", * autoCreateSubnetworks: false, * }); * const pscIlbProducerSubnetwork = new gcp.compute.Subnetwork("psc_ilb_producer_subnetwork", { * name: "psc-ilb-producer-subnetwork", * region: "us-west2", * network: pscIlbNetwork.id, * ipCidrRange: "10.0.0.0/16", * }); * const pscIlbTargetService = new gcp.compute.ForwardingRule("psc_ilb_target_service", { * name: "producer-forwarding-rule", * region: "us-west2", * loadBalancingScheme: "INTERNAL", * backendService: producerServiceBackend.id, * allPorts: true, * network: pscIlbNetwork.name, * subnetwork: pscIlbProducerSubnetwork.name, * }); * const pscIlbNat = new gcp.compute.Subnetwork("psc_ilb_nat", { * name: "psc-ilb-nat", * region: "us-west2", * network: pscIlbNetwork.id, * purpose: "PRIVATE_SERVICE_CONNECT", * ipCidrRange: "10.1.0.0/16", * }); * const pscIlbServiceAttachment = new gcp.compute.ServiceAttachment("psc_ilb_service_attachment", { * name: "my-psc-ilb", * region: "us-west2", * description: "A service attachment configured with Terraform", * enableProxyProtocol: false, * connectionPreference: "ACCEPT_MANUAL", * natSubnets: [pscIlbNat.id], * targetService: pscIlbTargetService.id, * consumerAcceptLists: [{ * networkUrl: pscIlbConsumerNetwork.selfLink, * connectionLimit: 1, * }], * }); * const pscIlbConsumerSubnetwork = new gcp.compute.Subnetwork("psc_ilb_consumer_subnetwork", { * name: "psc-ilb-consumer-network", * ipCidrRange: "10.0.0.0/16", * region: "us-west2", * network: pscIlbConsumerNetwork.id, * }); * const pscIlbConsumerAddress = new gcp.compute.Address("psc_ilb_consumer_address", { * name: "psc-ilb-consumer-address", * region: "us-west2", * subnetwork: pscIlbConsumerSubnetwork.id, * addressType: "INTERNAL", * }); * const pscIlbConsumer = new gcp.compute.ForwardingRule("psc_ilb_consumer", { * name: "psc-ilb-consumer-forwarding-rule", * region: "us-west2", * target: pscIlbServiceAttachment.id, * loadBalancingScheme: "", * network: pscIlbConsumerNetwork.id, * subnetwork: pscIlbConsumerSubnetwork.id, * ipAddress: pscIlbConsumerAddress.id, * }); * ``` * ### Service Attachment Reconcile Connections * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const producerServiceHealthCheck = new gcp.compute.HealthCheck("producer_service_health_check", { * name: "producer-service-health-check", * checkIntervalSec: 1, * timeoutSec: 1, * tcpHealthCheck: { * port: 80, * }, * }); * const producerServiceBackend = new gcp.compute.RegionBackendService("producer_service_backend", { * name: "producer-service", * region: "us-west2", * healthChecks: producerServiceHealthCheck.id, * }); * const pscIlbNetwork = new gcp.compute.Network("psc_ilb_network", { * name: "psc-ilb-network", * autoCreateSubnetworks: false, * }); * const pscIlbProducerSubnetwork = new gcp.compute.Subnetwork("psc_ilb_producer_subnetwork", { * name: "psc-ilb-producer-subnetwork", * region: "us-west2", * network: pscIlbNetwork.id, * ipCidrRange: "10.0.0.0/16", * }); * const pscIlbTargetService = new gcp.compute.ForwardingRule("psc_ilb_target_service", { * name: "producer-forwarding-rule", * region: "us-west2", * loadBalancingScheme: "INTERNAL", * backendService: producerServiceBackend.id, * allPorts: true, * network: pscIlbNetwork.name, * subnetwork: pscIlbProducerSubnetwork.name, * }); * const pscIlbNat = new gcp.compute.Subnetwork("psc_ilb_nat", { * name: "psc-ilb-nat", * region: "us-west2", * network: pscIlbNetwork.id, * purpose: "PRIVATE_SERVICE_CONNECT", * ipCidrRange: "10.1.0.0/16", * }); * const pscIlbServiceAttachment = new gcp.compute.ServiceAttachment("psc_ilb_service_attachment", { * name: "my-psc-ilb", * region: "us-west2", * description: "A service attachment configured with Terraform", * domainNames: ["gcp.tfacc.hashicorptest.com."], * enableProxyProtocol: true, * connectionPreference: "ACCEPT_MANUAL", * natSubnets: [pscIlbNat.id], * targetService: pscIlbTargetService.id, * consumerRejectLists: [ * "673497134629", * "482878270665", * ], * consumerAcceptLists: [{ * projectIdOrNum: "658859330310", * connectionLimit: 4, * }], * reconcileConnections: false, * }); * ``` * * ## Import * * ServiceAttachment can be imported using any of these accepted formats: * * * `projects/{{project}}/regions/{{region}}/serviceAttachments/{{name}}` * * * `{{project}}/{{region}}/{{name}}` * * * `{{region}}/{{name}}` * * * `{{name}}` * * When using the `pulumi import` command, ServiceAttachment can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:compute/serviceAttachment:ServiceAttachment default projects/{{project}}/regions/{{region}}/serviceAttachments/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/serviceAttachment:ServiceAttachment default {{project}}/{{region}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/serviceAttachment:ServiceAttachment default {{region}}/{{name}} * ``` * * ```sh * $ pulumi import gcp:compute/serviceAttachment:ServiceAttachment default {{name}} * ``` */ class ServiceAttachment extends pulumi.CustomResource { /** * Get an existing ServiceAttachment 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 ServiceAttachment(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of ServiceAttachment. 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'] === ServiceAttachment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["connectedEndpoints"] = state ? state.connectedEndpoints : undefined; resourceInputs["connectionPreference"] = state ? state.connectionPreference : undefined; resourceInputs["consumerAcceptLists"] = state ? state.consumerAcceptLists : undefined; resourceInputs["consumerRejectLists"] = state ? state.consumerRejectLists : undefined; resourceInputs["description"] = state ? state.description : undefined; resourceInputs["domainNames"] = state ? state.domainNames : undefined; resourceInputs["enableProxyProtocol"] = state ? state.enableProxyProtocol : undefined; resourceInputs["fingerprint"] = state ? state.fingerprint : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["natSubnets"] = state ? state.natSubnets : undefined; resourceInputs["project"] = state ? state.project : undefined; resourceInputs["propagatedConnectionLimit"] = state ? state.propagatedConnectionLimit : undefined; resourceInputs["reconcileConnections"] = state ? state.reconcileConnections : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["selfLink"] = state ? state.selfLink : undefined; resourceInputs["targetService"] = state ? state.targetService : undefined; } else { const args = argsOrState; if ((!args || args.connectionPreference === undefined) && !opts.urn) { throw new Error("Missing required property 'connectionPreference'"); } if ((!args || args.enableProxyProtocol === undefined) && !opts.urn) { throw new Error("Missing required property 'enableProxyProtocol'"); } if ((!args || args.natSubnets === undefined) && !opts.urn) { throw new Error("Missing required property 'natSubnets'"); } if ((!args || args.targetService === undefined) && !opts.urn) { throw new Error("Missing required property 'targetService'"); } resourceInputs["connectionPreference"] = args ? args.connectionPreference : undefined; resourceInputs["consumerAcceptLists"] = args ? args.consumerAcceptLists : undefined; resourceInputs["consumerRejectLists"] = args ? args.consumerRejectLists : undefined; resourceInputs["description"] = args ? args.description : undefined; resourceInputs["domainNames"] = args ? args.domainNames : undefined; resourceInputs["enableProxyProtocol"] = args ? args.enableProxyProtocol : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["natSubnets"] = args ? args.natSubnets : undefined; resourceInputs["project"] = args ? args.project : undefined; resourceInputs["propagatedConnectionLimit"] = args ? args.propagatedConnectionLimit : undefined; resourceInputs["reconcileConnections"] = args ? args.reconcileConnections : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["targetService"] = args ? args.targetService : undefined; resourceInputs["connectedEndpoints"] = undefined /*out*/; resourceInputs["fingerprint"] = undefined /*out*/; resourceInputs["selfLink"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(ServiceAttachment.__pulumiType, name, resourceInputs, opts); } } exports.ServiceAttachment = ServiceAttachment; /** @internal */ ServiceAttachment.__pulumiType = 'gcp:compute/serviceAttachment:ServiceAttachment'; //# sourceMappingURL=serviceAttachment.js.map