@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
575 lines • 21.2 kB
JavaScript
"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! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectionProfile = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("../utilities"));
/**
* A set of reusable connection configurations to be used as a source or destination for a stream.
*
* To get more information about ConnectionProfile, see:
*
* * [API documentation](https://cloud.google.com/datastream/docs/reference/rest/v1/projects.locations.connectionProfiles)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/datastream/docs/create-connection-profiles)
*
* ## Example Usage
*
* ### Datastream Connection Profile Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Connection profile",
* location: "us-central1",
* connectionProfileId: "my-profile",
* gcsProfile: {
* bucket: "my-bucket",
* rootPath: "/path",
* },
* });
* ```
* ### Datastream Connection Profile Postgresql Private Connection
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as random from "@pulumi/random";
*
* const _default = new gcp.compute.Network("default", {
* name: "my-network",
* autoCreateSubnetworks: false,
* });
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "my-subnetwork",
* ipCidrRange: "10.1.0.0/16",
* region: "us-central1",
* network: _default.id,
* });
* const privateConnection = new gcp.datastream.PrivateConnection("private_connection", {
* displayName: "Private connection",
* location: "us-central1",
* privateConnectionId: "my-connection",
* vpcPeeringConfig: {
* vpc: _default.id,
* subnet: "10.0.0.0/29",
* },
* });
* const natVmIp = new gcp.compute.Address("nat_vm_ip", {name: "nat-vm-ip"});
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "my-instance",
* databaseVersion: "POSTGRES_14",
* region: "us-central1",
* settings: {
* tier: "db-f1-micro",
* ipConfiguration: {
* authorizedNetworks: [{
* value: natVmIp.address,
* }],
* },
* },
* deletionProtection: true,
* });
* const db = new gcp.sql.Database("db", {
* instance: instance.name,
* name: "db",
* });
* const pwd = new random.index.Password("pwd", {
* length: 16,
* special: false,
* });
* const user = new gcp.sql.User("user", {
* name: "user",
* instance: instance.name,
* password: pwd.result,
* });
* const natVm = new gcp.compute.Instance("nat_vm", {
* name: "nat-vm",
* machineType: "e2-medium",
* zone: "us-central1-a",
* desiredStatus: "RUNNING",
* bootDisk: {
* initializeParams: {
* image: "debian-cloud/debian-12",
* },
* },
* networkInterfaces: [{
* network: privateConnection.vpcPeeringConfig.apply(vpcPeeringConfig => vpcPeeringConfig?.vpc),
* subnetwork: defaultSubnetwork.selfLink,
* accessConfigs: [{
* natIp: natVmIp.address,
* }],
* }],
* metadataStartupScript: pulumi.interpolate`#! /bin/bash
* # See https://cloud.google.com/datastream/docs/private-connectivity#set-up-reverse-proxy
* export DB_ADDR=${instance.publicIpAddress}
* export DB_PORT=5432
* echo 1 > /proc/sys/net/ipv4/ip_forward
* md_url_prefix=\"http://169.254.169.254/computeMetadata/v1/instance\"
* vm_nic_ip=\"$(curl -H \"Metadata-Flavor: Google\" ${md_url_prefix}/network-interfaces/0/ip)\"
* iptables -t nat -F
* iptables -t nat -A PREROUTING \\
* -p tcp --dport $DB_PORT \\
* -j DNAT \\
* --to-destination $DB_ADDR
* iptables -t nat -A POSTROUTING \\
* -p tcp --dport $DB_PORT \\
* -j SNAT \\
* --to-source $vm_nic_ip
* iptables-save
* `,
* });
* const rules = new gcp.compute.Firewall("rules", {
* name: "ingress-rule",
* network: privateConnection.vpcPeeringConfig.apply(vpcPeeringConfig => vpcPeeringConfig?.vpc),
* description: "Allow traffic into NAT VM",
* direction: "INGRESS",
* allows: [{
* protocol: "tcp",
* ports: ["5432"],
* }],
* sourceRanges: [privateConnection.vpcPeeringConfig.apply(vpcPeeringConfig => vpcPeeringConfig?.subnet)],
* });
* const defaultConnectionProfile = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Connection profile",
* location: "us-central1",
* connectionProfileId: "my-profile",
* postgresqlProfile: {
* hostname: natVm.networkInterfaces.apply(networkInterfaces => networkInterfaces[0].networkIp),
* username: user.name,
* password: user.password,
* database: db.name,
* port: 5432,
* },
* privateConnectivity: {
* privateConnection: privateConnection.id,
* },
* });
* ```
* ### Datastream Connection Profile Full
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Connection profile",
* location: "us-central1",
* connectionProfileId: "my-profile",
* gcsProfile: {
* bucket: "my-bucket",
* rootPath: "/path",
* },
* forwardSshConnectivity: {
* hostname: "google.com",
* username: "my-user",
* port: 8022,
* password: "swordfish",
* },
* labels: {
* key: "value",
* },
* });
* ```
* ### Datastream Connection Profile Postgres
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as random from "@pulumi/random";
*
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "my-instance",
* databaseVersion: "POSTGRES_14",
* region: "us-central1",
* settings: {
* tier: "db-f1-micro",
* ipConfiguration: {
* authorizedNetworks: [
* {
* value: "34.71.242.81",
* },
* {
* value: "34.72.28.29",
* },
* {
* value: "34.67.6.157",
* },
* {
* value: "34.67.234.134",
* },
* {
* value: "34.72.239.218",
* },
* ],
* },
* },
* deletionProtection: true,
* });
* const db = new gcp.sql.Database("db", {
* instance: instance.name,
* name: "db",
* });
* const pwd = new random.index.Password("pwd", {
* length: 16,
* special: false,
* });
* const user = new gcp.sql.User("user", {
* name: "user",
* instance: instance.name,
* password: pwd.result,
* });
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Connection profile",
* location: "us-central1",
* connectionProfileId: "my-profile",
* postgresqlProfile: {
* hostname: instance.publicIpAddress,
* username: user.name,
* password: user.password,
* database: db.name,
* },
* });
* ```
* ### Datastream Connection Profile Sql Server
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "sql-server",
* databaseVersion: "SQLSERVER_2022_STANDARD",
* region: "us-central1",
* rootPassword: "root-password",
* deletionProtection: true,
* settings: {
* tier: "db-custom-2-4096",
* ipConfiguration: {
* authorizedNetworks: [
* {
* value: "34.71.242.81",
* },
* {
* value: "34.72.28.29",
* },
* {
* value: "34.67.6.157",
* },
* {
* value: "34.67.234.134",
* },
* {
* value: "34.72.239.218",
* },
* ],
* },
* },
* });
* const db = new gcp.sql.Database("db", {
* name: "db",
* instance: instance.name,
* });
* const user = new gcp.sql.User("user", {
* name: "user",
* instance: instance.name,
* password: "password",
* });
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "SQL Server Source",
* location: "us-central1",
* connectionProfileId: "source-profile",
* sqlServerProfile: {
* hostname: instance.publicIpAddress,
* port: 1433,
* username: user.name,
* password: user.password,
* database: db.name,
* },
* });
* ```
* ### Datastream Stream Postgresql Sslconfig Server And Client Verification
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
* import * as random from "@pulumi/random";
* import * as std from "@pulumi/std";
*
* const datastreamIps = gcp.datastream.getStaticIps({
* location: "us-central1",
* });
* const instance = new gcp.sql.DatabaseInstance("instance", {
* name: "my-instance",
* databaseVersion: "POSTGRES_15",
* region: "us-central1",
* settings: {
* tier: "db-f1-micro",
* ipConfiguration: {
* authorizedNetworks: std.format({
* input: "datastream-%d",
* args: [entry.key],
* }).then(invoke => .map(entry => ({
* name: invoke.result,
* value: entry.value,
* }))),
* ipv4Enabled: true,
* sslMode: "TRUSTED_CLIENT_CERTIFICATE_REQUIRED",
* },
* },
* deletionProtection: true,
* });
* const db = new gcp.sql.Database("db", {
* instance: instance.name,
* name: "db",
* });
* const pwd = new random.index.Password("pwd", {
* length: 16,
* special: false,
* });
* const user = new gcp.sql.User("user", {
* name: "user",
* instance: instance.name,
* password: pwd.result,
* });
* const clientCert = new gcp.sql.SslCert("client_cert", {
* commonName: "client-name",
* instance: instance.name,
* });
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Connection Profile",
* location: "us-central1",
* connectionProfileId: "profile-id",
* postgresqlProfile: {
* hostname: instance.publicIpAddress,
* port: 5432,
* username: "user",
* password: pwd.result,
* database: db.name,
* sslConfig: {
* serverAndClientVerification: {
* clientCertificate: clientCert.cert,
* clientKey: clientCert.privateKey,
* caCertificate: clientCert.serverCaCert,
* },
* },
* },
* });
* ```
* ### Datastream Connection Profile Salesforce
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Salesforce Source",
* location: "us-central1",
* connectionProfileId: "source-profile",
* createWithoutValidation: true,
* salesforceProfile: {
* domain: "fake-domain.my.salesforce.com",
* userCredentials: {
* username: "fake-username",
* secretManagerStoredPassword: "fake-password",
* secretManagerStoredSecurityToken: "fake-token",
* },
* },
* });
* ```
* ### Datastream Connection Profile Spanner
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Spanner Source",
* location: "us-central1",
* connectionProfileId: "source-profile",
* createWithoutValidation: true,
* spannerProfile: {
* database: "projects/example-project/instances/example-instance/databases/example-database",
* host: "https://spanner.example-region.rep.googleapis.com",
* },
* });
* ```
* ### Datastream Connection Profile Postgres Secret Manager
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Postgres Source With Secret Manager",
* location: "us-central1",
* connectionProfileId: "source-profile",
* createWithoutValidation: true,
* postgresqlProfile: {
* hostname: "fake-hostname",
* port: 3306,
* username: "fake-username",
* secretManagerStoredPassword: "projects/fake-project/secrets/fake-secret/versions/1",
* database: "fake-database",
* },
* });
* ```
* ### Datastream Connection Profile Mongodb
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.datastream.ConnectionProfile("default", {
* displayName: "Mongodb Source",
* location: "us-central1",
* connectionProfileId: "source-profile",
* mongodbProfile: {
* hostAddresses: [{
* hostname: "mongodb-primary.example.com",
* port: 27017,
* }],
* replicaSet: "myReplicaSet",
* username: "mongoUser",
* password: "mongoPassword",
* database: "myDatabase",
* standardConnectionFormat: {}[0],
* },
* });
* ```
*
* ## Import
*
* ConnectionProfile can be imported using any of these accepted formats:
*
* * `projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}`
* * `{{project}}/{{location}}/{{connection_profile_id}}`
* * `{{location}}/{{connection_profile_id}}`
*
* When using the `pulumi import` command, ConnectionProfile can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:datastream/connectionProfile:ConnectionProfile default projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}
* $ pulumi import gcp:datastream/connectionProfile:ConnectionProfile default {{project}}/{{location}}/{{connection_profile_id}}
* $ pulumi import gcp:datastream/connectionProfile:ConnectionProfile default {{location}}/{{connection_profile_id}}
* ```
*/
class ConnectionProfile extends pulumi.CustomResource {
/**
* Get an existing ConnectionProfile 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 ConnectionProfile(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'gcp:datastream/connectionProfile:ConnectionProfile';
/**
* Returns true if the given object is an instance of ConnectionProfile. 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'] === ConnectionProfile.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["bigqueryProfile"] = state?.bigqueryProfile;
resourceInputs["connectionProfileId"] = state?.connectionProfileId;
resourceInputs["createWithoutValidation"] = state?.createWithoutValidation;
resourceInputs["deletionPolicy"] = state?.deletionPolicy;
resourceInputs["displayName"] = state?.displayName;
resourceInputs["effectiveLabels"] = state?.effectiveLabels;
resourceInputs["forwardSshConnectivity"] = state?.forwardSshConnectivity;
resourceInputs["gcsProfile"] = state?.gcsProfile;
resourceInputs["labels"] = state?.labels;
resourceInputs["location"] = state?.location;
resourceInputs["mongodbProfile"] = state?.mongodbProfile;
resourceInputs["mysqlProfile"] = state?.mysqlProfile;
resourceInputs["name"] = state?.name;
resourceInputs["oracleProfile"] = state?.oracleProfile;
resourceInputs["postgresqlProfile"] = state?.postgresqlProfile;
resourceInputs["privateConnectivity"] = state?.privateConnectivity;
resourceInputs["project"] = state?.project;
resourceInputs["pulumiLabels"] = state?.pulumiLabels;
resourceInputs["salesforceProfile"] = state?.salesforceProfile;
resourceInputs["spannerProfile"] = state?.spannerProfile;
resourceInputs["sqlServerProfile"] = state?.sqlServerProfile;
}
else {
const args = argsOrState;
if (args?.connectionProfileId === undefined && !opts.urn) {
throw new Error("Missing required property 'connectionProfileId'");
}
if (args?.displayName === undefined && !opts.urn) {
throw new Error("Missing required property 'displayName'");
}
if (args?.location === undefined && !opts.urn) {
throw new Error("Missing required property 'location'");
}
resourceInputs["bigqueryProfile"] = args?.bigqueryProfile;
resourceInputs["connectionProfileId"] = args?.connectionProfileId;
resourceInputs["createWithoutValidation"] = args?.createWithoutValidation;
resourceInputs["deletionPolicy"] = args?.deletionPolicy;
resourceInputs["displayName"] = args?.displayName;
resourceInputs["forwardSshConnectivity"] = args?.forwardSshConnectivity;
resourceInputs["gcsProfile"] = args?.gcsProfile;
resourceInputs["labels"] = args?.labels;
resourceInputs["location"] = args?.location;
resourceInputs["mongodbProfile"] = args?.mongodbProfile;
resourceInputs["mysqlProfile"] = args?.mysqlProfile;
resourceInputs["oracleProfile"] = args?.oracleProfile;
resourceInputs["postgresqlProfile"] = args?.postgresqlProfile;
resourceInputs["privateConnectivity"] = args?.privateConnectivity;
resourceInputs["project"] = args?.project;
resourceInputs["salesforceProfile"] = args?.salesforceProfile;
resourceInputs["spannerProfile"] = args?.spannerProfile;
resourceInputs["sqlServerProfile"] = args?.sqlServerProfile;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["pulumiLabels"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["effectiveLabels", "pulumiLabels"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(ConnectionProfile.__pulumiType, name, resourceInputs, opts);
}
}
exports.ConnectionProfile = ConnectionProfile;
//# sourceMappingURL=connectionProfile.js.map