Instance
Provides a MongoDB instance resource supports replica set instances only. the MongoDB provides stable, reliable, and automatic scalable database services. It offers a full range of database solutions, such as disaster recovery, backup, recovery, monitoring, and alarms. You can see detail product introduction here
NOTE: Available since v1.37.0. NOTE: The following regions don't support create Classic network MongoDB instance. `cn-zhangjiakou`,`cn-huhehaote`,`ap-southeast-3`,`ap-southeast-5`,`me-east-1`,`ap-northeast-1`,`eu-west-1` NOTE: Create MongoDB instance or change instance type and storage would cost 5~10 minutes. Please make full preparation
Example Usage
Create a Mongodb instance
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "terraform-example";
const _default = alicloud.mongodb.getZones({});
const index = _default.then(_default => _default.zones).length.apply(length => length - 1);
const zoneId = _default.then(_default => _default.zones[index].id);
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "172.17.3.0/24",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vswitchName: name,
cidrBlock: "172.17.3.0/24",
vpcId: defaultNetwork.id,
zoneId: zoneId,
});
const defaultInstance = new alicloud.mongodb.Instance("default", {
engineVersion: "4.2",
dbInstanceClass: "dds.mongo.mid",
dbInstanceStorage: 10,
vswitchId: defaultSwitch.id,
securityIpLists: [
"10.168.1.12",
"100.69.7.112",
],
name: name,
tags: {
Created: "TF",
For: "example",
},
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "terraform-example"
default = alicloud.mongodb.get_zones()
index = len(default.zones).apply(lambda length: length - 1)
zone_id = default.zones[index].id
default_network = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="172.17.3.0/24")
default_switch = alicloud.vpc.Switch("default",
vswitch_name=name,
cidr_block="172.17.3.0/24",
vpc_id=default_network.id,
zone_id=zone_id)
default_instance = alicloud.mongodb.Instance("default",
engine_version="4.2",
db_instance_class="dds.mongo.mid",
db_instance_storage=10,
vswitch_id=default_switch.id,
security_ip_lists=[
"10.168.1.12",
"100.69.7.112",
],
name=name,
tags={
"Created": "TF",
"For": "example",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "terraform-example";
var @default = AliCloud.MongoDB.GetZones.Invoke();
var index = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)).Length.Apply(length => length - 1);
var zoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)[index].Id);
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
VpcName = name,
CidrBlock = "172.17.3.0/24",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VswitchName = name,
CidrBlock = "172.17.3.0/24",
VpcId = defaultNetwork.Id,
ZoneId = zoneId,
});
var defaultInstance = new AliCloud.MongoDB.Instance("default", new()
{
EngineVersion = "4.2",
DbInstanceClass = "dds.mongo.mid",
DbInstanceStorage = 10,
VswitchId = defaultSwitch.Id,
SecurityIpLists = new[]
{
"10.168.1.12",
"100.69.7.112",
},
Name = name,
Tags =
{
{ "Created", "TF" },
{ "For", "example" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mongodb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "terraform-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := mongodb.GetZones(ctx, &mongodb.GetZonesArgs{}, nil)
if err != nil {
return err
}
index := len(_default.Zones).ApplyT(func(length int) (float64, error) {
return length - 1, nil
}).(pulumi.Float64Output)
zoneId := _default.Zones[index].Id
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("172.17.3.0/24"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VswitchName: pulumi.String(name),
CidrBlock: pulumi.String("172.17.3.0/24"),
VpcId: defaultNetwork.ID(),
ZoneId: pulumi.String(zoneId),
})
if err != nil {
return err
}
_, err = mongodb.NewInstance(ctx, "default", &mongodb.InstanceArgs{
EngineVersion: pulumi.String("4.2"),
DbInstanceClass: pulumi.String("dds.mongo.mid"),
DbInstanceStorage: pulumi.Int(10),
VswitchId: defaultSwitch.ID(),
SecurityIpLists: pulumi.StringArray{
pulumi.String("10.168.1.12"),
pulumi.String("100.69.7.112"),
},
Name: pulumi.String(name),
Tags: pulumi.StringMap{
"Created": pulumi.String("TF"),
"For": pulumi.String("example"),
},
})
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.mongodb.MongodbFunctions;
import com.pulumi.alicloud.mongodb.inputs.GetZonesArgs;
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.mongodb.Instance;
import com.pulumi.alicloud.mongodb.InstanceArgs;
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 config = ctx.config();
final var name = config.get("name").orElse("terraform-example");
final var default = MongodbFunctions.getZones(GetZonesArgs.builder()
.build());
final var index = default_.zones().length().applyValue(_length -> _length - 1);
final var zoneId = default_.zones()[index].id();
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("172.17.3.0/24")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vswitchName(name)
.cidrBlock("172.17.3.0/24")
.vpcId(defaultNetwork.id())
.zoneId(zoneId)
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.engineVersion("4.2")
.dbInstanceClass("dds.mongo.mid")
.dbInstanceStorage(10)
.vswitchId(defaultSwitch.id())
.securityIpLists(
"10.168.1.12",
"100.69.7.112")
.name(name)
.tags(Map.ofEntries(
Map.entry("Created", "TF"),
Map.entry("For", "example")
))
.build());
}
}
Module Support
You can use to the existing mongodb module to create a MongoDB instance resource one-click.
Import
MongoDB instance can be imported using the id, e.g.
$ pulumi import alicloud:mongodb/instance:Instance example dds-bp1291daeda44194
Properties
Password of the root account. It is a string of 6 to 32 characters and is composed of letters, numbers, and underlines.
The frequency at which high-frequency backups are created. Valid values: -1
, 15
, 30
, 60
, 120
, 180
, 240
, 360
, 480
, 720
.
MongoDB Instance backup period. It is required when backup_time
was existed. Valid values: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday. Default to Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.
The retention period of full backups.
The backup retention policy configured for the instance. Valid values:
MongoDB instance backup time. It is required when backup_period
was existed. In the format of HH:mmZ- HH:mmZ. Time setting interval is one hour. If not set, the system will return a default, like "23:00Z-24:00Z".
The ID of the encryption key.
Instance specification. see Instance specifications.
User-defined DB instance storage space.Unit: GB. Value range:
The time when the changed configurations take effect. Valid values: Immediately
, MaintainTime
.
Specifies whether to enable the log backup feature. Valid values:
The ID of the custom key.
The encryption method. NOTE: encryptor_name
is valid only when tde_status
is set to enabled
.
Database version. Value options can refer to the latest docs CreateDBInstance EngineVersion
. NOTE: From version 1.225.0, engine_version
can be modified.
Configure the zone where the hidden node is located to deploy multiple zones. NOTE: This parameter value cannot be the same as zone_id
and secondary_zone_id
parameter values.
The billing method of the instance. Default value: PostPaid
. Valid values: PrePaid
, PostPaid
. NOTE: It can be modified from PostPaid
to PrePaid
after version 1.63.0.
An KMS encrypts password used to a instance. If the account_password
is filled in, this field will be ignored.
An KMS encryption context used to decrypt kms_encrypted_password
before creating or updating instance with kms_encrypted_password
. See Encryption Context. It is valid when kms_encrypted_password
is set.
The number of days for which log backups are retained. Valid values: 7
to 730
. NOTE: log_backup_retention_period
is valid only when enable_backup_log
is set to 1
.
The end time of the operation and maintenance time period of the instance, in the format of HH:mmZ (UTC time).
The start time of the operation and maintenance time period of the instance, in the format of HH:mmZ (UTC time).
The network type of the instance. Valid values:Classic
, VPC
.
Set of parameters needs to be set after mongodb instance was launched. See parameters
below.
The provisioned IOPS. Valid values: 0
to 50000
.
The number of read-only nodes in the replica set instance. Default value: 0. Valid values: 0 to 5.
The name of the mongo replica set.
Replica set instance information.
Number of replica set nodes. Valid values: 1
, 3
, 5
, 7
.
The ID of the Resource Group.
Instance data backup retention days. Available since v1.42.0.
Configure the available area where the slave node (Secondary node) is located to realize multi-available area deployment. NOTE: This parameter value cannot be the same as zone_id
and hidden_zone_id
parameter values.
The Security Group ID of ECS.
List of IP addresses allowed to access all databases of an instance. The list contains up to 1,000 IP addresses, separated by commas. Supported formats include 0.0.0.0/0, 10.23.12.24 (IP), and 10.23.12.24/24 (Classless Inter-Domain Routing (CIDR) mode. /24 represents the length of the prefix in an IP address. The range of the prefix length is 1,32).
The snapshot backup type. Default value: Standard
. Valid values:
The storage engine of the instance. Default value: WiredTiger
. Valid values: WiredTiger
, RocksDB
.
The storage type of the instance. Valid values: cloud_essd1
, cloud_essd2
, cloud_essd3
, cloud_auto
, local_ssd
. NOTE: From version 1.229.0, storage_type
can be modified. However, storage_type
can only be modified to cloud_auto
.
The TDE(Transparent Data Encryption) status. Note: tde_status
cannot be set to disabled
after it is enabled, see Transparent Data Encryption for more details.