@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
438 lines • 17.1 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.MigrationJob = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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,
* },
* 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,
* },
* 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 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,
* },
* 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",
* },
* });
* 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}}
* ```
*
* ```sh
* $ pulumi import gcp:databasemigrationservice/migrationJob:MigrationJob default {{project}}/{{location}}/{{migration_job_id}}
* ```
*
* ```sh
* $ 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, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* 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 ? state.createTime : undefined;
resourceInputs["destination"] = state ? state.destination : undefined;
resourceInputs["displayName"] = state ? state.displayName : undefined;
resourceInputs["dumpFlags"] = state ? state.dumpFlags : undefined;
resourceInputs["dumpPath"] = state ? state.dumpPath : undefined;
resourceInputs["dumpType"] = state ? state.dumpType : 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["migrationJobId"] = state ? state.migrationJobId : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["performanceConfig"] = state ? state.performanceConfig : undefined;
resourceInputs["phase"] = state ? state.phase : undefined;
resourceInputs["project"] = state ? state.project : undefined;
resourceInputs["pulumiLabels"] = state ? state.pulumiLabels : undefined;
resourceInputs["reverseSshConnectivity"] = state ? state.reverseSshConnectivity : undefined;
resourceInputs["source"] = state ? state.source : undefined;
resourceInputs["state"] = state ? state.state : undefined;
resourceInputs["staticIpConnectivity"] = state ? state.staticIpConnectivity : undefined;
resourceInputs["type"] = state ? state.type : undefined;
resourceInputs["vpcPeeringConnectivity"] = state ? state.vpcPeeringConnectivity : undefined;
}
else {
const args = argsOrState;
if ((!args || args.destination === undefined) && !opts.urn) {
throw new Error("Missing required property 'destination'");
}
if ((!args || args.migrationJobId === undefined) && !opts.urn) {
throw new Error("Missing required property 'migrationJobId'");
}
if ((!args || args.source === undefined) && !opts.urn) {
throw new Error("Missing required property 'source'");
}
if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["destination"] = args ? args.destination : undefined;
resourceInputs["displayName"] = args ? args.displayName : undefined;
resourceInputs["dumpFlags"] = args ? args.dumpFlags : undefined;
resourceInputs["dumpPath"] = args ? args.dumpPath : undefined;
resourceInputs["dumpType"] = args ? args.dumpType : undefined;
resourceInputs["labels"] = args ? args.labels : undefined;
resourceInputs["location"] = args ? args.location : undefined;
resourceInputs["migrationJobId"] = args ? args.migrationJobId : undefined;
resourceInputs["performanceConfig"] = args ? args.performanceConfig : undefined;
resourceInputs["project"] = args ? args.project : undefined;
resourceInputs["reverseSshConnectivity"] = args ? args.reverseSshConnectivity : undefined;
resourceInputs["source"] = args ? args.source : undefined;
resourceInputs["staticIpConnectivity"] = args ? args.staticIpConnectivity : undefined;
resourceInputs["type"] = args ? args.type : undefined;
resourceInputs["vpcPeeringConnectivity"] = args ? args.vpcPeeringConnectivity : undefined;
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;
/** @internal */
MigrationJob.__pulumiType = 'gcp:databasemigrationservice/migrationJob:MigrationJob';
//# sourceMappingURL=migrationJob.js.map