UNPKG

@pulumi/gcp

Version:

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

550 lines • 19.9 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.Instance = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Instances are deployed to an available Google Cloud region and are accessible via their web interface. * * To get more information about Instance, see: * * * [API documentation](https://cloud.google.com/secure-source-manager/docs/reference/rest/v1/projects.locations.instances) * * How-to Guides * * [Official Documentation](https://cloud.google.com/secure-source-manager/docs/create-instance) * * ## Example Usage * * ### Secure Source Manager Instance Basic * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.securesourcemanager.Instance("default", { * location: "us-central1", * instanceId: "my-instance", * labels: { * foo: "bar", * }, * deletionPolicy: "PREVENT", * }); * ``` * ### Secure Source Manager Instance Cmek * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const cryptoKeyBinding = new gcp.kms.CryptoKeyIAMMember("crypto_key_binding", { * cryptoKeyId: "my-key", * role: "roles/cloudkms.cryptoKeyEncrypterDecrypter", * member: project.then(project => `serviceAccount:service-${project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com`), * }); * const _default = new gcp.securesourcemanager.Instance("default", { * location: "us-central1", * instanceId: "my-instance", * kmsKey: "my-key", * deletionPolicy: "PREVENT", * }, { * dependsOn: [cryptoKeyBinding], * }); * ``` * ### Secure Source Manager Instance Private * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const caPool = new gcp.certificateauthority.CaPool("ca_pool", { * name: "ca-pool", * location: "us-central1", * tier: "ENTERPRISE", * publishingOptions: { * publishCaCert: true, * publishCrl: true, * }, * }); * const rootCa = new gcp.certificateauthority.Authority("root_ca", { * pool: caPool.name, * certificateAuthorityId: "root-ca", * location: "us-central1", * config: { * subjectConfig: { * subject: { * organization: "google", * commonName: "my-certificate-authority", * }, * }, * x509Config: { * caOptions: { * isCa: true, * }, * keyUsage: { * baseKeyUsage: { * certSign: true, * crlSign: true, * }, * extendedKeyUsage: { * serverAuth: true, * }, * }, * }, * }, * keySpec: { * algorithm: "RSA_PKCS1_4096_SHA256", * }, * deletionProtection: false, * ignoreActiveCertificatesOnDeletion: true, * skipGracePeriod: true, * }); * const project = gcp.organizations.getProject({}); * const caPoolBinding = new gcp.certificateauthority.CaPoolIamBinding("ca_pool_binding", { * caPool: caPool.id, * role: "roles/privateca.certificateRequester", * members: [project.then(project => `serviceAccount:service-${project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com`)], * }); * // ca pool IAM permissions can take time to propagate * const wait120Seconds = new time.index.Sleep("wait_120_seconds", {createDuration: "120s"}, { * dependsOn: [caPoolBinding], * }); * const _default = new gcp.securesourcemanager.Instance("default", { * instanceId: "my-instance", * location: "us-central1", * privateConfig: { * isPrivate: true, * caPool: caPool.id, * }, * deletionPolicy: "PREVENT", * }, { * dependsOn: [ * rootCa, * wait120Seconds, * ], * }); * ``` * ### Secure Source Manager Instance Private Psc Backend * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const project = gcp.organizations.getProject({}); * const caPool = new gcp.certificateauthority.CaPool("ca_pool", { * name: "ca-pool", * location: "us-central1", * tier: "ENTERPRISE", * publishingOptions: { * publishCaCert: true, * publishCrl: true, * }, * }); * const rootCa = new gcp.certificateauthority.Authority("root_ca", { * pool: caPool.name, * certificateAuthorityId: "root-ca", * location: "us-central1", * config: { * subjectConfig: { * subject: { * organization: "google", * commonName: "my-certificate-authority", * }, * }, * x509Config: { * caOptions: { * isCa: true, * }, * keyUsage: { * baseKeyUsage: { * certSign: true, * crlSign: true, * }, * extendedKeyUsage: { * serverAuth: true, * }, * }, * }, * }, * keySpec: { * algorithm: "RSA_PKCS1_4096_SHA256", * }, * deletionProtection: false, * ignoreActiveCertificatesOnDeletion: true, * skipGracePeriod: true, * }); * const caPoolBinding = new gcp.certificateauthority.CaPoolIamBinding("ca_pool_binding", { * caPool: caPool.id, * role: "roles/privateca.certificateRequester", * members: [project.then(project => `serviceAccount:service-${project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com`)], * }); * // ca pool IAM permissions can take time to propagate * const wait120Seconds = new time.index.Sleep("wait_120_seconds", {createDuration: "120s"}, { * dependsOn: [caPoolBinding], * }); * // See https://cloud.google.com/secure-source-manager/docs/create-private-service-connect-instance#root-ca-api * const _default = new gcp.securesourcemanager.Instance("default", { * instanceId: "my-instance", * location: "us-central1", * privateConfig: { * isPrivate: true, * caPool: caPool.id, * }, * deletionPolicy: "PREVENT", * }, { * dependsOn: [ * rootCa, * wait120Seconds, * ], * }); * // Connect SSM private instance with L4 proxy ILB. * const network = new gcp.compute.Network("network", { * name: "my-network", * autoCreateSubnetworks: false, * }); * const subnet = new gcp.compute.Subnetwork("subnet", { * name: "my-subnet", * region: "us-central1", * network: network.id, * ipCidrRange: "10.0.1.0/24", * privateIpGoogleAccess: true, * }); * const pscNeg = new gcp.compute.RegionNetworkEndpointGroup("psc_neg", { * name: "my-neg", * region: "us-central1", * networkEndpointType: "PRIVATE_SERVICE_CONNECT", * pscTargetService: _default.privateConfig.apply(privateConfig => privateConfig?.httpServiceAttachment), * network: network.id, * subnetwork: subnet.id, * }); * const backendService = new gcp.compute.RegionBackendService("backend_service", { * name: "my-backend-service", * region: "us-central1", * protocol: "TCP", * loadBalancingScheme: "INTERNAL_MANAGED", * backends: [{ * group: pscNeg.id, * balancingMode: "UTILIZATION", * capacityScaler: 1, * }], * }); * const proxySubnet = new gcp.compute.Subnetwork("proxy_subnet", { * name: "my-proxy-subnet", * region: "us-central1", * network: network.id, * ipCidrRange: "10.0.2.0/24", * purpose: "REGIONAL_MANAGED_PROXY", * role: "ACTIVE", * }); * const targetProxy = new gcp.compute.RegionTargetTcpProxy("target_proxy", { * name: "my-target-proxy", * region: "us-central1", * backendService: backendService.id, * }); * const fwRuleTargetProxy = new gcp.compute.ForwardingRule("fw_rule_target_proxy", { * name: "fw-rule-target-proxy", * region: "us-central1", * loadBalancingScheme: "INTERNAL_MANAGED", * ipProtocol: "TCP", * portRange: "443", * target: targetProxy.id, * network: network.id, * subnetwork: subnet.id, * networkTier: "PREMIUM", * }, { * dependsOn: [proxySubnet], * }); * const privateZone = new gcp.dns.ManagedZone("private_zone", { * name: "my-dns-zone", * dnsName: "p.sourcemanager.dev.", * visibility: "private", * privateVisibilityConfig: { * networks: [{ * networkUrl: network.id, * }], * }, * }); * const ssmInstanceHtmlRecord = new gcp.dns.RecordSet("ssm_instance_html_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].html}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleTargetProxy.ipAddress], * }); * const ssmInstanceApiRecord = new gcp.dns.RecordSet("ssm_instance_api_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].api}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleTargetProxy.ipAddress], * }); * const ssmInstanceGitRecord = new gcp.dns.RecordSet("ssm_instance_git_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].gitHttp}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleTargetProxy.ipAddress], * }); * ``` * ### Secure Source Manager Instance Private Psc Endpoint * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * import * as time from "@pulumiverse/time"; * * const project = gcp.organizations.getProject({}); * const caPool = new gcp.certificateauthority.CaPool("ca_pool", { * name: "ca-pool", * location: "us-central1", * tier: "ENTERPRISE", * publishingOptions: { * publishCaCert: true, * publishCrl: true, * }, * }); * const rootCa = new gcp.certificateauthority.Authority("root_ca", { * pool: caPool.name, * certificateAuthorityId: "root-ca", * location: "us-central1", * config: { * subjectConfig: { * subject: { * organization: "google", * commonName: "my-certificate-authority", * }, * }, * x509Config: { * caOptions: { * isCa: true, * }, * keyUsage: { * baseKeyUsage: { * certSign: true, * crlSign: true, * }, * extendedKeyUsage: { * serverAuth: true, * }, * }, * }, * }, * keySpec: { * algorithm: "RSA_PKCS1_4096_SHA256", * }, * deletionProtection: false, * ignoreActiveCertificatesOnDeletion: true, * skipGracePeriod: true, * }); * const caPoolBinding = new gcp.certificateauthority.CaPoolIamBinding("ca_pool_binding", { * caPool: caPool.id, * role: "roles/privateca.certificateRequester", * members: [project.then(project => `serviceAccount:service-${project.number}@gcp-sa-sourcemanager.iam.gserviceaccount.com`)], * }); * // ca pool IAM permissions can take time to propagate * const wait120Seconds = new time.index.Sleep("wait_120_seconds", {createDuration: "120s"}, { * dependsOn: [caPoolBinding], * }); * // See https://cloud.google.com/secure-source-manager/docs/create-private-service-connect-instance#root-ca-api * const _default = new gcp.securesourcemanager.Instance("default", { * instanceId: "my-instance", * location: "us-central1", * privateConfig: { * isPrivate: true, * caPool: caPool.id, * }, * deletionPolicy: "PREVENT", * }, { * dependsOn: [ * rootCa, * wait120Seconds, * ], * }); * // Connect SSM private instance with endpoint. * const network = new gcp.compute.Network("network", { * name: "my-network", * autoCreateSubnetworks: false, * }); * const subnet = new gcp.compute.Subnetwork("subnet", { * name: "my-subnet", * region: "us-central1", * network: network.id, * ipCidrRange: "10.0.60.0/24", * privateIpGoogleAccess: true, * }); * const address = new gcp.compute.Address("address", { * name: "my-address", * region: "us-central1", * address: "10.0.60.100", * addressType: "INTERNAL", * subnetwork: subnet.id, * }); * const fwRuleServiceAttachment = new gcp.compute.ForwardingRule("fw_rule_service_attachment", { * name: "fw-rule-service-attachment", * region: "us-central1", * loadBalancingScheme: "", * ipAddress: address.id, * network: network.id, * target: _default.privateConfig.apply(privateConfig => privateConfig?.httpServiceAttachment), * }); * const privateZone = new gcp.dns.ManagedZone("private_zone", { * name: "my-dns-zone", * dnsName: "p.sourcemanager.dev.", * visibility: "private", * privateVisibilityConfig: { * networks: [{ * networkUrl: network.id, * }], * }, * }); * const ssmInstanceHtmlRecord = new gcp.dns.RecordSet("ssm_instance_html_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].html}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleServiceAttachment.ipAddress], * }); * const ssmInstanceApiRecord = new gcp.dns.RecordSet("ssm_instance_api_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].api}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleServiceAttachment.ipAddress], * }); * const ssmInstanceGitRecord = new gcp.dns.RecordSet("ssm_instance_git_record", { * name: _default.hostConfigs.apply(hostConfigs => `${hostConfigs[0].gitHttp}.`), * type: "A", * ttl: 300, * managedZone: privateZone.name, * rrdatas: [fwRuleServiceAttachment.ipAddress], * }); * ``` * ### Secure Source Manager Instance Workforce Identity Federation * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const _default = new gcp.securesourcemanager.Instance("default", { * location: "us-central1", * instanceId: "my-instance", * workforceIdentityFederationConfig: { * enabled: true, * }, * deletionPolicy: "PREVENT", * }); * ``` * * ## Import * * Instance can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/instances/{{instance_id}}` * * * `{{project}}/{{location}}/{{instance_id}}` * * * `{{location}}/{{instance_id}}` * * * `{{instance_id}}` * * When using the `pulumi import` command, Instance can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:securesourcemanager/instance:Instance default projects/{{project}}/locations/{{location}}/instances/{{instance_id}} * ``` * * ```sh * $ pulumi import gcp:securesourcemanager/instance:Instance default {{project}}/{{location}}/{{instance_id}} * ``` * * ```sh * $ pulumi import gcp:securesourcemanager/instance:Instance default {{location}}/{{instance_id}} * ``` * * ```sh * $ pulumi import gcp:securesourcemanager/instance:Instance default {{instance_id}} * ``` */ class Instance extends pulumi.CustomResource { /** * Get an existing Instance 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 Instance(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Instance. 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'] === Instance.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["createTime"] = state?.createTime; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["hostConfigs"] = state?.hostConfigs; resourceInputs["instanceId"] = state?.instanceId; resourceInputs["kmsKey"] = state?.kmsKey; resourceInputs["labels"] = state?.labels; resourceInputs["location"] = state?.location; resourceInputs["name"] = state?.name; resourceInputs["privateConfig"] = state?.privateConfig; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["state"] = state?.state; resourceInputs["stateNote"] = state?.stateNote; resourceInputs["updateTime"] = state?.updateTime; resourceInputs["workforceIdentityFederationConfig"] = state?.workforceIdentityFederationConfig; } else { const args = argsOrState; if (args?.instanceId === undefined && !opts.urn) { throw new Error("Missing required property 'instanceId'"); } if (args?.location === undefined && !opts.urn) { throw new Error("Missing required property 'location'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["instanceId"] = args?.instanceId; resourceInputs["kmsKey"] = args?.kmsKey; resourceInputs["labels"] = args?.labels; resourceInputs["location"] = args?.location; resourceInputs["privateConfig"] = args?.privateConfig; resourceInputs["project"] = args?.project; resourceInputs["workforceIdentityFederationConfig"] = args?.workforceIdentityFederationConfig; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["hostConfigs"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; resourceInputs["pulumiLabels"] = undefined /*out*/; resourceInputs["state"] = undefined /*out*/; resourceInputs["stateNote"] = undefined /*out*/; resourceInputs["updateTime"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(Instance.__pulumiType, name, resourceInputs, opts); } } exports.Instance = Instance; /** @internal */ Instance.__pulumiType = 'gcp:securesourcemanager/instance:Instance'; //# sourceMappingURL=instance.js.map