@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
449 lines • 16.9 kB
JavaScript
"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.ConnectionProfile = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A connection profile definition.
*
* To get more information about ConnectionProfile, see:
*
* * [API documentation](https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.connectionProfiles/create)
* * How-to Guides
* * [Database Migration](https://cloud.google.com/database-migration/docs/)
*
* ## Example Usage
*
* ### Database Migration Service Connection Profile Cloudsql
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const project = gcp.organizations.getProject({});
* const cloudsqldb = new gcp.sql.DatabaseInstance("cloudsqldb", {
* name: "my-database",
* databaseVersion: "MYSQL_5_7",
* settings: {
* tier: "db-n1-standard-1",
* deletionProtectionEnabled: false,
* },
* deletionProtection: false,
* });
* const sqlClientCert = new gcp.sql.SslCert("sql_client_cert", {
* commonName: "my-cert",
* instance: cloudsqldb.name,
* }, {
* dependsOn: [cloudsqldb],
* });
* const sqldbUser = new gcp.sql.User("sqldb_user", {
* name: "my-username",
* instance: cloudsqldb.name,
* password: "my-password",
* }, {
* dependsOn: [sqlClientCert],
* });
* const cloudsqlprofile = new gcp.databasemigrationservice.ConnectionProfile("cloudsqlprofile", {
* location: "us-central1",
* connectionProfileId: "my-fromprofileid",
* displayName: "my-fromprofileid_display",
* labels: {
* foo: "bar",
* },
* mysql: {
* host: cloudsqldb.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress),
* port: 3306,
* username: sqldbUser.name,
* password: sqldbUser.password,
* ssl: {
* clientKey: sqlClientCert.privateKey,
* clientCertificate: sqlClientCert.cert,
* caCertificate: sqlClientCert.serverCaCert,
* },
* cloudSqlId: "my-database",
* },
* }, {
* dependsOn: [sqldbUser],
* });
* const cloudsqlprofileDestination = new gcp.databasemigrationservice.ConnectionProfile("cloudsqlprofile_destination", {
* location: "us-central1",
* connectionProfileId: "my-toprofileid",
* displayName: "my-toprofileid_displayname",
* labels: {
* foo: "bar",
* },
* cloudsql: {
* settings: {
* databaseVersion: "MYSQL_5_7",
* userLabels: {
* cloudfoo: "cloudbar",
* },
* tier: "db-n1-standard-1",
* edition: "ENTERPRISE",
* storageAutoResizeLimit: "0",
* activationPolicy: "ALWAYS",
* ipConfig: {
* enableIpv4: true,
* requireSsl: true,
* },
* autoStorageIncrease: true,
* dataDiskType: "PD_HDD",
* dataDiskSizeGb: "11",
* zone: "us-central1-b",
* sourceId: project.then(project => `projects/${project.projectId}/locations/us-central1/connectionProfiles/my-fromprofileid`),
* rootPassword: "testpasscloudsql",
* },
* },
* }, {
* dependsOn: [cloudsqlprofile],
* });
* ```
* ### Database Migration Service Connection Profile Postgres
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const postgresqldb = new gcp.sql.DatabaseInstance("postgresqldb", {
* name: "my-database",
* databaseVersion: "POSTGRES_12",
* settings: {
* tier: "db-custom-2-13312",
* },
* deletionProtection: false,
* });
* const sqlClientCert = new gcp.sql.SslCert("sql_client_cert", {
* commonName: "my-cert",
* instance: postgresqldb.name,
* }, {
* dependsOn: [postgresqldb],
* });
* const sqldbUser = new gcp.sql.User("sqldb_user", {
* name: "my-username",
* instance: postgresqldb.name,
* password: "my-password",
* }, {
* dependsOn: [sqlClientCert],
* });
* const postgresprofile = new gcp.databasemigrationservice.ConnectionProfile("postgresprofile", {
* location: "us-central1",
* connectionProfileId: "my-profileid",
* displayName: "my-profileid_display",
* labels: {
* foo: "bar",
* },
* postgresql: {
* host: postgresqldb.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress),
* port: 5432,
* username: sqldbUser.name,
* password: sqldbUser.password,
* ssl: {
* clientKey: sqlClientCert.privateKey,
* clientCertificate: sqlClientCert.cert,
* caCertificate: sqlClientCert.serverCaCert,
* },
* cloudSqlId: "my-database",
* },
* }, {
* dependsOn: [sqldbUser],
* });
* ```
* ### Database Migration Service Connection Profile Oracle
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const oracleprofile = new gcp.databasemigrationservice.ConnectionProfile("oracleprofile", {
* location: "us-central1",
* connectionProfileId: "my-profileid",
* displayName: "my-profileid_display",
* labels: {
* foo: "bar",
* },
* oracle: {
* host: "host",
* port: 1521,
* username: "username",
* password: "password",
* databaseService: "dbprovider",
* staticServiceIpConnectivity: {},
* },
* });
* ```
* ### Database Migration Service Connection Profile Alloydb
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const project = gcp.organizations.getProject({});
* const _default = new gcp.compute.Network("default", {name: "vpc-network"});
* const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
* name: "private-ip-alloc",
* addressType: "INTERNAL",
* purpose: "VPC_PEERING",
* prefixLength: 16,
* network: _default.id,
* });
* const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
* network: _default.id,
* service: "servicenetworking.googleapis.com",
* reservedPeeringRanges: [privateIpAlloc.name],
* });
* const alloydbprofile = new gcp.databasemigrationservice.ConnectionProfile("alloydbprofile", {
* location: "us-central1",
* connectionProfileId: "my-profileid",
* displayName: "my-profileid_display",
* labels: {
* foo: "bar",
* },
* alloydb: {
* clusterId: "tf-test-dbmsalloycluster_85840",
* settings: {
* initialUser: {
* user: "alloyuser_60302",
* password: "alloypass_22811",
* },
* vpcNetwork: _default.id,
* labels: {
* alloyfoo: "alloybar",
* },
* primaryInstanceSettings: {
* id: "priminstid",
* machineConfig: {
* cpuCount: 2,
* },
* databaseFlags: {},
* labels: {
* alloysinstfoo: "allowinstbar",
* },
* },
* },
* },
* }, {
* dependsOn: [vpcConnection],
* });
* ```
* ### Database Migration Service Connection Profile Existing Mysql
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const project = gcp.organizations.getProject({});
* const destinationCsql = new gcp.sql.DatabaseInstance("destination_csql", {
* name: "destination-csql",
* databaseVersion: "MYSQL_5_7",
* settings: {
* tier: "db-n1-standard-1",
* deletionProtectionEnabled: false,
* },
* deletionProtection: false,
* });
* const existing_mysql = new gcp.databasemigrationservice.ConnectionProfile("existing-mysql", {
* location: "us-central1",
* connectionProfileId: "destination-cp",
* displayName: "destination-cp_display",
* labels: {
* foo: "bar",
* },
* mysql: {
* cloudSqlId: "destination-csql",
* },
* }, {
* dependsOn: [destinationCsql],
* });
* ```
* ### Database Migration Service Connection Profile Existing Postgres
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const project = gcp.organizations.getProject({});
* const destinationCsql = new gcp.sql.DatabaseInstance("destination_csql", {
* name: "destination-csql",
* databaseVersion: "POSTGRES_15",
* settings: {
* tier: "db-custom-2-13312",
* deletionProtectionEnabled: false,
* },
* deletionProtection: false,
* });
* const existing_psql = new gcp.databasemigrationservice.ConnectionProfile("existing-psql", {
* location: "us-central1",
* connectionProfileId: "destination-cp",
* displayName: "destination-cp_display",
* labels: {
* foo: "bar",
* },
* postgresql: {
* cloudSqlId: "destination-csql",
* },
* }, {
* dependsOn: [destinationCsql],
* });
* ```
* ### Database Migration Service Connection Profile Existing Alloydb
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const project = gcp.organizations.getProject({});
* const _default = new gcp.compute.Network("default", {name: "destination-alloydb"});
* const destinationAlloydb = new gcp.alloydb.Cluster("destination_alloydb", {
* clusterId: "destination-alloydb",
* location: "us-central1",
* networkConfig: {
* network: _default.id,
* },
* databaseVersion: "POSTGRES_15",
* initialUser: {
* user: "destination-alloydb",
* password: "destination-alloydb",
* },
* });
* const privateIpAlloc = new gcp.compute.GlobalAddress("private_ip_alloc", {
* name: "destination-alloydb",
* addressType: "INTERNAL",
* purpose: "VPC_PEERING",
* prefixLength: 16,
* network: _default.id,
* });
* const vpcConnection = new gcp.servicenetworking.Connection("vpc_connection", {
* network: _default.id,
* service: "servicenetworking.googleapis.com",
* reservedPeeringRanges: [privateIpAlloc.name],
* });
* const destinationAlloydbPrimary = new gcp.alloydb.Instance("destination_alloydb_primary", {
* cluster: destinationAlloydb.name,
* instanceId: "destination-alloydb-primary",
* instanceType: "PRIMARY",
* }, {
* dependsOn: [vpcConnection],
* });
* const existing_alloydb = new gcp.databasemigrationservice.ConnectionProfile("existing-alloydb", {
* location: "us-central1",
* connectionProfileId: "destination-cp",
* displayName: "destination-cp_display",
* labels: {
* foo: "bar",
* },
* postgresql: {
* alloydbClusterId: "destination-alloydb",
* },
* }, {
* dependsOn: [
* destinationAlloydb,
* destinationAlloydbPrimary,
* ],
* });
* ```
*
* ## 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:databasemigrationservice/connectionProfile:ConnectionProfile default projects/{{project}}/locations/{{location}}/connectionProfiles/{{connection_profile_id}}
* ```
*
* ```sh
* $ pulumi import gcp:databasemigrationservice/connectionProfile:ConnectionProfile default {{project}}/{{location}}/{{connection_profile_id}}
* ```
*
* ```sh
* $ pulumi import gcp:databasemigrationservice/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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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["alloydb"] = state ? state.alloydb : undefined;
resourceInputs["cloudsql"] = state ? state.cloudsql : undefined;
resourceInputs["connectionProfileId"] = state ? state.connectionProfileId : undefined;
resourceInputs["createTime"] = state ? state.createTime : undefined;
resourceInputs["dbprovider"] = state ? state.dbprovider : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["effectiveLabels"] = state ? state.effectiveLabels : undefined;
resourceInputs["errors"] = state ? state.errors : undefined;
resourceInputs["labels"] = state ? state.labels : undefined;
resourceInputs["location"] = state ? state.location : undefined;
resourceInputs["mysql"] = state ? state.mysql : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["oracle"] = state ? state.oracle : undefined;
resourceInputs["postgresql"] = state ? state.postgresql : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined;
resourceInputs["state"] = state ? state.state : undefined;
}
else {
const args = argsOrState;
if ((!args || args.connectionProfileId === undefined) && !opts.urn) {
throw new Error("Missing required property 'connectionProfileId'");
}
resourceInputs["alloydb"] = args ? args.alloydb : undefined;
resourceInputs["cloudsql"] = args ? args.cloudsql : undefined;
resourceInputs["connectionProfileId"] = args ? args.connectionProfileId : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["labels"] = args ? args.labels : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["mysql"] = args ? args.mysql : undefined;
resourceInputs["oracle"] = args ? args.oracle : undefined;
resourceInputs["postgresql"] = args ? args.postgresql : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["createTime"] = undefined /*out*/;
resourceInputs["dbprovider"] = undefined /*out*/;
resourceInputs["effectiveLabels"] = undefined /*out*/;
resourceInputs["errors"] = undefined /*out*/;
resourceInputs["name"] = undefined /*out*/;
resourceInputs["pulumiLabels"] = undefined /*out*/;
resourceInputs["state"] = 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;
/** @internal */
ConnectionProfile.__pulumiType = 'gcp:databasemigrationservice/connectionProfile:ConnectionProfile';
//# sourceMappingURL=connectionProfile.js.map