UNPKG

@pulumi/gcp

Version:

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

571 lines • 21.5 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! *** 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.MigrationJob = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * A migration job definition. * * To get more information about MigrationJob, see: * * * [API documentation](https://cloud.google.com/database-migration/docs/reference/rest/v1/projects.locations.migrationJobs/create) * * How-to Guides * * [Database Migration](https://cloud.google.com/database-migration/docs/) * * ## Example Usage * * ### Database Migration Service Migration Job Mysql To Mysql * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const sourceCsql = new gcp.sql.DatabaseInstance("source_csql", { * name: "source-csql", * databaseVersion: "MYSQL_5_7", * settings: { * tier: "db-n1-standard-1", * deletionProtectionEnabled: false, * }, * deletionProtection: false, * }); * const sourceSqlClientCert = new gcp.sql.SslCert("source_sql_client_cert", { * commonName: "cert", * instance: sourceCsql.name, * }, { * dependsOn: [sourceCsql], * }); * const sourceSqldbUser = new gcp.sql.User("source_sqldb_user", { * name: "username", * instance: sourceCsql.name, * password: "password", * }, { * dependsOn: [sourceSqlClientCert], * }); * const sourceCp = new gcp.databasemigrationservice.ConnectionProfile("source_cp", { * location: "us-central1", * connectionProfileId: "source-cp", * displayName: "source-cp_display", * labels: { * foo: "bar", * }, * mysql: { * host: sourceCsql.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress), * port: 3306, * username: sourceSqldbUser.name, * password: sourceSqldbUser.password, * ssl: { * clientKey: sourceSqlClientCert.privateKey, * clientCertificate: sourceSqlClientCert.cert, * caCertificate: sourceSqlClientCert.serverCaCert, * type: "SERVER_CLIENT", * }, * cloudSqlId: "source-csql", * }, * }, { * dependsOn: [sourceSqldbUser], * }); * 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 destinationCp = new gcp.databasemigrationservice.ConnectionProfile("destination_cp", { * location: "us-central1", * connectionProfileId: "destination-cp", * displayName: "destination-cp_display", * labels: { * foo: "bar", * }, * mysql: { * cloudSqlId: "destination-csql", * }, * }, { * dependsOn: [destinationCsql], * }); * const _default = new gcp.compute.Network("default", {name: "destination-csql"}); * const mysqltomysql = new gcp.databasemigrationservice.MigrationJob("mysqltomysql", { * location: "us-central1", * migrationJobId: "my-migrationid", * displayName: "my-migrationid_display", * labels: { * foo: "bar", * }, * performanceConfig: { * dumpParallelLevel: "MAX", * }, * vpcPeeringConnectivity: { * vpc: _default.id, * }, * dumpType: "LOGICAL", * dumpFlags: { * dumpFlags: [{ * name: "max-allowed-packet", * value: "1073741824", * }], * }, * source: sourceCp.name, * destination: destinationCp.name, * type: "CONTINUOUS", * }); * ``` * ### Database Migration Service Migration Job Postgres To Postgres * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const sourceCsql = new gcp.sql.DatabaseInstance("source_csql", { * name: "source-csql", * databaseVersion: "POSTGRES_15", * settings: { * tier: "db-custom-2-13312", * deletionProtectionEnabled: false, * }, * deletionProtection: false, * }); * const sourceSqlClientCert = new gcp.sql.SslCert("source_sql_client_cert", { * commonName: "cert", * instance: sourceCsql.name, * }, { * dependsOn: [sourceCsql], * }); * const sourceSqldbUser = new gcp.sql.User("source_sqldb_user", { * name: "username", * instance: sourceCsql.name, * password: "password", * }, { * dependsOn: [sourceSqlClientCert], * }); * const sourceCp = new gcp.databasemigrationservice.ConnectionProfile("source_cp", { * location: "us-central1", * connectionProfileId: "source-cp", * displayName: "source-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * host: sourceCsql.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress), * port: 3306, * username: sourceSqldbUser.name, * password: sourceSqldbUser.password, * ssl: { * clientKey: sourceSqlClientCert.privateKey, * clientCertificate: sourceSqlClientCert.cert, * caCertificate: sourceSqlClientCert.serverCaCert, * type: "SERVER_CLIENT", * }, * cloudSqlId: "source-csql", * }, * }, { * dependsOn: [sourceSqldbUser], * }); * 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 destinationCp = new gcp.databasemigrationservice.ConnectionProfile("destination_cp", { * location: "us-central1", * connectionProfileId: "destination-cp", * displayName: "destination-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * cloudSqlId: "destination-csql", * }, * }, { * dependsOn: [destinationCsql], * }); * const psqltopsql = new gcp.databasemigrationservice.MigrationJob("psqltopsql", { * location: "us-central1", * migrationJobId: "my-migrationid", * displayName: "my-migrationid_display", * labels: { * foo: "bar", * }, * staticIpConnectivity: {}, * source: sourceCp.name, * destination: destinationCp.name, * type: "CONTINUOUS", * }); * ``` * ### Database Migration Service Migration Job Postgres To Postgres Objects * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const sourceCsql = new gcp.sql.DatabaseInstance("source_csql", { * name: "source-csql", * databaseVersion: "POSTGRES_15", * settings: { * tier: "db-custom-2-13312", * deletionProtectionEnabled: false, * }, * deletionProtection: false, * }); * const sourceSqlClientCert = new gcp.sql.SslCert("source_sql_client_cert", { * commonName: "cert", * instance: sourceCsql.name, * }, { * dependsOn: [sourceCsql], * }); * const sourceSqldbUser = new gcp.sql.User("source_sqldb_user", { * name: "username", * instance: sourceCsql.name, * password: "password", * }, { * dependsOn: [sourceSqlClientCert], * }); * const sourceCp = new gcp.databasemigrationservice.ConnectionProfile("source_cp", { * location: "us-central1", * connectionProfileId: "source-cp", * displayName: "source-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * host: sourceCsql.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress), * port: 3306, * username: sourceSqldbUser.name, * password: sourceSqldbUser.password, * ssl: { * clientKey: sourceSqlClientCert.privateKey, * clientCertificate: sourceSqlClientCert.cert, * caCertificate: sourceSqlClientCert.serverCaCert, * type: "SERVER_CLIENT", * }, * cloudSqlId: "source-csql", * }, * }, { * dependsOn: [sourceSqldbUser], * }); * 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 destinationCp = new gcp.databasemigrationservice.ConnectionProfile("destination_cp", { * location: "us-central1", * connectionProfileId: "destination-cp", * displayName: "destination-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * cloudSqlId: "destination-csql", * }, * }, { * dependsOn: [destinationCsql], * }); * const psqltopsqlobjects = new gcp.databasemigrationservice.MigrationJob("psqltopsqlobjects", { * location: "us-central1", * migrationJobId: "my-migrationid", * displayName: "my-migrationid_display", * labels: { * foo: "bar", * }, * staticIpConnectivity: {}, * source: sourceCp.name, * destination: destinationCp.name, * type: "CONTINUOUS", * objectsConfig: { * sourceObjectsConfig: { * objectsSelectionType: "SPECIFIED_OBJECTS", * objectConfigs: [ * { * objectIdentifier: { * type: "DATABASE", * database: "my_database", * }, * }, * { * objectIdentifier: { * type: "TABLE", * database: "my_other_database", * schema: "public", * table: "users", * }, * }, * ], * }, * }, * }); * ``` * ### Database Migration Service Migration Job Postgres To Alloydb * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as gcp from "@pulumi/gcp"; * * const project = gcp.organizations.getProject({}); * const sourceCsql = new gcp.sql.DatabaseInstance("source_csql", { * name: "source-csql", * databaseVersion: "POSTGRES_15", * settings: { * tier: "db-custom-2-13312", * deletionProtectionEnabled: false, * }, * deletionProtection: false, * }); * const sourceSqlClientCert = new gcp.sql.SslCert("source_sql_client_cert", { * commonName: "cert", * instance: sourceCsql.name, * }, { * dependsOn: [sourceCsql], * }); * const sourceSqldbUser = new gcp.sql.User("source_sqldb_user", { * name: "username", * instance: sourceCsql.name, * password: "password", * }, { * dependsOn: [sourceSqlClientCert], * }); * const sourceCp = new gcp.databasemigrationservice.ConnectionProfile("source_cp", { * location: "us-central1", * connectionProfileId: "source-cp", * displayName: "source-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * host: sourceCsql.ipAddresses.apply(ipAddresses => ipAddresses[0].ipAddress), * port: 3306, * username: sourceSqldbUser.name, * password: sourceSqldbUser.password, * ssl: { * clientKey: sourceSqlClientCert.privateKey, * clientCertificate: sourceSqlClientCert.cert, * caCertificate: sourceSqlClientCert.serverCaCert, * type: "SERVER_CLIENT", * }, * cloudSqlId: "source-csql", * }, * }, { * dependsOn: [sourceSqldbUser], * }); * 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", * }, * deletionProtection: false, * }); * 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 destinationCp = new gcp.databasemigrationservice.ConnectionProfile("destination_cp", { * location: "us-central1", * connectionProfileId: "destination-cp", * displayName: "destination-cp_display", * labels: { * foo: "bar", * }, * postgresql: { * alloydbClusterId: "destination-alloydb", * }, * }, { * dependsOn: [ * destinationAlloydb, * destinationAlloydbPrimary, * ], * }); * const psqltoalloydb = new gcp.databasemigrationservice.MigrationJob("psqltoalloydb", { * location: "us-central1", * migrationJobId: "my-migrationid", * displayName: "my-migrationid_display", * labels: { * foo: "bar", * }, * staticIpConnectivity: {}, * source: sourceCp.name, * destination: destinationCp.name, * type: "CONTINUOUS", * }); * ``` * * ## Import * * MigrationJob can be imported using any of these accepted formats: * * * `projects/{{project}}/locations/{{location}}/migrationJobs/{{migration_job_id}}` * * `{{project}}/{{location}}/{{migration_job_id}}` * * `{{location}}/{{migration_job_id}}` * * When using the `pulumi import` command, MigrationJob can be imported using one of the formats above. For example: * * ```sh * $ pulumi import gcp:databasemigrationservice/migrationJob:MigrationJob default projects/{{project}}/locations/{{location}}/migrationJobs/{{migration_job_id}} * $ pulumi import gcp:databasemigrationservice/migrationJob:MigrationJob default {{project}}/{{location}}/{{migration_job_id}} * $ pulumi import gcp:databasemigrationservice/migrationJob:MigrationJob default {{location}}/{{migration_job_id}} * ``` */ class MigrationJob extends pulumi.CustomResource { /** * Get an existing MigrationJob 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 MigrationJob(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'gcp:databasemigrationservice/migrationJob:MigrationJob'; /** * Returns true if the given object is an instance of MigrationJob. 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'] === MigrationJob.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["createTime"] = state?.createTime; resourceInputs["deletionPolicy"] = state?.deletionPolicy; resourceInputs["destination"] = state?.destination; resourceInputs["displayName"] = state?.displayName; resourceInputs["dumpFlags"] = state?.dumpFlags; resourceInputs["dumpPath"] = state?.dumpPath; resourceInputs["dumpType"] = state?.dumpType; resourceInputs["effectiveLabels"] = state?.effectiveLabels; resourceInputs["errors"] = state?.errors; resourceInputs["labels"] = state?.labels; resourceInputs["location"] = state?.location; resourceInputs["migrationJobId"] = state?.migrationJobId; resourceInputs["name"] = state?.name; resourceInputs["objectsConfig"] = state?.objectsConfig; resourceInputs["performanceConfig"] = state?.performanceConfig; resourceInputs["phase"] = state?.phase; resourceInputs["postgresHomogeneousConfig"] = state?.postgresHomogeneousConfig; resourceInputs["project"] = state?.project; resourceInputs["pulumiLabels"] = state?.pulumiLabels; resourceInputs["reverseSshConnectivity"] = state?.reverseSshConnectivity; resourceInputs["source"] = state?.source; resourceInputs["state"] = state?.state; resourceInputs["staticIpConnectivity"] = state?.staticIpConnectivity; resourceInputs["type"] = state?.type; resourceInputs["vpcPeeringConnectivity"] = state?.vpcPeeringConnectivity; } else { const args = argsOrState; if (args?.destination === undefined && !opts.urn) { throw new Error("Missing required property 'destination'"); } if (args?.migrationJobId === undefined && !opts.urn) { throw new Error("Missing required property 'migrationJobId'"); } if (args?.source === undefined && !opts.urn) { throw new Error("Missing required property 'source'"); } if (args?.type === undefined && !opts.urn) { throw new Error("Missing required property 'type'"); } resourceInputs["deletionPolicy"] = args?.deletionPolicy; resourceInputs["destination"] = args?.destination; resourceInputs["displayName"] = args?.displayName; resourceInputs["dumpFlags"] = args?.dumpFlags; resourceInputs["dumpPath"] = args?.dumpPath; resourceInputs["dumpType"] = args?.dumpType; resourceInputs["labels"] = args?.labels; resourceInputs["location"] = args?.location; resourceInputs["migrationJobId"] = args?.migrationJobId; resourceInputs["objectsConfig"] = args?.objectsConfig; resourceInputs["performanceConfig"] = args?.performanceConfig; resourceInputs["postgresHomogeneousConfig"] = args?.postgresHomogeneousConfig; resourceInputs["project"] = args?.project; resourceInputs["reverseSshConnectivity"] = args?.reverseSshConnectivity; resourceInputs["source"] = args?.source; resourceInputs["staticIpConnectivity"] = args?.staticIpConnectivity; resourceInputs["type"] = args?.type; resourceInputs["vpcPeeringConnectivity"] = args?.vpcPeeringConnectivity; resourceInputs["createTime"] = undefined /*out*/; resourceInputs["effectiveLabels"] = undefined /*out*/; resourceInputs["errors"] = undefined /*out*/; resourceInputs["name"] = undefined /*out*/; resourceInputs["phase"] = 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(MigrationJob.__pulumiType, name, resourceInputs, opts); } } exports.MigrationJob = MigrationJob; //# sourceMappingURL=migrationJob.js.map