Provides a MongoDB Sharding Network Private Address resource.
For information about MongoDB Sharding Network Private Address and how to use it, see What is Sharding Network Private Address.
Basic Usage
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" {
zone_id = local.zone_id
vswitch_id = alicloud_vswitch.default.id
engine_version = "4.2"
name = var.name
shard_list {
node_class = "dds.shard.mid"
node_storage = "10"
}
shard_list {
node_class = "dds.shard.standard"
node_storage = "20"
readonly_replicas = "1"
}
mongo_list {
node_class = "dds.mongos.mid"
}
mongo_list {
node_class = "dds.mongos.mid"
}
}
resource "alicloud_mongodb_sharding_network_private_address" "default" {
db_instance_id = alicloud_mongodb_sharding_instance.default.id
node_id = alicloud_mongodb_sharding_instance.default.shard_list.0.node_id
zone_id = alicloud_mongodb_sharding_instance.default.zone_id
account_name = "example"
account_password = "Example_123"
}
The following arguments are supported:
account_name
- (Optional) The name of the account.
account_password
- (Optional, Sensitive) Account password.
!#$%^&*()_+-=
.db_instance_id
- (Required) The db instance id.zone_id
- (Required) The zone ID of the instance.node_id
- (Required) The ID of the Shard node or the ConfigServer node.The following attributes are exported:
id
- The resource ID of Sharding Network Private Address. The value formats as <db_instance_id>:<node_id>
.network_address
- An array that consists of the endpoints of ApsaraDB for MongoDB instances.
network_type
- The network type.network_address
- The endpoint of the instance.node_type
- The type of the node.port
- The port number.role
- The role of the node.vpc_id
- The ID of the VPC.expired_time
- The remaining duration of the classic network address. Unit: seconds
.ip_address
- The IP address of the instance.vswitch_id
- The vSwitch ID of the VPC.node_id
- The ID of the mongos
, shard
, or Configserver
node in the sharded cluster instance.MongoDB Sharding Network Private Address can be imported using the id, e.g.
$ terraform import alicloud_mongodb_sharding_network_private_address.example <db_instance_id>:<node_id>