» alicloud_mongodb_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

» Example Usage

» Create a Mongodb instance

data "alicloud_zones" "default" {
  available_resource_creation = "MongoDB"

resource "alicloud_vpc" "default" {
  name       = "vpc-123456"
  cidr_block = ""

resource "alicloud_vswitch" "default" {
  vpc_id            = "${alicloud_vpc.default.id}"
  cidr_block        = ""
  availability_zone = "${data.alicloud_zones.default.zones.0.id}"
  name              = "vpc-123456"

resource "alicloud_mongodb_instance" "example" {
  engine_version      = "3.4"
  db_instance_class   = "dds.mongo.mid"
  db_instance_storage = 10
  vswitch_id          = "${alicloud_vswitch.default.id}"
  security_ip_list    = ["", ""]

» Module Support

You can use to the existing mongodb module to create a MongoDB instance resource one-click.

» Argument Reference

The following arguments are supported:

  • engine_version - (Required, ForceNew) Database version. Value options can refer to the latest docs CreateDBInstance EngineVersion.
  • db_instance_class - (Required) Instance specification. see Instance specifications.
  • db_instance_storage - (Required) User-defined DB instance storage space.Unit: GB. Value range:
    • Custom storage space; value range: [10,2000]
    • 10-GB increments.
  • replication_factor - (Optional) Number of replica set nodes. Valid values: [3, 5, 7]
  • storage_engine (Optional, ForceNew) Storage engine: WiredTiger or RocksDB. System Default value: WiredTiger.
  • name - (Optional) The name of DB instance. It a string of 2 to 256 characters.
  • instance_charge_type - (Optional) Valid values are PrePaid, PostPaid, System default to PostPaid. It can be modified from PostPaid to PrePaid after version 1.63.0.
  • period - (Optional) The duration that you will buy DB instance (in month). It is valid when instance_charge_type is PrePaid. Valid values: [1~9], 12, 24, 36. System default to 1.
  • zone_id - (Optional, ForceNew) The Zone to launch the DB instance. it supports multiple zone. If it is a multi-zone and vswitch_id is specified, the vswitch must in one of them. The multiple zone ID can be retrieved by setting multi to "true" in the data source alicloud_zones.
  • vswitch_id - (Optional, ForceNew) The virtual switch ID to launch DB instances in one VPC.
  • 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 in 1.57.1+) An KMS encrypts password used to a instance. If the account_password is filled in, this field will be ignored.
  • kms_encryption_context - (Optional, MapString, Available in 1.57.1+) 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.
  • security_ip_list - (Optional) 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, (IP), and (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]).
  • security_group_id - (Optional, Available in 1.73.0+) The Security Group ID of ECS.
  • backup_period - (Optional, Available in 1.42.0+) 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]
  • backup_time - (Optional, Available in 1.42.0+) 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".
  • tde_status - (Optional, ForceNew, Available in 1.73.0+) The TDE(Transparent Data Encryption) status.
  • maintain_start_time - (Optional, Available in v1.56.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 in v1.56.0+) The end time of the operation and maintenance time period of the instance, in the format of HH:mmZ (UTC time).
  • ssl_action - (Optional, Available in v1.78.0+) Actions performed on SSL functions, Valid values: Open: turn on SSL encryption; Close: turn off SSL encryption; Update: update SSL certificate.
  • tags - (Optional, Available in v1.66.0+) A mapping of tags to assign to the resource.

» Attributes Reference

The following attributes are exported:

  • id - The ID of the MongoDB.
  • retention_period - Instance log backup retention days. Available in 1.42.0+.
  • replica_set_name - The name of the mongo replica set
  • ssl_status - Status of the SSL feature. Open: SSL is turned on; Closed: SSL is turned off.

» Timeouts

The timeouts block allows you to specify timeouts for certain actions:

  • create - (Defaults to 30 mins) Used when creating the MongoDB instance (until it reaches the initial Running status).
  • update - (Defaults to 30 mins) Used when updating the MongoDB instance (until it reaches the initial Running status).
  • delete - (Defaults to 30 mins) Used when terminating the MongoDB instance.

» Import

MongoDB can be imported using the id, e.g.

$ terraform import alicloud_mongodb_instance.example dds-bp1291daeda44194