From ea714b17f7b54208aa5df57840d3eeb603b60788 Mon Sep 17 00:00:00 2001 From: xuyaming0800 Date: Tue, 21 Mar 2023 20:43:41 +0800 Subject: [PATCH 1/2] bugfix: fix mongodb instance import --- example/mongoDBInstance/main.tf | 22 ++++++++++------- example/mongodb/import/main.tf | 15 ------------ .../service_volcengine_mongodb_instance.go | 4 ++-- website/docs/r/mongodb_instance.html.markdown | 24 ++++++++++++------- 4 files changed, 31 insertions(+), 34 deletions(-) delete mode 100644 example/mongodb/import/main.tf diff --git a/example/mongoDBInstance/main.tf b/example/mongoDBInstance/main.tf index ca1af9d9..09bcc4cc 100644 --- a/example/mongoDBInstance/main.tf +++ b/example/mongoDBInstance/main.tf @@ -1,15 +1,21 @@ resource "volcengine_mongodb_instance" "foo"{ - zone_id="cn-xxx" - instance_type="ShardedCluster" - node_spec="mongo.xxx" - mongos_node_spec="mongo.mongos.xxx" - shard_number=3 - storage_space_gb=100 - subnet_id="subnet-2d6pxxu" - instance_name="tf-test" + zone_id="cn-beijing-a" + instance_type="ReplicaSet" + node_spec="mongo.2c4g" +# mongos_node_spec="mongo.2c4g" +# shard_number=3 + storage_space_gb=20 + subnet_id="subnet-rrx4ns6abw1sv0x57wq6h47" + instance_name="mongo-replica-be9995d32e4a" charge_type="PostPaid" + super_account_password = "******" # period_unit="Month" # period=1 # auto_renew=false # ssl_action="Close" +# lifecycle { +# ignore_changes = [ +# super_account_password, +# ] +# } } \ No newline at end of file diff --git a/example/mongodb/import/main.tf b/example/mongodb/import/main.tf deleted file mode 100644 index 3578269f..00000000 --- a/example/mongodb/import/main.tf +++ /dev/null @@ -1,15 +0,0 @@ -resource "volcengine_mongodb_instance" "foo"{ - # region_id="cn-xxx" - # zone_ids=["cn-xxx"] - # instance_name="test-22" - # sharded_cluster=0 - # password="1qaz!QAZ" - # node_number=2 - # shard_capacity=1024 - # engine_version="5.0" - # vpc_id="vpc-274d24a6ece807fap8***" - # subnet_id="subnet-274o6znje5iww7fa***" - # charge_type="PrePaid" - # purchase_months=1 - # auto_renew=false -} \ No newline at end of file diff --git a/volcengine/mongodb/instance/service_volcengine_mongodb_instance.go b/volcengine/mongodb/instance/service_volcengine_mongodb_instance.go index 78972293..b73e502a 100644 --- a/volcengine/mongodb/instance/service_volcengine_mongodb_instance.go +++ b/volcengine/mongodb/instance/service_volcengine_mongodb_instance.go @@ -180,11 +180,11 @@ func (s *VolcengineMongoDBInstanceService) ReadResource(resourceData *schema.Res nodes := temp.([]interface{}) data["NodeNumber"] = len(nodes) data["NodeSpec"] = nodes[0].(map[string]interface{})["NodeSpec"] + data["StorageSpaceGb"] = nodes[0].(map[string]interface{})["TotalStorageGB"] } else { data["NodeNumber"] = 0 } - } - if data["InstanceType"].(string) == "ShardedCluster" { + } else if data["InstanceType"].(string) == "ShardedCluster" { if temp, ok := data["Mongos"]; ok && temp != nil { mongos := temp.([]interface{}) data["MongosNodeNumber"] = len(mongos) diff --git a/website/docs/r/mongodb_instance.html.markdown b/website/docs/r/mongodb_instance.html.markdown index 233385bb..e9de921e 100644 --- a/website/docs/r/mongodb_instance.html.markdown +++ b/website/docs/r/mongodb_instance.html.markdown @@ -11,19 +11,25 @@ Provides a resource to manage mongodb instance ## Example Usage ```hcl resource "volcengine_mongodb_instance" "foo" { - zone_id = "cn-xxx" - instance_type = "ShardedCluster" - node_spec = "mongo.xxx" - mongos_node_spec = "mongo.mongos.xxx" - shard_number = 3 - storage_space_gb = 100 - subnet_id = "subnet-2d6pxxu" - instance_name = "tf-test" - charge_type = "PostPaid" + zone_id = "cn-beijing-a" + instance_type = "ReplicaSet" + node_spec = "mongo.2c4g" + # mongos_node_spec="mongo.2c4g" + # shard_number=3 + storage_space_gb = 20 + subnet_id = "subnet-rrx4ns6abw1sv0x57wq6h47" + instance_name = "mongo-replica-be9995d32e4a" + charge_type = "PostPaid" + super_account_password = "******" # period_unit="Month" # period=1 # auto_renew=false # ssl_action="Close" + # lifecycle { + # ignore_changes = [ + # super_account_password, + # ] + # } } ``` ## Argument Reference From 91cfa5c772ec840903be5b0085199a1ac46ed90a Mon Sep 17 00:00:00 2001 From: xuyaming0800 Date: Tue, 21 Mar 2023 20:44:00 +0800 Subject: [PATCH 2/2] bugfix: fix mongodb instance import --- common/common_volcengine_version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 231832ee..1792b031 100644 --- a/common/common_volcengine_version.go +++ b/common/common_volcengine_version.go @@ -2,5 +2,5 @@ package common const ( TerraformProviderName = "terraform-provider-volcengine" - TerraformProviderVersion = "0.0.61" + TerraformProviderVersion = "0.0.62" )