From 507b15945e3d24876f5556d481f9f08fc22bbc70 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Wed, 22 Feb 2023 19:37:03 +0800 Subject: [PATCH 1/2] bugfix: ecs postpaid-> prepaid --- example/ecsInstance/main.tf | 16 +++++++++------- .../common_volcengine_ecs_instance.go | 2 +- .../service_volcengine_ecs_instance.go | 6 ++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/example/ecsInstance/main.tf b/example/ecsInstance/main.tf index 8ec51867..03dc4b0c 100644 --- a/example/ecsInstance/main.tf +++ b/example/ecsInstance/main.tf @@ -6,7 +6,7 @@ resource "volcengine_vpc" "foo" { resource "volcengine_subnet" "foo1" { subnet_name = "subnet-test-1" cidr_block = "172.16.1.0/24" - zone_id = "cn-beijing-a" + zone_id = "cn-shanghai-a" vpc_id = volcengine_vpc.foo.id } @@ -16,18 +16,20 @@ resource "volcengine_security_group" "foo1" { } resource "volcengine_ecs_instance" "default" { - image_id = "image-aagd56zrw2jtdro3bnrl" - instance_type = "ecs.g1.large" - instance_name = "xym-tf-test-2" + image_id = "image-ybm3r19o545id8bxuanl" + instance_type = "ecs.g2i.large" + instance_name = "xym-tf-test-3" description = "xym-tf-test-desc-1" password = "93f0cb0614Aab12" - instance_charge_type = "PostPaid" - system_volume_type = "PTSSD" + instance_charge_type = "PrePaid" + period = 1 +# auto_renew =false + system_volume_type = "ESSD_PL0" system_volume_size = 60 subnet_id = volcengine_subnet.foo1.id security_group_ids = [volcengine_security_group.foo1.id] data_volumes { - volume_type = "PTSSD" + volume_type = "ESSD_PL0" size = 100 delete_with_instance = true } diff --git a/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go index 9ba90736..62201be3 100644 --- a/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/common_volcengine_ecs_instance.go @@ -34,7 +34,7 @@ func EcsInstanceImportDiffSuppress(k, old, new string, d *schema.ResourceData) b return true } - if d.Get("instance_charge_type").(string) == "PostPaid" && (k == "period" || k == "period_unit" || k == "auto_renew" || k == "auto_renew_period") { + if d.Get("instance_charge_type").(string) == "PostPaid" && (k == "period" || k == "period_unit") { return true } diff --git a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go index 28b0732b..f6d0b279 100644 --- a/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/service_volcengine_ecs_instance.go @@ -432,6 +432,12 @@ func (s *VolcengineEcsService) CreateResource(resourceData *schema.ResourceData, (*call.SdkParam)["Volumes.1.DeleteWithInstance"] = true (*call.SdkParam)["Count"] = 1 + if (*call.SdkParam)["InstanceChargeType"] != "PrePaid" { + delete(*call.SdkParam, "AutoRenew") + delete(*call.SdkParam, "AutoRenewPeriod") + delete(*call.SdkParam, "Period") + } + if _, ok := (*call.SdkParam)["ZoneId"]; !ok || (*call.SdkParam)["ZoneId"] == "" { var ( vnet map[string]interface{} From 166e15a705ae3c75fd72473ded42c196f17f2865 Mon Sep 17 00:00:00 2001 From: xuyaming Date: Wed, 22 Feb 2023 19:37:50 +0800 Subject: [PATCH 2/2] bugfix: ecs postpaid-> prepaid --- common/common_volcengine_version.go | 2 +- example/ecsInstance/main.tf | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 40dcfb0b..e071eb7c 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.56" + TerraformProviderVersion = "0.0.57" ) diff --git a/example/ecsInstance/main.tf b/example/ecsInstance/main.tf index 03dc4b0c..8ec51867 100644 --- a/example/ecsInstance/main.tf +++ b/example/ecsInstance/main.tf @@ -6,7 +6,7 @@ resource "volcengine_vpc" "foo" { resource "volcengine_subnet" "foo1" { subnet_name = "subnet-test-1" cidr_block = "172.16.1.0/24" - zone_id = "cn-shanghai-a" + zone_id = "cn-beijing-a" vpc_id = volcengine_vpc.foo.id } @@ -16,20 +16,18 @@ resource "volcengine_security_group" "foo1" { } resource "volcengine_ecs_instance" "default" { - image_id = "image-ybm3r19o545id8bxuanl" - instance_type = "ecs.g2i.large" - instance_name = "xym-tf-test-3" + image_id = "image-aagd56zrw2jtdro3bnrl" + instance_type = "ecs.g1.large" + instance_name = "xym-tf-test-2" description = "xym-tf-test-desc-1" password = "93f0cb0614Aab12" - instance_charge_type = "PrePaid" - period = 1 -# auto_renew =false - system_volume_type = "ESSD_PL0" + instance_charge_type = "PostPaid" + system_volume_type = "PTSSD" system_volume_size = 60 subnet_id = volcengine_subnet.foo1.id security_group_ids = [volcengine_security_group.foo1.id] data_volumes { - volume_type = "ESSD_PL0" + volume_type = "PTSSD" size = 100 delete_with_instance = true }