digitalocean.DatabaseOnlineMigration
Explore with Pulumi AI
Provides a virtual resource that can be used to start an online migration for a DigitalOcean managed database cluster. Migrating a cluster establishes a connection with an existing cluster and replicates its contents to the target cluster. If the existing database is continuously being written to, the migration process will continue for up to two weeks unless it is manually stopped. Online migration is only available for MySQL, PostgreSQL, Caching, and Valkey clusters.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";
const source = new digitalocean.DatabaseCluster("source", {
name: "st01",
engine: "mysql",
version: "8",
size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
region: digitalocean.Region.NYC1,
nodeCount: 1,
tags: ["production"],
});
const destination = new digitalocean.DatabaseCluster("destination", {
name: "dt01",
engine: "mysql",
version: "8",
size: digitalocean.DatabaseSlug.DB_1VPCU1GB,
region: digitalocean.Region.NYC1,
nodeCount: 1,
tags: ["production"],
});
const sourceDb = new digitalocean.DatabaseDb("source_db", {
clusterId: source.id,
name: "terraform-db-om-source",
});
const foobar = new digitalocean.DatabaseOnlineMigration("foobar", {
clusterId: destination.id,
source: {
host: source.host,
dbName: sourceDb.name,
port: source.port,
username: source.user,
password: source.password,
},
}, {
dependsOn: [
destination,
source,
sourceDb,
],
});
import pulumi
import pulumi_digitalocean as digitalocean
source = digitalocean.DatabaseCluster("source",
name="st01",
engine="mysql",
version="8",
size=digitalocean.DatabaseSlug.D_B_1_VPCU1_GB,
region=digitalocean.Region.NYC1,
node_count=1,
tags=["production"])
destination = digitalocean.DatabaseCluster("destination",
name="dt01",
engine="mysql",
version="8",
size=digitalocean.DatabaseSlug.D_B_1_VPCU1_GB,
region=digitalocean.Region.NYC1,
node_count=1,
tags=["production"])
source_db = digitalocean.DatabaseDb("source_db",
cluster_id=source.id,
name="terraform-db-om-source")
foobar = digitalocean.DatabaseOnlineMigration("foobar",
cluster_id=destination.id,
source={
"host": source.host,
"db_name": source_db.name,
"port": source.port,
"username": source.user,
"password": source.password,
},
opts = pulumi.ResourceOptions(depends_on=[
destination,
source,
source_db,
]))
package main
import (
"github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
source, err := digitalocean.NewDatabaseCluster(ctx, "source", &digitalocean.DatabaseClusterArgs{
Name: pulumi.String("st01"),
Engine: pulumi.String("mysql"),
Version: pulumi.String("8"),
Size: pulumi.String(digitalocean.DatabaseSlug_DB_1VPCU1GB),
Region: pulumi.String(digitalocean.RegionNYC1),
NodeCount: pulumi.Int(1),
Tags: pulumi.StringArray{
pulumi.String("production"),
},
})
if err != nil {
return err
}
destination, err := digitalocean.NewDatabaseCluster(ctx, "destination", &digitalocean.DatabaseClusterArgs{
Name: pulumi.String("dt01"),
Engine: pulumi.String("mysql"),
Version: pulumi.String("8"),
Size: pulumi.String(digitalocean.DatabaseSlug_DB_1VPCU1GB),
Region: pulumi.String(digitalocean.RegionNYC1),
NodeCount: pulumi.Int(1),
Tags: pulumi.StringArray{
pulumi.String("production"),
},
})
if err != nil {
return err
}
sourceDb, err := digitalocean.NewDatabaseDb(ctx, "source_db", &digitalocean.DatabaseDbArgs{
ClusterId: source.ID(),
Name: pulumi.String("terraform-db-om-source"),
})
if err != nil {
return err
}
_, err = digitalocean.NewDatabaseOnlineMigration(ctx, "foobar", &digitalocean.DatabaseOnlineMigrationArgs{
ClusterId: destination.ID(),
Source: &digitalocean.DatabaseOnlineMigrationSourceArgs{
Host: source.Host,
DbName: sourceDb.Name,
Port: source.Port,
Username: source.User,
Password: source.Password,
},
}, pulumi.DependsOn([]pulumi.Resource{
destination,
source,
sourceDb,
}))
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;
return await Deployment.RunAsync(() =>
{
var source = new DigitalOcean.DatabaseCluster("source", new()
{
Name = "st01",
Engine = "mysql",
Version = "8",
Size = DigitalOcean.DatabaseSlug.DB_1VPCU1GB,
Region = DigitalOcean.Region.NYC1,
NodeCount = 1,
Tags = new[]
{
"production",
},
});
var destination = new DigitalOcean.DatabaseCluster("destination", new()
{
Name = "dt01",
Engine = "mysql",
Version = "8",
Size = DigitalOcean.DatabaseSlug.DB_1VPCU1GB,
Region = DigitalOcean.Region.NYC1,
NodeCount = 1,
Tags = new[]
{
"production",
},
});
var sourceDb = new DigitalOcean.DatabaseDb("source_db", new()
{
ClusterId = source.Id,
Name = "terraform-db-om-source",
});
var foobar = new DigitalOcean.DatabaseOnlineMigration("foobar", new()
{
ClusterId = destination.Id,
Source = new DigitalOcean.Inputs.DatabaseOnlineMigrationSourceArgs
{
Host = source.Host,
DbName = sourceDb.Name,
Port = source.Port,
Username = source.User,
Password = source.Password,
},
}, new CustomResourceOptions
{
DependsOn =
{
destination,
source,
sourceDb,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.digitalocean.DatabaseCluster;
import com.pulumi.digitalocean.DatabaseClusterArgs;
import com.pulumi.digitalocean.DatabaseDb;
import com.pulumi.digitalocean.DatabaseDbArgs;
import com.pulumi.digitalocean.DatabaseOnlineMigration;
import com.pulumi.digitalocean.DatabaseOnlineMigrationArgs;
import com.pulumi.digitalocean.inputs.DatabaseOnlineMigrationSourceArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var source = new DatabaseCluster("source", DatabaseClusterArgs.builder()
.name("st01")
.engine("mysql")
.version("8")
.size("db-s-1vcpu-1gb")
.region("nyc1")
.nodeCount(1)
.tags("production")
.build());
var destination = new DatabaseCluster("destination", DatabaseClusterArgs.builder()
.name("dt01")
.engine("mysql")
.version("8")
.size("db-s-1vcpu-1gb")
.region("nyc1")
.nodeCount(1)
.tags("production")
.build());
var sourceDb = new DatabaseDb("sourceDb", DatabaseDbArgs.builder()
.clusterId(source.id())
.name("terraform-db-om-source")
.build());
var foobar = new DatabaseOnlineMigration("foobar", DatabaseOnlineMigrationArgs.builder()
.clusterId(destination.id())
.source(DatabaseOnlineMigrationSourceArgs.builder()
.host(source.host())
.dbName(sourceDb.name())
.port(source.port())
.username(source.user())
.password(source.password())
.build())
.build(), CustomResourceOptions.builder()
.dependsOn(
destination,
source,
sourceDb)
.build());
}
}
resources:
source:
type: digitalocean:DatabaseCluster
properties:
name: st01
engine: mysql
version: '8'
size: db-s-1vcpu-1gb
region: nyc1
nodeCount: 1
tags:
- production
destination:
type: digitalocean:DatabaseCluster
properties:
name: dt01
engine: mysql
version: '8'
size: db-s-1vcpu-1gb
region: nyc1
nodeCount: 1
tags:
- production
sourceDb:
type: digitalocean:DatabaseDb
name: source_db
properties:
clusterId: ${source.id}
name: terraform-db-om-source
foobar:
type: digitalocean:DatabaseOnlineMigration
properties:
clusterId: ${destination.id}
source:
host: ${source.host}
dbName: ${sourceDb.name}
port: ${source.port}
username: ${source.user}
password: ${source.password}
options:
dependsOn:
- ${destination}
- ${source}
- ${sourceDb}
Create DatabaseOnlineMigration Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DatabaseOnlineMigration(name: string, args: DatabaseOnlineMigrationArgs, opts?: CustomResourceOptions);
@overload
def DatabaseOnlineMigration(resource_name: str,
args: DatabaseOnlineMigrationArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DatabaseOnlineMigration(resource_name: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
source: Optional[DatabaseOnlineMigrationSourceArgs] = None,
disable_ssl: Optional[bool] = None,
ignore_dbs: Optional[Sequence[str]] = None)
func NewDatabaseOnlineMigration(ctx *Context, name string, args DatabaseOnlineMigrationArgs, opts ...ResourceOption) (*DatabaseOnlineMigration, error)
public DatabaseOnlineMigration(string name, DatabaseOnlineMigrationArgs args, CustomResourceOptions? opts = null)
public DatabaseOnlineMigration(String name, DatabaseOnlineMigrationArgs args)
public DatabaseOnlineMigration(String name, DatabaseOnlineMigrationArgs args, CustomResourceOptions options)
type: digitalocean:DatabaseOnlineMigration
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args DatabaseOnlineMigrationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args DatabaseOnlineMigrationArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args DatabaseOnlineMigrationArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DatabaseOnlineMigrationArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DatabaseOnlineMigrationArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var databaseOnlineMigrationResource = new DigitalOcean.DatabaseOnlineMigration("databaseOnlineMigrationResource", new()
{
ClusterId = "string",
Source = new DigitalOcean.Inputs.DatabaseOnlineMigrationSourceArgs
{
DbName = "string",
Host = "string",
Password = "string",
Port = 0,
Username = "string",
},
DisableSsl = false,
IgnoreDbs = new[]
{
"string",
},
});
example, err := digitalocean.NewDatabaseOnlineMigration(ctx, "databaseOnlineMigrationResource", &digitalocean.DatabaseOnlineMigrationArgs{
ClusterId: pulumi.String("string"),
Source: &digitalocean.DatabaseOnlineMigrationSourceArgs{
DbName: pulumi.String("string"),
Host: pulumi.String("string"),
Password: pulumi.String("string"),
Port: pulumi.Int(0),
Username: pulumi.String("string"),
},
DisableSsl: pulumi.Bool(false),
IgnoreDbs: pulumi.StringArray{
pulumi.String("string"),
},
})
var databaseOnlineMigrationResource = new DatabaseOnlineMigration("databaseOnlineMigrationResource", DatabaseOnlineMigrationArgs.builder()
.clusterId("string")
.source(DatabaseOnlineMigrationSourceArgs.builder()
.dbName("string")
.host("string")
.password("string")
.port(0)
.username("string")
.build())
.disableSsl(false)
.ignoreDbs("string")
.build());
database_online_migration_resource = digitalocean.DatabaseOnlineMigration("databaseOnlineMigrationResource",
cluster_id="string",
source={
"db_name": "string",
"host": "string",
"password": "string",
"port": 0,
"username": "string",
},
disable_ssl=False,
ignore_dbs=["string"])
const databaseOnlineMigrationResource = new digitalocean.DatabaseOnlineMigration("databaseOnlineMigrationResource", {
clusterId: "string",
source: {
dbName: "string",
host: "string",
password: "string",
port: 0,
username: "string",
},
disableSsl: false,
ignoreDbs: ["string"],
});
type: digitalocean:DatabaseOnlineMigration
properties:
clusterId: string
disableSsl: false
ignoreDbs:
- string
source:
dbName: string
host: string
password: string
port: 0
username: string
DatabaseOnlineMigration Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The DatabaseOnlineMigration resource accepts the following input properties:
- Cluster
Id string - The ID of the target MySQL cluster.
- Source
Pulumi.
Digital Ocean. Inputs. Database Online Migration Source - Configuration for migration
- Disable
Ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- Ignore
Dbs List<string> - A list of databases that should be ignored during migration.
- Cluster
Id string - The ID of the target MySQL cluster.
- Source
Database
Online Migration Source Args - Configuration for migration
- Disable
Ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- Ignore
Dbs []string - A list of databases that should be ignored during migration.
- cluster
Id String - The ID of the target MySQL cluster.
- source
Database
Online Migration Source - Configuration for migration
- disable
Ssl Boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs List<String> - A list of databases that should be ignored during migration.
- cluster
Id string - The ID of the target MySQL cluster.
- source
Database
Online Migration Source - Configuration for migration
- disable
Ssl boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs string[] - A list of databases that should be ignored during migration.
- cluster_
id str - The ID of the target MySQL cluster.
- source
Database
Online Migration Source Args - Configuration for migration
- disable_
ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- ignore_
dbs Sequence[str] - A list of databases that should be ignored during migration.
- cluster
Id String - The ID of the target MySQL cluster.
- source Property Map
- Configuration for migration
- disable
Ssl Boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs List<String> - A list of databases that should be ignored during migration.
Outputs
All input properties are implicitly available as output properties. Additionally, the DatabaseOnlineMigration resource produces the following output properties:
- created_
at str - The date and time when the online migration was created
- id str
- The provider-assigned unique ID for this managed resource.
- status str
- The status of the online migration
Look up Existing DatabaseOnlineMigration Resource
Get an existing DatabaseOnlineMigration resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: DatabaseOnlineMigrationState, opts?: CustomResourceOptions): DatabaseOnlineMigration
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cluster_id: Optional[str] = None,
created_at: Optional[str] = None,
disable_ssl: Optional[bool] = None,
ignore_dbs: Optional[Sequence[str]] = None,
source: Optional[DatabaseOnlineMigrationSourceArgs] = None,
status: Optional[str] = None) -> DatabaseOnlineMigration
func GetDatabaseOnlineMigration(ctx *Context, name string, id IDInput, state *DatabaseOnlineMigrationState, opts ...ResourceOption) (*DatabaseOnlineMigration, error)
public static DatabaseOnlineMigration Get(string name, Input<string> id, DatabaseOnlineMigrationState? state, CustomResourceOptions? opts = null)
public static DatabaseOnlineMigration get(String name, Output<String> id, DatabaseOnlineMigrationState state, CustomResourceOptions options)
resources: _: type: digitalocean:DatabaseOnlineMigration get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Cluster
Id string - The ID of the target MySQL cluster.
- Created
At string - The date and time when the online migration was created
- Disable
Ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- Ignore
Dbs List<string> - A list of databases that should be ignored during migration.
- Source
Pulumi.
Digital Ocean. Inputs. Database Online Migration Source - Configuration for migration
- Status string
- The status of the online migration
- Cluster
Id string - The ID of the target MySQL cluster.
- Created
At string - The date and time when the online migration was created
- Disable
Ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- Ignore
Dbs []string - A list of databases that should be ignored during migration.
- Source
Database
Online Migration Source Args - Configuration for migration
- Status string
- The status of the online migration
- cluster
Id String - The ID of the target MySQL cluster.
- created
At String - The date and time when the online migration was created
- disable
Ssl Boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs List<String> - A list of databases that should be ignored during migration.
- source
Database
Online Migration Source - Configuration for migration
- status String
- The status of the online migration
- cluster
Id string - The ID of the target MySQL cluster.
- created
At string - The date and time when the online migration was created
- disable
Ssl boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs string[] - A list of databases that should be ignored during migration.
- source
Database
Online Migration Source - Configuration for migration
- status string
- The status of the online migration
- cluster_
id str - The ID of the target MySQL cluster.
- created_
at str - The date and time when the online migration was created
- disable_
ssl bool - When set to true, enables SSL encryption when connecting to the source database.
- ignore_
dbs Sequence[str] - A list of databases that should be ignored during migration.
- source
Database
Online Migration Source Args - Configuration for migration
- status str
- The status of the online migration
- cluster
Id String - The ID of the target MySQL cluster.
- created
At String - The date and time when the online migration was created
- disable
Ssl Boolean - When set to true, enables SSL encryption when connecting to the source database.
- ignore
Dbs List<String> - A list of databases that should be ignored during migration.
- source Property Map
- Configuration for migration
- status String
- The status of the online migration
Supporting Types
DatabaseOnlineMigrationSource, DatabaseOnlineMigrationSourceArgs
- db
Name String - The name of the default database
- host String
- The FQDN pointing to the database cluster's current primary node.
- password String
- A randomly generated password for the default user.
- port Integer
- The port on which the database cluster is listening.
- username String
- The default user for the database.
Import
A MySQL database cluster’s online_migration can be imported using the id
the parent cluster, e.g.
$ pulumi import digitalocean:index/databaseOnlineMigration:DatabaseOnlineMigration example 4b62829a-9c42-465b-aaa3-84051048e712
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- DigitalOcean pulumi/pulumi-digitalocean
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
digitalocean
Terraform Provider.