Rds Clone Db Instance
Provides an RDS Clone DB Instance resource. For information about RDS Clone DB Instance and how to use it, see What is ApsaraDB for RDS.
NOTE: Available since v1.149.0+.
Example Usage
Create an RDS MySQL clone instance
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const example = alicloud.rds.getZones({
engine: "PostgreSQL",
engineVersion: "13.0",
instanceChargeType: "PostPaid",
category: "HighAvailability",
dbInstanceStorageType: "cloud_essd",
});
const exampleGetInstanceClasses = example.then(example => alicloud.rds.getInstanceClasses({
zoneId: example.zones?.[0]?.id,
engine: "PostgreSQL",
engineVersion: "13.0",
category: "HighAvailability",
dbInstanceStorageType: "cloud_essd",
instanceChargeType: "PostPaid",
}));
const exampleNetwork = new alicloud.vpc.Network("example", {
vpcName: "terraform-example",
cidrBlock: "172.16.0.0/16",
});
const exampleSwitch = new alicloud.vpc.Switch("example", {
vpcId: exampleNetwork.id,
cidrBlock: "172.16.0.0/24",
zoneId: example.then(example => example.zones?.[0]?.id),
vswitchName: "terraform-example",
});
const exampleInstance = new alicloud.rds.Instance("example", {
engine: "PostgreSQL",
engineVersion: "13.0",
instanceType: exampleGetInstanceClasses.then(exampleGetInstanceClasses => exampleGetInstanceClasses.instanceClasses?.[0]?.instanceClass),
instanceStorage: exampleGetInstanceClasses.then(exampleGetInstanceClasses => exampleGetInstanceClasses.instanceClasses?.[0]?.storageRange?.min),
instanceChargeType: "Postpaid",
instanceName: "terraform-example",
vswitchId: exampleSwitch.id,
monitoringPeriod: 60,
});
const exampleRdsBackup = new alicloud.rds.RdsBackup("example", {
dbInstanceId: exampleInstance.id,
removeFromState: true,
});
const exampleRdsCloneDbInstance = new alicloud.rds.RdsCloneDbInstance("example", {
sourceDbInstanceId: exampleInstance.id,
dbInstanceStorageType: "cloud_essd",
paymentType: "PayAsYouGo",
backupId: exampleRdsBackup.backupId,
});
import pulumi
import pulumi_alicloud as alicloud
example = alicloud.rds.get_zones(engine="PostgreSQL",
engine_version="13.0",
instance_charge_type="PostPaid",
category="HighAvailability",
db_instance_storage_type="cloud_essd")
example_get_instance_classes = alicloud.rds.get_instance_classes(zone_id=example.zones[0].id,
engine="PostgreSQL",
engine_version="13.0",
category="HighAvailability",
db_instance_storage_type="cloud_essd",
instance_charge_type="PostPaid")
example_network = alicloud.vpc.Network("example",
vpc_name="terraform-example",
cidr_block="172.16.0.0/16")
example_switch = alicloud.vpc.Switch("example",
vpc_id=example_network.id,
cidr_block="172.16.0.0/24",
zone_id=example.zones[0].id,
vswitch_name="terraform-example")
example_instance = alicloud.rds.Instance("example",
engine="PostgreSQL",
engine_version="13.0",
instance_type=example_get_instance_classes.instance_classes[0].instance_class,
instance_storage=example_get_instance_classes.instance_classes[0].storage_range.min,
instance_charge_type="Postpaid",
instance_name="terraform-example",
vswitch_id=example_switch.id,
monitoring_period=60)
example_rds_backup = alicloud.rds.RdsBackup("example",
db_instance_id=example_instance.id,
remove_from_state=True)
example_rds_clone_db_instance = alicloud.rds.RdsCloneDbInstance("example",
source_db_instance_id=example_instance.id,
db_instance_storage_type="cloud_essd",
payment_type="PayAsYouGo",
backup_id=example_rds_backup.backup_id)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var example = AliCloud.Rds.GetZones.Invoke(new()
{
Engine = "PostgreSQL",
EngineVersion = "13.0",
InstanceChargeType = "PostPaid",
Category = "HighAvailability",
DbInstanceStorageType = "cloud_essd",
});
var exampleGetInstanceClasses = AliCloud.Rds.GetInstanceClasses.Invoke(new()
{
ZoneId = example.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
Engine = "PostgreSQL",
EngineVersion = "13.0",
Category = "HighAvailability",
DbInstanceStorageType = "cloud_essd",
InstanceChargeType = "PostPaid",
});
var exampleNetwork = new AliCloud.Vpc.Network("example", new()
{
VpcName = "terraform-example",
CidrBlock = "172.16.0.0/16",
});
var exampleSwitch = new AliCloud.Vpc.Switch("example", new()
{
VpcId = exampleNetwork.Id,
CidrBlock = "172.16.0.0/24",
ZoneId = example.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
VswitchName = "terraform-example",
});
var exampleInstance = new AliCloud.Rds.Instance("example", new()
{
Engine = "PostgreSQL",
EngineVersion = "13.0",
InstanceType = exampleGetInstanceClasses.Apply(getInstanceClassesResult => getInstanceClassesResult.InstanceClasses[0]?.InstanceClass),
InstanceStorage = exampleGetInstanceClasses.Apply(getInstanceClassesResult => getInstanceClassesResult.InstanceClasses[0]?.StorageRange?.Min),
InstanceChargeType = "Postpaid",
InstanceName = "terraform-example",
VswitchId = exampleSwitch.Id,
MonitoringPeriod = 60,
});
var exampleRdsBackup = new AliCloud.Rds.RdsBackup("example", new()
{
DbInstanceId = exampleInstance.Id,
RemoveFromState = true,
});
var exampleRdsCloneDbInstance = new AliCloud.Rds.RdsCloneDbInstance("example", new()
{
SourceDbInstanceId = exampleInstance.Id,
DbInstanceStorageType = "cloud_essd",
PaymentType = "PayAsYouGo",
BackupId = exampleRdsBackup.BackupId,
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/rds"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := rds.GetZones(ctx, &rds.GetZonesArgs{
Engine: pulumi.StringRef("PostgreSQL"),
EngineVersion: pulumi.StringRef("13.0"),
InstanceChargeType: pulumi.StringRef("PostPaid"),
Category: pulumi.StringRef("HighAvailability"),
DbInstanceStorageType: pulumi.StringRef("cloud_essd"),
}, nil)
if err != nil {
return err
}
exampleGetInstanceClasses, err := rds.GetInstanceClasses(ctx, &rds.GetInstanceClassesArgs{
ZoneId: pulumi.StringRef(example.Zones[0].Id),
Engine: pulumi.StringRef("PostgreSQL"),
EngineVersion: pulumi.StringRef("13.0"),
Category: pulumi.StringRef("HighAvailability"),
DbInstanceStorageType: pulumi.StringRef("cloud_essd"),
InstanceChargeType: pulumi.StringRef("PostPaid"),
}, nil)
if err != nil {
return err
}
exampleNetwork, err := vpc.NewNetwork(ctx, "example", &vpc.NetworkArgs{
VpcName: pulumi.String("terraform-example"),
CidrBlock: pulumi.String("172.16.0.0/16"),
})
if err != nil {
return err
}
exampleSwitch, err := vpc.NewSwitch(ctx, "example", &vpc.SwitchArgs{
VpcId: exampleNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/24"),
ZoneId: pulumi.String(example.Zones[0].Id),
VswitchName: pulumi.String("terraform-example"),
})
if err != nil {
return err
}
exampleInstance, err := rds.NewInstance(ctx, "example", &rds.InstanceArgs{
Engine: pulumi.String("PostgreSQL"),
EngineVersion: pulumi.String("13.0"),
InstanceType: pulumi.String(exampleGetInstanceClasses.InstanceClasses[0].InstanceClass),
InstanceStorage: pulumi.String(exampleGetInstanceClasses.InstanceClasses[0].StorageRange.Min),
InstanceChargeType: pulumi.String("Postpaid"),
InstanceName: pulumi.String("terraform-example"),
VswitchId: exampleSwitch.ID(),
MonitoringPeriod: pulumi.Int(60),
})
if err != nil {
return err
}
exampleRdsBackup, err := rds.NewRdsBackup(ctx, "example", &rds.RdsBackupArgs{
DbInstanceId: exampleInstance.ID(),
RemoveFromState: pulumi.Bool(true),
})
if err != nil {
return err
}
_, err = rds.NewRdsCloneDbInstance(ctx, "example", &rds.RdsCloneDbInstanceArgs{
SourceDbInstanceId: exampleInstance.ID(),
DbInstanceStorageType: pulumi.String("cloud_essd"),
PaymentType: pulumi.String("PayAsYouGo"),
BackupId: exampleRdsBackup.BackupId,
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.rds.RdsFunctions;
import com.pulumi.alicloud.rds.inputs.GetZonesArgs;
import com.pulumi.alicloud.rds.inputs.GetInstanceClassesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.rds.Instance;
import com.pulumi.alicloud.rds.InstanceArgs;
import com.pulumi.alicloud.rds.RdsBackup;
import com.pulumi.alicloud.rds.RdsBackupArgs;
import com.pulumi.alicloud.rds.RdsCloneDbInstance;
import com.pulumi.alicloud.rds.RdsCloneDbInstanceArgs;
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) {
final var example = RdsFunctions.getZones(GetZonesArgs.builder()
.engine("PostgreSQL")
.engineVersion("13.0")
.instanceChargeType("PostPaid")
.category("HighAvailability")
.dbInstanceStorageType("cloud_essd")
.build());
final var exampleGetInstanceClasses = RdsFunctions.getInstanceClasses(GetInstanceClassesArgs.builder()
.zoneId(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.engine("PostgreSQL")
.engineVersion("13.0")
.category("HighAvailability")
.dbInstanceStorageType("cloud_essd")
.instanceChargeType("PostPaid")
.build());
var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
.vpcName("terraform-example")
.cidrBlock("172.16.0.0/16")
.build());
var exampleSwitch = new Switch("exampleSwitch", SwitchArgs.builder()
.vpcId(exampleNetwork.id())
.cidrBlock("172.16.0.0/24")
.zoneId(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
.vswitchName("terraform-example")
.build());
var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
.engine("PostgreSQL")
.engineVersion("13.0")
.instanceType(exampleGetInstanceClasses.applyValue(getInstanceClassesResult -> getInstanceClassesResult.instanceClasses()[0].instanceClass()))
.instanceStorage(exampleGetInstanceClasses.applyValue(getInstanceClassesResult -> getInstanceClassesResult.instanceClasses()[0].storageRange().min()))
.instanceChargeType("Postpaid")
.instanceName("terraform-example")
.vswitchId(exampleSwitch.id())
.monitoringPeriod("60")
.build());
var exampleRdsBackup = new RdsBackup("exampleRdsBackup", RdsBackupArgs.builder()
.dbInstanceId(exampleInstance.id())
.removeFromState("true")
.build());
var exampleRdsCloneDbInstance = new RdsCloneDbInstance("exampleRdsCloneDbInstance", RdsCloneDbInstanceArgs.builder()
.sourceDbInstanceId(exampleInstance.id())
.dbInstanceStorageType("cloud_essd")
.paymentType("PayAsYouGo")
.backupId(exampleRdsBackup.backupId())
.build());
}
}
resources:
exampleNetwork:
type: alicloud:vpc:Network
name: example
properties:
vpcName: terraform-example
cidrBlock: 172.16.0.0/16
exampleSwitch:
type: alicloud:vpc:Switch
name: example
properties:
vpcId: ${exampleNetwork.id}
cidrBlock: 172.16.0.0/24
zoneId: ${example.zones[0].id}
vswitchName: terraform-example
exampleInstance:
type: alicloud:rds:Instance
name: example
properties:
engine: PostgreSQL
engineVersion: '13.0'
instanceType: ${exampleGetInstanceClasses.instanceClasses[0].instanceClass}
instanceStorage: ${exampleGetInstanceClasses.instanceClasses[0].storageRange.min}
instanceChargeType: Postpaid
instanceName: terraform-example
vswitchId: ${exampleSwitch.id}
monitoringPeriod: '60'
exampleRdsBackup:
type: alicloud:rds:RdsBackup
name: example
properties:
dbInstanceId: ${exampleInstance.id}
removeFromState: 'true'
exampleRdsCloneDbInstance:
type: alicloud:rds:RdsCloneDbInstance
name: example
properties:
sourceDbInstanceId: ${exampleInstance.id}
dbInstanceStorageType: cloud_essd
paymentType: PayAsYouGo
backupId: ${exampleRdsBackup.backupId}
variables:
example:
fn::invoke:
function: alicloud:rds:getZones
arguments:
engine: PostgreSQL
engineVersion: '13.0'
instanceChargeType: PostPaid
category: HighAvailability
dbInstanceStorageType: cloud_essd
exampleGetInstanceClasses:
fn::invoke:
function: alicloud:rds:getInstanceClasses
arguments:
zoneId: ${example.zones[0].id}
engine: PostgreSQL
engineVersion: '13.0'
category: HighAvailability
dbInstanceStorageType: cloud_essd
instanceChargeType: PostPaid
Import
RDS Clone DB Instance can be imported using the id, e.g.
$ pulumi import alicloud:rds/rdsCloneDbInstance:RdsCloneDbInstance example <id>
Properties
This parameter is only supported by the RDS PostgreSQL cloud disk version. This parameter indicates the authentication method. It is allowed only when the public key of the client certificate authority is enabled. Valid values: cert
and perfer
and verify-ca
and verify-full (supported by RDS PostgreSQL above 12)
.
How to upgrade the minor version of the instance. Valid values:
The type of backup that is used to restore the data of the original instance. Valid values:
The file that contains the certificate used for TDE.
This parameter is only supported by the RDS PostgreSQL cloud disk version. It indicates the public key of the client certification authority. If the value of client_ca_enabled is 1, this parameter must be configured.
The client ca enabled.
This parameter is only supported by the RDS PostgreSQL cloud disk version, which indicates that the client revokes the certificate file. If the value of client_crl_enabled is 1, this parameter must be configured.
The client crl enabled.
The database connection address.
The connection string prefix.
The instance type of the new instance. For information, see Primary ApsaraDB RDS instance types.
The db instance description.
The storage capacity of the new instance. Unit: GB. The storage capacity increases in increments of 5 GB. For more information, see Primary ApsaraDB RDS instance types.
The type of storage media that is used for the new instance. Valid values:
The ID of the dedicated cluster to which the new instance belongs. This parameter takes effect only when you create the new instance in a dedicated cluster.
The switch of delete protection. Valid values:
The effective time.
The ID of the private key.
Database version. Value:
Set it to true to make some parameter efficient when modifying them. Default to false.
The network type of the instance. Valid values:
The maintainable time period of the instance. Format: HH:mm Z- HH:mm Z(UTC time).
Set of parameters needs to be set after DB instance was launched. Available parameters can refer to the latest docs View database parameter templates.See parameters
below.
The billing method of the new instance. Valid values: PayAsYouGo
and Subscription
and Serverless
.
The details of the AD domain.See pg_hba_conf
below.
The intranet IP address of the new instance must be within the specified vSwitch IP address range. By default, the system automatically allocates by using VPCId and VSwitchId.
The file that contains the private key used for TDE.
The released keep policy.
This parameter is only supported by the RDS PostgreSQL cloud disk version, indicating the authentication method of the replication permission. It is only allowed when the public key of the client certificate authority is enabled. Valid values: cert
and perfer
and verify-ca
and verify-full (supported by RDS PostgreSQL above 12)
.
The resource group id.
Specifies whether to restore only the databases and tables that you specify. The value 1 specifies to restore only the specified databases and tables. If you do not want to restore only the specified databases or tables, you can choose not to specify this parameter.
The point in time to which you want to restore the data of the original instance. The point in time must fall within the specified log backup retention period. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.
The IP address whitelist of the instance. Separate multiple IP addresses with commas (,) and cannot be repeated. The following two formats are supported:
This parameter is only supported by the RDS PostgreSQL cloud disk version. It indicates the content of the server certificate. If the CAType value is custom, this parameter must be configured.
The settings of the serverless instance. This parameter is required when you create a serverless instance. This parameter takes effect only when you create an ApsaraDB RDS for MySQL instance.See serverless_config
below.
The source db instance id.
Enable or disable SSL. Valid values: 0
and 1
.
The time at which you want to apply the specification changes. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.
The data replication mode. Valid values:
The information about the databases and tables that you want to restore. Format: [{"type":"db","name":"The original name of Database 1","newname":"The new name of Database 1","tables":{"type":"table","name":"The original name of Table 1 in Database 1","newname":"The new name of Table 1 in Database 1"},{"type":"table","name":"The original name of Table 2 in Database 1","newname":"The new name of Table 2 in Database 1"}},{"type":"db","name":"The original name of Database 2","newname":"The new name of Database 2","tables":{"type":"table","name":"The original name of Table 1 in Database 2","newname":"The new name of Table 1 in Database 2"},{"type":"table","name":"The original name of Table 2 in Database 2","newname":"The new name of Table 2 in Database 2"}}]
The availability check method of the instance. Valid values:
The ID of the zone to which the new instance belongs. You can call the DescribeRegions operation to query the most recent region list.
The region ID of the secondary instance if you create a secondary instance. If you set this parameter to the same value as the ZoneId parameter, the instance is deployed in a single zone. Otherwise, the instance is deployed in multiple zones.
The region ID of the log instance if you create a log instance. If you set this parameter to the same value as the ZoneId parameter, the instance is deployed in a single zone. Otherwise, the instance is deployed in multiple zones.