alicloud_mongodb_sharding_instance
Provides a MongoDB Sharding 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.40.0.
-> NOTE:  The following regions don't support create Classic network MongoDB Sharding Instance.
[cn-zhangjiakou,cn-huhehaote,ap-southeast-3,ap-southeast-5,me-east-1,ap-northeast-1,eu-west-1]
-> NOTE: Create MongoDB Sharding instance or change instance type and storage would cost 10~20 minutes. Please make full preparation.
Example Usage
Create a Mongodb Sharding instance
variable "name" {
  default = "terraform-example"
}
data "alicloud_mongodb_zones" "default" {
}
locals {
  index   = length(data.alicloud_mongodb_zones.default.zones) - 1
  zone_id = data.alicloud_mongodb_zones.default.zones[local.index].id
}
resource "alicloud_vpc" "default" {
  vpc_name   = var.name
  cidr_block = "172.17.3.0/24"
}
resource "alicloud_vswitch" "default" {
  vswitch_name = var.name
  cidr_block   = "172.17.3.0/24"
  vpc_id       = alicloud_vpc.default.id
  zone_id      = local.zone_id
}
resource "alicloud_mongodb_sharding_instance" "default" {
  engine_version = "4.2"
  vswitch_id     = alicloud_vswitch.default.id
  zone_id        = local.zone_id
  name           = var.name
  mongo_list {
    node_class = "dds.mongos.mid"
  }
  mongo_list {
    node_class = "dds.mongos.mid"
  }
  shard_list {
    node_class   = "dds.shard.mid"
    node_storage = "10"
  }
  shard_list {
    node_class        = "dds.shard.standard"
    node_storage      = "20"
    readonly_replicas = "1"
  }
}
Module Support
You can use to the existing mongodb-sharding module to create a MongoDB Sharding Instance resource one-click.
Argument Reference
The following arguments are supported:
engine_version- (Required) Database version. Value options can refer to the latest docs CreateDBInstanceEngineVersion. NOTE: From version 1.225.1,engine_versioncan be modified.storage_engine(Optional, ForceNew) The storage engine of the instance. Default value:WiredTiger. Valid values:WiredTiger,RocksDB.storage_type- (Optional, Available since v1.225.1) 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_typecan be modified. However,storage_typecan only be modified tocloud_auto.provisioned_iops- (Optional, Int, Available since v1.229.0) The provisioned IOPS. Valid values:0to50000.protocol_type- (Optional, ForceNew, Available since v1.161.0) The type of the access protocol. Valid values:mongodbordynamodb.vpc_id- (Optional, ForceNew, Available since v1.161.0) The ID of the VPC. -> NOTE:vpc_idis valid only whennetwork_typeis set toVPC.vswitch_id- (Optional, ForceNew) The virtual switch ID to launch DB instances in one VPC.zone_id- (Optional, ForceNew) The Zone to launch the DB instance. MongoDB Sharding Instance does not support multiple-zone. If it is a multi-zone andvswitch_idis specified, the vswitch must in one of them.secondary_zone_id- (Optional, Available since v1.253.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 aszone_idandhidden_zone_idparameter values.hidden_zone_id- (Optional, Available since v1.253.0) Configure the zone where the hidden node is located to deploy multiple zones. NOTE: This parameter value cannot be the same aszone_idandsecondary_zone_idparameter values.security_group_id- (Optional, Available since v1.76.0) The Security Group ID of ECS.network_type- (Optional, ForceNew, Available since v1.161.0) The network type of the instance. Valid values:ClassicorVPC.name- (Optional) The name of DB instance. It must be 2 to 256 characters in length.instance_charge_type- (Optional) The billing method of the instance. Default value:PostPaid. Valid values:PrePaid,PostPaid. NOTE: It can be modified fromPostPaidtoPrePaidafter version v1.141.0.period- (Optional, Int) The duration that you will buy DB instance (in month). It is valid wheninstance_charge_typeisPrePaid. Default value:1. Valid values: [1~9], 12, 24, 36.security_ip_list- (Optional, List) 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]). System default to["127.0.0.1"].account_password- (Optional, Sensitive) Password of the root account. It is a string of 6 to 32 characters and is composed of letters, numbers, and underlines.kms_encrypted_password- (Optional, Available since v1.57.1) An KMS encrypts password used to a instance. If theaccount_passwordis filled in, this field will be ignored.kms_encryption_context- (Optional, MapString, Available since v1.57.1) An KMS encryption context used to decryptkms_encrypted_passwordbefore creating or updating instance withkms_encrypted_password. See Encryption Context. It is valid whenkms_encrypted_passwordis set.encrypted- (Optional, ForceNew, Bool, Available since v1.260.0) Whether to enable cloud disk encryption. Default value:false. Valid values:true,false.cloud_disk_encryption_key- (Optional, ForceNew, Available since v1.260.0) The ID of the encryption key.resource_group_id- (Optional, Available since v1.161.0) The ID of the Resource Group.auto_renew- (Optional, Bool, Available since v1.141.0) Auto renew for prepaid. Default value:false. Valid values:true,false.backup_time- (Optional, Available since v1.42.0) Sharding Instance backup time. It is required whenbackup_periodwas 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".backup_period- (Optional, List, Available since v1.42.0) MongoDB Instance backup period. It is required whenbackup_timewas existed. Valid values: [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]. Default to [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]backup_retention_period- (Optional, Int, Available since v1.259.0) The retention period of full backups.backup_retention_policy_on_cluster_deletion- (Optional, Int, Available since v1.235.0) The backup retention policy configured for the instance. Valid values:0: All backup sets are immediately deleted when the instance is released.1: Automatic backup is performed when the instance is released and the backup set is retained for a long period of time.2: Automatic backup is performed when the instance is released and all backup sets are retained for a long period of time.
enable_backup_log- (Optional, Int, Available since v1.259.0) Specifies whether to enable the log backup feature. Valid values:1: The log backup feature is enabled.
log_backup_retention_period- (Optional, Int, Available since v1.259.0) The number of days for which log backups are retained. Valid values:7to730. NOTE:log_backup_retention_periodis valid only whenenable_backup_logis set to1.snapshot_backup_type- (Optional, Available since v1.253.0) The snapshot backup type. Default value:Standard. Valid values:Standard: Standard backup.Flash: Single-digit second backup.
backup_interval- (Optional, Available since v1.253.0) The frequency at which high-frequency backups are created. Valid values:-1,15,30,60,120,180,240,360,480,720.ssl_action- (Optional, Available since v1.259.0) Actions performed on SSL functions. Valid values:Open: turn on SSL encryption.Close: turn off SSL encryption.Update: update SSL certificate.
maintain_start_time- (Optional, Available since v1.259.0) The start time of the operation and maintenance time period of the instance, in the format of HH:mmZ (UTC time).maintain_end_time- (Optional, Available since v1.259.0) The end time of the operation and maintenance time period of the instance, in the format of HH:mmZ (UTC time).tde_status- (Optional, Available since v1.76.0) The TDE(Transparent Data Encryption) status. It can be updated from version 1.160.0.encryptor_name- (Optional, Available since v1.260.0) The encryption method. NOTE:encryptor_nameis valid only whentde_statusis set toenabled.encryption_key- (Optional, Available since v1.260.0) The ID of the custom key.role_arn- (Optional, Available since v1.260.0) The Alibaba Cloud Resource Name (ARN) of the specified Resource Access Management (RAM) role.db_instance_release_protection- (Optional, Bool, Available since v1.253.0) Indicates whether release protection is enabled for the instance. Valid values:true,false.global_security_group_list- (Optional, List, Available since v1.258.0) The list of Global Security Group Ids.mongo_list- (Required, Set) The Mongo nodes of the instance. The mongo-node count can be purchased is in range of [2, 32]. Seemongo_listbelow.shard_list- (Required, Set) The Shard nodes of the instance. The shard-node count can be purchased is in range of [2, 32]. Seeshard_listbelow.config_server_list- (Optional, ForceNew, Set, Available since v1.223.0) The ConfigServer nodes of the instance. Seeconfig_server_listbelow.tags- (Optional) A mapping of tags to assign to the resource.order_type- (Optional, Available since v1.134.0) The type of configuration changes performed. Default value:DOWNGRADE. Valid values:UPGRADE: The specifications are upgraded.DOWNGRADE: The specifications are downgraded. NOTE:order_typeis only applicable to instances wheninstance_charge_typeisPrePaid.
mongo_list
The mongo_list supports the following:
node_class-(Required) The instance type of the mongo node. see Instance specifications.
shard_list
The shard_list supports the following:
node_class- (Required) The instance type of the shard node. see Instance specifications.node_storage- (Required, Int) The storage space of the shard node.- Custom storage space; value range: [10, 1,000]
 - 10-GB increments. Unit: GB.
 
readonly_replicas- (Optional, Int, Available since v1.126.0) The number of read-only nodes in shard node Default value:0. Valid values:0to5.
config_server_list
The config_server_list supports the following:
node_class- (Optional, ForceNew) The instance type of the ConfigServer node. Valid values:mdb.shard.2x.xlarge.d,dds.cs.mid.node_storage- (Optional, ForceNew, Int) The storage space of the ConfigServer node.
Attributes Reference
The following attributes are exported:
id- The resource ID in terraform of Sharding Instance.retention_period- (Available since v1.42.0) Instance data backup retention days.ssl_status- (Available since v1.259.0) The status of the SSL feature.mongo_list- The mongo nodes of the instance.node_id- The ID of the mongo node.connect_string- The endpoint of the mongo node.port- The port number that is used to connect to the mongo node.
shard_list- The information of the shard node.node_id- The ID of the shard node.
config_server_list- The information of the ConfigServer nodes.node_id- The ID of the Config Server node.connect_string- The connection address of the Config Server node.port- The connection port of the Config Server node.max_connections- The max connections of the Config Server node.max_iops- The maximum IOPS of the Config Server node.node_description- The description of the Config Server node.
Timeouts
-> NOTE: Available since v1.126.0.
The timeouts block allows you to specify timeouts for certain actions:
create- (Defaults to 30 mins) Used when creating the Sharding Instance (until it reaches the initialRunningstatus).update- (Defaults to 120 mins) Used when updating the Sharding Instance (until it reaches the initialRunningstatus).delete- (Defaults to 30 mins) Used when deleting the Sharding Instance.
Import
MongoDB Sharding Instance can be imported using the id, e.g.
$ terraform import alicloud_mongodb_sharding_instance.example dds-bp1291daeda44195