Skip to content

Commit

Permalink
Merge pull request #144 from volcengine/feat/mongo
Browse files Browse the repository at this point in the history
Feat/mongo
  • Loading branch information
zpp12354321 authored Nov 21, 2023
2 parents 4b6f9b4 + 548c3fe commit 95411dd
Show file tree
Hide file tree
Showing 68 changed files with 2,291 additions and 169 deletions.
2 changes: 1 addition & 1 deletion common/common_volcengine_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package common

const (
TerraformProviderName = "terraform-provider-volcengine"
TerraformProviderVersion = "0.0.124"
TerraformProviderVersion = "0.0.125"
)
4 changes: 2 additions & 2 deletions docgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ var resourceKeys = map[string]string{
"tos": "TOS(BETA)",
"cr": "CR",
"veenedge": "VEENEDGE",
"cen": "CEN(BETA)",
"vpn": "VPN(BETA)",
"cen": "CEN",
"vpn": "VPN",
"autoscaling": "AUTOSCALING",
"mongodb": "MONGODB",
"bioos": "BIOOS",
Expand Down
13 changes: 10 additions & 3 deletions example/dataMongoDBAllowLists/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
data "volcengine_mongodb_allow_lists" "default"{
region_id = "cn-xxx"
instance_id="mongo-replica-xxx"
resource "volcengine_mongodb_allow_list" "foo" {
allow_list_name="acc-test"
allow_list_desc="acc-test"
allow_list_type="IPv4"
allow_list="10.1.1.3,10.2.3.0/24,10.1.1.1"
}

data "volcengine_mongodb_allow_lists" "foo"{
allow_list_ids = [volcengine_mongodb_allow_list.foo.id]
region_id = "cn-beijing"
}
48 changes: 45 additions & 3 deletions example/dataMongoDBInstanceParameters/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_mongodb_instance" "foo"{
db_engine_version = "MongoDB_4_0"
instance_type="ReplicaSet"
super_account_password="@acc-test-123"
node_spec="mongo.2c4g"
mongos_node_spec="mongo.mongos.2c4g"
instance_name="acc-test-mongo-replica"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 32
shard_number=3
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_instance_parameter" "foo" {
instance_id = volcengine_mongodb_instance.foo.id
parameter_name = "cursorTimeoutMillis"
parameter_role = "Node"
parameter_value = "600111"
}

data "volcengine_mongodb_instance_parameters" "foo"{
instance_id = "mongo-replica-f16e9298b121" // 必填
parameter_role = "Node" // 选填
parameter_names = "connPoolMaxConnsPerHost" // 选填
instance_id = volcengine_mongodb_instance.foo.id
parameter_names = "cursorTimeoutMillis"
parameter_role = "Node"
}
41 changes: 40 additions & 1 deletion example/dataMongoDBSSLStates/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_mongodb_instance" "foo"{
db_engine_version = "MongoDB_4_0"
instance_type="ReplicaSet"
super_account_password="@acc-test-123"
node_spec="mongo.2c4g"
mongos_node_spec="mongo.mongos.2c4g"
instance_name="acc-test-mongo-replica"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 2
shard_number=3
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_ssl_state" "foo" {
instance_id = volcengine_mongodb_instance.foo.id
}

data "volcengine_mongodb_ssl_states" "foo"{
instance_id = "mongo-replica-f16e9298b121" // 必填
instance_id = volcengine_mongodb_instance.foo.id
}
61 changes: 60 additions & 1 deletion example/dataMongodbEndpoints/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_mongodb_instance" "foo"{
db_engine_version = "MongoDB_4_0"
instance_type = "ShardedCluster"
super_account_password = "@acc-test-123"
node_spec = "mongo.shard.1c2g"
mongos_node_spec = "mongo.mongos.1c2g"
instance_name = "acc-test-mongo-shard"
charge_type = "PostPaid"
project_name = "default"
mongos_node_number = 2
shard_number = 2
storage_space_gb = 20
subnet_id = volcengine_subnet.foo.id
zone_id = data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_eip_address" "foo" {
billing_type = "PostPaidByBandwidth"
bandwidth = 1
isp = "ChinaUnicom"
name = "acc-eip-${count.index}"
description = "acc-test"
project_name = "default"
count = 2
}

resource "volcengine_mongodb_endpoint" "foo_public"{
instance_id = volcengine_mongodb_instance.foo.id
network_type = "Public"
object_id = volcengine_mongodb_instance.foo.mongos_id
mongos_node_ids = [volcengine_mongodb_instance.foo.mongos[0].mongos_node_id, volcengine_mongodb_instance.foo.mongos[1].mongos_node_id]
eip_ids = volcengine_eip_address.foo[*].id
}

resource "volcengine_mongodb_endpoint" "foo_private"{
instance_id = volcengine_mongodb_instance.foo.id
network_type = "Private"
object_id = volcengine_mongodb_instance.foo.config_servers_id
}

data "volcengine_mongodb_endpoints" "foo"{
instance_id="mongo-shard-xxx"
instance_id = volcengine_mongodb_instance.foo.id
}
6 changes: 3 additions & 3 deletions example/mongoDBAllowList/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "volcengine_mongodb_allow_list" "foo"{
allow_list_name="tf-test-hh"
allow_list_desc="test1"
resource "volcengine_mongodb_allow_list" "foo" {
allow_list_name="acc-test"
allow_list_desc="acc-test"
allow_list_type="IPv4"
allow_list="10.1.1.3,10.2.3.0/24,10.1.1.1"
}
48 changes: 45 additions & 3 deletions example/mongoDBAllowListAssociate/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
resource "volcengine_mongodb_allow_list_associate" "foo"{
instance_id="mongo-replica-f16e9298b121"
allow_list_id="acl-9e307ce4efe843fb9ffd8cb6a6cb225f"
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_mongodb_instance" "foo"{
db_engine_version = "MongoDB_4_0"
instance_type="ReplicaSet"
super_account_password="@acc-test-123"
node_spec="mongo.2c4g"
mongos_node_spec="mongo.mongos.2c4g"
instance_name="acc-test-mongo-replica"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 32
shard_number=3
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_allow_list" "foo" {
allow_list_name="acc-test"
allow_list_desc="acc-test"
allow_list_type="IPv4"
allow_list="10.1.1.3,10.2.3.0/24,10.1.1.1"
}

resource "volcengine_mongodb_allow_list_associate" "foo" {
allow_list_id = volcengine_mongodb_allow_list.foo.id
instance_id = volcengine_mongodb_instance.foo.id
}
83 changes: 76 additions & 7 deletions example/mongoDBEndpoint/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,76 @@
resource "volcengine_mongodb_endpoint" "foo"{
instance_id="mongo-replica-38cf5badeb9e"
# object_id="mongo-shard-8ad9f45e173e"
network_type="Public"
eip_ids= ["eip-3rfe12dvmz8qo5zsk2h91q05p"]
# mongos_node_ids=["mongo-shard-8ad9f45e173e-0"]
}
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_eip_address" "foo" {
billing_type = "PostPaidByBandwidth"
bandwidth = 1
isp = "ChinaUnicom"
name = "acc-eip-${count.index}"
description = "acc-test"
project_name = "default"
count = 2
}

resource "volcengine_mongodb_instance" "replica-set"{
db_engine_version = "MongoDB_4_0"
instance_type="ReplicaSet"
super_account_password="@acc-test-123"
node_spec="mongo.2c4g"
mongos_node_spec="mongo.mongos.2c4g"
instance_name="acc-test-mongo-replica"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 2
shard_number=3
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_endpoint" "replica-set-public-endpoint"{
instance_id = volcengine_mongodb_instance.replica-set.id
network_type = "Public"
eip_ids = volcengine_eip_address.foo[*].id
}

resource "volcengine_mongodb_instance" "sharded-cluster"{
db_engine_version = "MongoDB_4_0"
instance_type="ShardedCluster"
super_account_password="@acc-test-123"
node_spec="mongo.shard.1c2g"
mongos_node_spec="mongo.mongos.1c2g"
instance_name="acc-test-mongo-shard"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 2
shard_number=2
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_endpoint" "sharded-cluster-private-endpoint"{
instance_id = volcengine_mongodb_instance.sharded-cluster.id
network_type = "Private"
object_id = volcengine_mongodb_instance.sharded-cluster.shards[0].shard_id
}
49 changes: 39 additions & 10 deletions example/mongoDBInstanceParameter/main.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
/*
该资源无法创建,需先import资源
$ terraform import volcengine_mongodb_instance_parameter.default param:mongo-replica-f16e9298b121:connPoolMaxConnsPerHost
请注意instance_id和parameter_name需与上述import的ID对应
*/
resource "volcengine_mongodb_instance_parameter" "default"{
instance_id = "mongo-replica-f16e9298b121" // 必填 import之后不允许修改
parameter_name = "connPoolMaxConnsPerHost" // 必填 import之后不允许修改
parameter_role = "Node" // 必填
parameter_value = "600" // 必填
data "volcengine_zones" "foo"{
}

resource "volcengine_vpc" "foo" {
vpc_name = "acc-test-vpc"
cidr_block = "172.16.0.0/16"
}

resource "volcengine_subnet" "foo" {
subnet_name = "acc-test-subnet"
cidr_block = "172.16.0.0/24"
zone_id = data.volcengine_zones.foo.zones[0].id
vpc_id = volcengine_vpc.foo.id
}

resource "volcengine_mongodb_instance" "foo"{
db_engine_version = "MongoDB_4_0"
instance_type="ReplicaSet"
super_account_password="@acc-test-123"
node_spec="mongo.2c4g"
mongos_node_spec="mongo.mongos.2c4g"
instance_name="acc-test-mongo-replica"
charge_type="PostPaid"
project_name = "default"
mongos_node_number = 32
shard_number=3
storage_space_gb=20
subnet_id=volcengine_subnet.foo.id
zone_id= data.volcengine_zones.foo.zones[0].id
tags {
key = "k1"
value = "v1"
}
}

resource "volcengine_mongodb_instance_parameter" "foo" {
instance_id = volcengine_mongodb_instance.foo.id
parameter_name = "cursorTimeoutMillis"
parameter_role = "Node"
parameter_value = "600111"
}
Loading

0 comments on commit 95411dd

Please sign in to comment.