From fd7183aa84a1b7658bc104b0c9e1ecb4f25ee62a Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Tue, 4 Jul 2023 12:09:28 +0800 Subject: [PATCH 01/10] feat: update iaas doc --- example/ecsInstance/main.tf | 24 ++++++++++++--- example/networkAcl/main.tf | 25 +++++++++++----- .../resource_volcengine_ecs_instance.go | 1 + ...ource_volcengine_ecs_key_pair_associate.go | 5 ++++ .../resource_volcengine_network_acl.go | 29 ++++++++++++------- 5 files changed, 63 insertions(+), 21 deletions(-) diff --git a/example/ecsInstance/main.tf b/example/ecsInstance/main.tf index cf598e92..23142743 100644 --- a/example/ecsInstance/main.tf +++ b/example/ecsInstance/main.tf @@ -18,8 +18,8 @@ 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" - description = "xym-tf-test-desc-1" + instance_name = "tf-ecs-test" + description = "tf-ecs-test-desc" password = "93f0cb0614Aab12" instance_charge_type = "PostPaid" system_volume_type = "PTSSD" @@ -31,10 +31,26 @@ resource "volcengine_ecs_instance" "default" { size = 100 delete_with_instance = true } - deployment_set_id = "" - ipv6_address_count = 1 + data_volumes { + volume_type = "PTSSD" + size = 50 + delete_with_instance = true + } +# deployment_set_id = "" +# ipv6_address_count = 1 # secondary_network_interfaces { # subnet_id = volcengine_subnet.foo1.id # security_group_ids = [volcengine_security_group.foo1.id] # } + + tags { + key = "tfk1" + value = "tfv1" + } + + tags { + key = "tfk2" + value = "tfv2" + } + } diff --git a/example/networkAcl/main.tf b/example/networkAcl/main.tf index f842b4c1..c3eaf2cf 100644 --- a/example/networkAcl/main.tf +++ b/example/networkAcl/main.tf @@ -1,17 +1,28 @@ resource "volcengine_network_acl" "foo" { - vpc_id = "vpc-12bk4qjc69reo17q7y36shv6z" + vpc_id = "vpc-2d6jskar243k058ozfdae13ne" network_acl_name = "tf-test-acl" + ingress_acl_entries { network_acl_entry_name = "ingress1" - policy = "accept" - protocol = "all" - source_cidr_ip = "192.168.0.0/24" + policy = "accept" + protocol = "all" + source_cidr_ip = "192.168.0.0/24" } + egress_acl_entries { network_acl_entry_name = "egress2" - policy = "accept" - protocol = "all" - destination_cidr_ip = "192.168.0.0/16" + policy = "accept" + protocol = "all" + destination_cidr_ip = "192.168.0.0/16" } + + ingress_acl_entries { + network_acl_entry_name = "ingress3" + policy = "accept" + protocol = "tcp" + port = "80/80" + source_cidr_ip = "192.168.0.0/24" + } + project_name = "default" } diff --git a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index 16a2a28d..784ad15a 100644 --- a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -297,6 +297,7 @@ func ResourceVolcengineEcsInstance() *schema.Resource { "secondary_network_interfaces": { Type: schema.TypeList, Optional: true, + ForceNew: true, MinItems: 1, Description: "The secondary networkInterface detail collection of ECS instance.", Elem: &schema.Resource{ diff --git a/volcengine/ecs/ecs_key_pair_associate/resource_volcengine_ecs_key_pair_associate.go b/volcengine/ecs/ecs_key_pair_associate/resource_volcengine_ecs_key_pair_associate.go index 33bc5870..5b360c43 100644 --- a/volcengine/ecs/ecs_key_pair_associate/resource_volcengine_ecs_key_pair_associate.go +++ b/volcengine/ecs/ecs_key_pair_associate/resource_volcengine_ecs_key_pair_associate.go @@ -13,6 +13,11 @@ import ( Import ECS key pair associate can be imported using the id, e.g. + +After binding the key pair, the instance needs to be restarted for the key pair to take effect. + +After the key pair is bound, the password login method will automatically become invalid. If your instance has been set for password login, after the key pair is bound, you will no longer be able to use the password login method. + ``` $ terraform import volcengine_ecs_key_pair_associate.default kp-ybti5tkpkv2udbfolrft:i-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/volcengine/vpc/network_acl/resource_volcengine_network_acl.go b/volcengine/vpc/network_acl/resource_volcengine_network_acl.go index ad5c7839..3a59bdf0 100644 --- a/volcengine/vpc/network_acl/resource_volcengine_network_acl.go +++ b/volcengine/vpc/network_acl/resource_volcengine_network_acl.go @@ -79,7 +79,7 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Optional: true, //Computed: true, Default: "accept", - Description: "The policy of entry.", + Description: "The policy of entry, default is `accept`. The value can be `accept` or `drop`.", }, "source_cidr_ip": { Type: schema.TypeString, @@ -90,8 +90,9 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Type: schema.TypeString, Optional: true, //Computed: true, - Default: "all", - Description: "The protocol of entry.", + Default: "all", + Description: "The protocol of entry, default is `all`. " + + "The value can be `icmp` or `gre` or `tcp` or `udp` or `all`.", }, "priority": { Type: schema.TypeInt, @@ -102,8 +103,11 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Type: schema.TypeString, Optional: true, //Computed: true, - Default: "-1/-1", - Description: "The port of entry.", + Default: "-1/-1", + Description: "The port of entry. Default is `-1/-1`. When Protocol is `all`, `icmp` or `gre`, " + + "the port range is `-1/-1`, which means no port restriction. " + + "When the Protocol is `tcp` or `udp`, the port range is `1~65535`, and the format is `1/200`, `80/80`, " + + "which means port 1 to port 200, port 80.", }, }, }, @@ -137,7 +141,7 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Optional: true, //Computed: true, Default: "accept", - Description: "The policy of entry.", + Description: "The policy of entry. Default is `accept`. The value can be `accept` or `drop`.", }, "destination_cidr_ip": { Type: schema.TypeString, @@ -148,8 +152,9 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Type: schema.TypeString, Optional: true, //Computed: true, - Default: "all", - Description: "The protocol of entry.", + Default: "all", + Description: "The protocol of entry. " + + "The value can be `icmp` or `gre` or `tcp` or `udp` or `all`. Default is `all`.", }, "priority": { Type: schema.TypeInt, @@ -160,8 +165,12 @@ func ResourceVolcengineNetworkAcl() *schema.Resource { Type: schema.TypeString, Optional: true, //Computed: true, - Default: "-1/-1", - Description: "The port of entry.", + Default: "-1/-1", + Description: "The port of entry. Default is `-1/-1`. " + + "When Protocol is `all`, `icmp` or `gre`, the port range is `-1/-1`, " + + "which means no port restriction." + + "When the Protocol is `tcp` or `udp`, the port range is `1~65535`, and the format is `1/200`, `80/80`," + + "which means port 1 to port 200, port 80.", }, }, }, From a2fc1199fab3c1d245f3bee826b96b194aa6767f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Wed, 5 Jul 2023 05:06:28 +0000 Subject: [PATCH 02/10] feat: opt vpn, as, cen code * bugfix: fix acl entry computed in acl provider * feat: update tf version * Merge branch 'feat/vke_node_pool_fix' into 'master' * feat: opt cen, as and vpn code * feat: merge code and add vpn unsubscribe https://code.byted.org/iaasng/terraform-provider-volcengine/merge_requests/302 --- example/cen/main.tf | 3 +- example/cenBandwidthPackage/main.tf | 1 + example/scalingConfiguration/main.tf | 21 +++-- example/scalingGroup/main.tf | 9 +- example/vpnConnection/main.tf | 4 +- example/vpnGateway/main.tf | 9 +- ...ource_volcengine_scaling_configurations.go | 35 ++++++++ ...source_volcengine_scaling_configuration.go | 60 ++++++++++++-- ...ervice_volcengine_scaling_configuration.go | 47 ++++++++++- .../data_source_volcengine_scaling_groups.go | 7 +- .../resource_volcengine_scaling_group.go | 24 ++++-- .../service_volcengine_scaling_group.go | 58 ++++++------- ..._volcengine_scaling_instance_attachment.go | 1 + .../resource_volcengine_scaling_policy.go | 51 ++++++++---- .../cen/cen/data_source_volcengine_cens.go | 5 ++ volcengine/cen/cen/resource_volcengine_cen.go | 5 ++ volcengine/cen/cen/service_volcengine_cen.go | 69 ++++++++++++++++ ...resource_volcengine_cen_attach_instance.go | 2 +- ...ource_volcengine_cen_bandwidth_packages.go | 5 ++ ...source_volcengine_cen_bandwidth_package.go | 14 +++- ...ervice_volcengine_cen_bandwidth_package.go | 71 +++++++++++++++- .../resource_volcengine_vpn_connection.go | 39 +++++---- .../service_volcengine_vpn_connection.go | 3 + .../common_volcengine_vpn_gateway.go | 5 +- .../resource_volcengine_vpn_gateway.go | 32 ++++---- .../service_volcengine_vpn_gateway.go | 82 ++++++++++++------- 26 files changed, 510 insertions(+), 152 deletions(-) diff --git a/example/cen/main.tf b/example/cen/main.tf index ef2bbfb8..74051910 100644 --- a/example/cen/main.tf +++ b/example/cen/main.tf @@ -1,4 +1,5 @@ resource "volcengine_cen" "foo" { - cen_name = "tf-test" + cen_name = "tf-test-3" description = "tf-test" + project_name = "yuwenhao" } \ No newline at end of file diff --git a/example/cenBandwidthPackage/main.tf b/example/cenBandwidthPackage/main.tf index 7600c5aa..771ac358 100644 --- a/example/cenBandwidthPackage/main.tf +++ b/example/cenBandwidthPackage/main.tf @@ -7,4 +7,5 @@ resource "volcengine_cen_bandwidth_package" "foo" { billing_type = "PrePaid" period_unit = "Year" period = 1 + project_name = "default" } \ No newline at end of file diff --git a/example/scalingConfiguration/main.tf b/example/scalingConfiguration/main.tf index ddd45c4f..b05ccd29 100644 --- a/example/scalingConfiguration/main.tf +++ b/example/scalingConfiguration/main.tf @@ -1,8 +1,8 @@ resource "volcengine_scaling_configuration" "foo" { scaling_configuration_name = "tf-test" - scaling_group_id = "scg-ybru8pazhgl8j1di4tyd" - image_id = "image-ybpbrfay1gl8j1srwwyz" - instance_types = ["ecs.g1.4xlarge"] + scaling_group_id = "scg-ycinx27x25gh9y31p0fy" + image_id = "image-ycgud4t4hxgso0e27bdl" + instance_types = ["ecs.g2i.large"] instance_name = "tf-test" instance_description = "" host_name = "" @@ -19,10 +19,21 @@ resource "volcengine_scaling_configuration" "foo" { size = 20 delete_with_instance = true } - security_group_ids = ["sg-2ff4fhdtlo8ao59gp67iiq9o3"] - eip_bandwidth = 0 + security_group_ids = ["sg-2fepz3c793g1s59gp67y21r34"] + eip_bandwidth = 10 eip_isp = "ChinaMobile" eip_billing_type = "PostPaidByBandwidth" user_data = "IyEvYmluL2Jhc2gKZWNobyAidGVzdCI=" + tags { + key = "xx" + value = "xx" + } + tags { + key = "da" + value = "da" + } + project_name = "default" + hpc_cluster_id = "" + spot_strategy = "NoSpot" } diff --git a/example/scalingGroup/main.tf b/example/scalingGroup/main.tf index 11b45b85..ae536b6b 100644 --- a/example/scalingGroup/main.tf +++ b/example/scalingGroup/main.tf @@ -1,10 +1,15 @@ resource "volcengine_scaling_group" "foo" { - scaling_group_name = "tf-test" - subnet_ids = ["subnet-2ff1n75eyf08w59gp67qhnhqm"] + scaling_group_name = "test-tf" + subnet_ids = ["subnet-2fe79j7c8o5c059gp68ksxr93"] multi_az_policy = "BALANCE" desire_instance_number = 0 min_instance_number = 0 max_instance_number = 1 instance_terminate_policy = "OldestInstance" default_cooldown = 10 + project_name = "default" + tags { + key = "xx" + value = "xxaaa" + } } \ No newline at end of file diff --git a/example/vpnConnection/main.tf b/example/vpnConnection/main.tf index 28e5105c..79e95470 100644 --- a/example/vpnConnection/main.tf +++ b/example/vpnConnection/main.tf @@ -13,12 +13,12 @@ resource "volcengine_vpn_connection" "foo" { ike_config_enc_alg = "aes" ike_config_auth_alg = "md5" ike_config_dh_group = "group2" - ike_config_lifetime = 100 + ike_config_lifetime = 9000 ike_config_local_id = "tf_test" ike_config_remote_id = "tf_test" ipsec_config_enc_alg = "aes" ipsec_config_auth_alg = "sha256" ipsec_config_dh_group = "group2" - ipsec_config_lifetime = 100 + ipsec_config_lifetime = 9000 project_name = "default" } \ No newline at end of file diff --git a/example/vpnGateway/main.tf b/example/vpnGateway/main.tf index ada89f6e..7e9945ff 100644 --- a/example/vpnGateway/main.tf +++ b/example/vpnGateway/main.tf @@ -1,9 +1,10 @@ resource "volcengine_vpn_gateway" "foo" { - vpc_id = "vpc-2fe19q1dn2g3k59gp68n7w3rr" - subnet_id = "subnet-2fe19qp20f3sw59gp67w8om25" + vpc_id = "vpc-12b31m7z2kc8w17q7y2fih9ts" + subnet_id = "subnet-12bh8g2d7fshs17q7y2nx82uk" bandwidth = 20 - vpn_gateway_name = "tf-test" + vpn_gateway_name = "tf-test-zzm" description = "tf-test" period = 2 - project_name = "yuwenhao" + period_unit = "Year" + project_name = "default" } \ No newline at end of file diff --git a/volcengine/autoscaling/scaling_configuration/data_source_volcengine_scaling_configurations.go b/volcengine/autoscaling/scaling_configuration/data_source_volcengine_scaling_configurations.go index 2f841f5e..b268f225 100644 --- a/volcengine/autoscaling/scaling_configuration/data_source_volcengine_scaling_configurations.go +++ b/volcengine/autoscaling/scaling_configuration/data_source_volcengine_scaling_configurations.go @@ -181,6 +181,41 @@ func DataSourceVolcengineScalingConfigurations() *schema.Resource { Computed: true, Description: "The ECS user data which the scaling configuration set.", }, + "tags": { + Type: schema.TypeSet, + Computed: true, + Description: "The label of the instance created by the scaling configuration.", + Set: ve.TagsHash, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Computed: true, + Description: "The Key of Tags.", + }, + "value": { + Type: schema.TypeString, + Computed: true, + Description: "The Value of Tags.", + }, + }, + }, + }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The project to which the instance created by the scaling configuration belongs.", + }, + "hpc_cluster_id": { + Type: schema.TypeString, + Computed: true, + Description: "The ID of the HPC cluster to which the instance belongs. Valid only when InstanceTypes.N specifies High Performance Computing GPU Type.", + }, + "spot_strategy": { + Type: schema.TypeString, + Computed: true, + Description: "The preemption policy of the instance. Valid Value: NoSpot (default), SpotAsPriceGo.", + }, }, }, }, diff --git a/volcengine/autoscaling/scaling_configuration/resource_volcengine_scaling_configuration.go b/volcengine/autoscaling/scaling_configuration/resource_volcengine_scaling_configuration.go index acb77069..4d86df24 100644 --- a/volcengine/autoscaling/scaling_configuration/resource_volcengine_scaling_configuration.go +++ b/volcengine/autoscaling/scaling_configuration/resource_volcengine_scaling_configuration.go @@ -51,7 +51,7 @@ func ResourceVolcengineScalingConfiguration() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, }, - Description: "The list of the ECS instance type which the scaling configuration set.", + Description: "The list of the ECS instance type which the scaling configuration set. The maximum number of instance types is 10.", }, "instance_name": { Type: schema.TypeString, @@ -92,7 +92,8 @@ func ResourceVolcengineScalingConfiguration() *schema.Resource { Type: schema.TypeList, Required: true, MinItems: 1, - Description: "The list of volume of the scaling configuration.", + MaxItems: 15, + Description: "The list of volume of the scaling configuration. The number of supported volumes ranges from 1 to 15.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "volume_type": { @@ -103,8 +104,8 @@ func ResourceVolcengineScalingConfiguration() *schema.Resource { "size": { Type: schema.TypeInt, Required: true, - ValidateFunc: validation.IntAtLeast(1), - Description: "The size of volume.", + ValidateFunc: validation.IntBetween(10, 8192), + Description: "The size of volume. System disk value range: 10 - 500. The value range of the data disk: 10 - 8192.", }, "delete_with_instance": { Type: schema.TypeBool, @@ -118,17 +119,21 @@ func ResourceVolcengineScalingConfiguration() *schema.Resource { "security_group_ids": { Type: schema.TypeSet, Required: true, + MaxItems: 5, + MinItems: 1, Elem: &schema.Schema{ Type: schema.TypeString, }, - Description: "The list of the security group id of the networkInterface which the scaling configuration set.", + Description: "The list of the security group id of the networkInterface which the scaling configuration set." + + " A maximum of 5 security groups can be bound at the same time, and the value ranges from 1 to 5.", }, "eip_bandwidth": { Type: schema.TypeInt, Optional: true, Computed: true, - ValidateFunc: validation.IntAtLeast(0), - Description: "The EIP bandwidth which the scaling configuration set.", + ValidateFunc: validation.IntBetween(1, 500), + Description: "The EIP bandwidth which the scaling configuration set. " + + "When the value of Eip.BillingType is PostPaidByBandwidth, the value is 1 to 500. When the value of Eip.BillingType is PostPaidByTraffic, the value is 1 to 200.", }, "eip_isp": { Type: schema.TypeString, @@ -151,6 +156,47 @@ func ResourceVolcengineScalingConfiguration() *schema.Resource { Optional: true, Description: "The ECS user data which the scaling configuration set.", }, + "tags": { + Type: schema.TypeSet, + Optional: true, + Description: "The label of the instance created by the scaling configuration. Up to 20 tags are supported.", + MaxItems: 20, + Set: ve.TagsHash, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "key": { + Type: schema.TypeString, + Required: true, + Description: "The Key of Tags.", + }, + "value": { + Type: schema.TypeString, + Required: true, + Description: "The Value of Tags.", + }, + }, + }, + }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The project to which the instance created by the scaling configuration belongs.", + }, + "hpc_cluster_id": { + Type: schema.TypeString, + Optional: true, + Description: "The ID of the HPC cluster to which the instance belongs. Valid only when InstanceTypes.N specifies High Performance Computing GPU Type.", + }, + "spot_strategy": { + Type: schema.TypeString, + Optional: true, + Default: "NoSpot", + Description: "The preemption policy of the instance. Valid Value: NoSpot (default), SpotAsPriceGo.", + ValidateFunc: validation.StringInSlice([]string{ + "NoSpot", + "SpotAsPriceGo", + }, false), + }, }, } dataSource := DataSourceVolcengineScalingConfigurations().Schema["scaling_configurations"].Elem.(*schema.Resource).Schema diff --git a/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go b/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go index 1eae9641..3d947f27 100644 --- a/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go +++ b/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go @@ -1,6 +1,7 @@ package scaling_configuration import ( + "encoding/json" "errors" "fmt" "time" @@ -138,6 +139,22 @@ func (s *VolcengineScalingConfigurationService) CreateResource(resourceData *sch TargetField: "Eip.BillingType", }, }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if tags, ok := d.GetOk("tags"); ok { + tagMap := map[string]interface{}{} + for _, v := range tags.(*schema.Set).List() { + if vMap, ok := v.(map[string]interface{}); ok { + tagMap[vMap["key"].(string)] = vMap["value"] + } + } + if tagsStr, err := json.Marshal(tagMap); err != nil { + return false, err + } else { + (*call.SdkParam)["Tags"] = string(tagsStr) + } + } + return true, nil + }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) @@ -213,12 +230,18 @@ func (s *VolcengineScalingConfigurationService) ModifyResource(resourceData *sch "eip_billing_type": { TargetField: "Eip.BillingType", }, + "project_name": { + ConvertType: ve.ConvertDefault, + }, + "spot_strategy": { + ConvertType: ve.ConvertDefault, + }, + "hpc_cluster_id": { + ConvertType: ve.ConvertDefault, + }, }, RequestIdField: "ScalingConfigurationId", BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - if len(*call.SdkParam) < 2 { - return false, nil - } if d.HasChange("eip_bandwidth") || d.HasChange("eip_isp") || d.HasChange("eip_billing_type") { (*call.SdkParam)["Eip.Bandwidth"] = d.Get("eip_bandwidth") (*call.SdkParam)["Eip.ISP"] = d.Get("eip_isp") @@ -232,6 +255,24 @@ func (s *VolcengineScalingConfigurationService) ModifyResource(resourceData *sch (*call.SdkParam)[fmt.Sprintf("Volumes.%d.VolumeType", i+1)] = volume["volume_type"] } } + if d.HasChange("tags") { + if tags, ok := d.GetOk("tags"); ok { + logger.DebugInfo(logger.ReqFormat, "测试", tags) + tagMap := map[string]interface{}{} + for _, v := range tags.(*schema.Set).List() { + logger.DebugInfo(logger.ReqFormat, "测试", v) + if vMap, ok := v.(map[string]interface{}); ok { + tagMap[vMap["key"].(string)] = vMap["value"] + } + } + logger.DebugInfo(logger.ReqFormat, "测试", tagMap) + if tagsStr, err := json.Marshal(tagMap); err != nil { + return false, err + } else { + (*call.SdkParam)["Tags"] = string(tagsStr) + } + } + } return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { diff --git a/volcengine/autoscaling/scaling_group/data_source_volcengine_scaling_groups.go b/volcengine/autoscaling/scaling_group/data_source_volcengine_scaling_groups.go index 3c259d93..d240a979 100644 --- a/volcengine/autoscaling/scaling_group/data_source_volcengine_scaling_groups.go +++ b/volcengine/autoscaling/scaling_group/data_source_volcengine_scaling_groups.go @@ -34,7 +34,6 @@ func DataSourceVolcengineScalingGroups() *schema.Resource { ValidateFunc: validation.StringIsValidRegExp, Description: "A Name Regex of scaling group.", }, - "output_file": { Type: schema.TypeString, Optional: true, @@ -181,6 +180,12 @@ func DataSourceVolcengineScalingGroups() *schema.Resource { Computed: true, Description: "The version of the launch template bound to the scaling group.", }, + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of scaling group.", + }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/autoscaling/scaling_group/resource_volcengine_scaling_group.go b/volcengine/autoscaling/scaling_group/resource_volcengine_scaling_group.go index 49b60b1b..f2daff1f 100644 --- a/volcengine/autoscaling/scaling_group/resource_volcengine_scaling_group.go +++ b/volcengine/autoscaling/scaling_group/resource_volcengine_scaling_group.go @@ -40,7 +40,7 @@ func ResourceVolcengineScalingGroup() *schema.Resource { Type: schema.TypeInt, Optional: true, Computed: true, - Description: "The default cooldown interval of the scaling group. Default value: 300.", + Description: "The default cooldown interval of the scaling group. Value range: 5 ~ 86400, unit: second. Default value: 300.", ValidateFunc: validation.IntBetween(5, 86400), }, "subnet_ids": { @@ -65,14 +65,14 @@ func ResourceVolcengineScalingGroup() *schema.Resource { "min_instance_number": { Type: schema.TypeInt, Required: true, - Description: "The min instance number of the scaling group.", - ValidateFunc: validation.IntAtLeast(0), + Description: "The min instance number of the scaling group. Value range: 0 ~ 100.", + ValidateFunc: validation.IntBetween(0, 100), }, "max_instance_number": { Type: schema.TypeInt, Required: true, - Description: "The max instance number of the scaling group.", - ValidateFunc: validation.IntAtLeast(0), + Description: "The max instance number of the scaling group. Value range: 0 ~ 100.", + ValidateFunc: validation.IntBetween(0, 100), }, "instance_terminate_policy": { Type: schema.TypeString, @@ -95,7 +95,7 @@ func ResourceVolcengineScalingGroup() *schema.Resource { "port": { Type: schema.TypeInt, Required: true, - Description: "The port receiving request of the server group.", + Description: "The port receiving request of the server group. Value range: 1 ~ 65535.", ValidateFunc: validation.IntBetween(1, 65535), }, "server_group_id": { @@ -106,7 +106,7 @@ func ResourceVolcengineScalingGroup() *schema.Resource { "weight": { Type: schema.TypeInt, Required: true, - Description: "The weight of the instance.", + Description: "The weight of the instance. Value range: 0 ~ 100.", ValidateFunc: validation.IntBetween(0, 100), }, "load_balancer_id": { @@ -131,13 +131,19 @@ func ResourceVolcengineScalingGroup() *schema.Resource { "launch_template_id": { Type: schema.TypeString, Optional: true, - Description: "The ID of the launch template bound to the scaling group.", + Description: "The ID of the launch template bound to the scaling group. The launch template and scaling configuration cannot take effect at the same time.", }, "launch_template_version": { Type: schema.TypeString, Optional: true, - Description: "The version of the launch template bound to the scaling group.", + Description: "The version of the launch template bound to the scaling group. Valid values are the version number, Latest, or Default.", }, + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the scaling group.", + }, + "tags": ve.TagsSchema(), }, } dataSource := DataSourceVolcengineScalingGroups().Schema["scaling_groups"].Elem.(*schema.Resource).Schema diff --git a/volcengine/autoscaling/scaling_group/service_volcengine_scaling_group.go b/volcengine/autoscaling/scaling_group/service_volcengine_scaling_group.go index 98e717b1..9a686a4d 100644 --- a/volcengine/autoscaling/scaling_group/service_volcengine_scaling_group.go +++ b/volcengine/autoscaling/scaling_group/service_volcengine_scaling_group.go @@ -178,6 +178,10 @@ func (s *VolcengineScalingGroupService) CreateResource(resourceData *schema.Reso TargetField: "MultiAZPolicy", ConvertType: ve.ConvertDefault, }, + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) @@ -196,40 +200,7 @@ func (s *VolcengineScalingGroupService) CreateResource(resourceData *schema.Reso }, } callbacks = append(callbacks, callback) - // serverGroup - if resourceData.Get("server_group_attributes") != nil && - len(resourceData.Get("server_group_attributes").(*schema.Set).List()) > 0 { - attachServerGroupCallback := ve.Callback{ - Call: ve.SdkCall{ - Action: "AttachServerGroup", - ConvertMode: ve.RequestConvertAll, - Convert: map[string]ve.RequestConvert{ - "server_group_attributes": { - ConvertType: ve.ConvertListN, - }, - }, - ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { - logger.Debug(logger.RespFormat, call.Action, call.SdkParam) - return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) - }, - CallError: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall, baseErr error) error { - return resource.Retry(15*time.Minute, func() *resource.RetryError { - _, callErr := s.ReadResource(d, d.Get("scaling_group_id").(string)) - if callErr != nil { - return resource.NonRetryableError(fmt.Errorf("error reading ScalingGroup: %q, %w", d.Id(), callErr)) - } - _, callErr = call.ExecuteCall(d, client, call) - if callErr == nil { - return nil - } - return resource.RetryableError(callErr) - }) - }, - }, - } - callbacks = append(callbacks, attachServerGroupCallback) - } - return []ve.Callback{callback} + return callbacks } func (s *VolcengineScalingGroupService) ModifyResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -275,6 +246,12 @@ func (s *VolcengineScalingGroupService) ModifyResource(resourceData *schema.Reso "multi_az_policy": { TargetField: "MultiAZPolicy", }, + "launch_template_id": { + ConvertType: ve.ConvertDefault, + }, + "launch_template_version": { + ConvertType: ve.ConvertDefault, + }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { if len(*call.SdkParam) < 2 { @@ -364,7 +341,9 @@ func (s *VolcengineScalingGroupService) ModifyResource(resourceData *schema.Reso }, } callbacks = append(callbacks, removeAttrCallback, attachAttrCallback) - + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "scalinggroup", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) return callbacks } @@ -446,3 +425,12 @@ func getUniversalInfo(actionName string) ve.UniversalInfo { ContentType: ve.Default, } } + +func (s *VolcengineScalingGroupService) ProjectTrn() *ve.ProjectTrn { + return &ve.ProjectTrn{ + ServiceName: "auto_scaling", + ResourceType: "scalinggroup", + ProjectResponseField: "ProjectName", + ProjectSchemaField: "project_name", + } +} diff --git a/volcengine/autoscaling/scaling_instance_attachment/resource_volcengine_scaling_instance_attachment.go b/volcengine/autoscaling/scaling_instance_attachment/resource_volcengine_scaling_instance_attachment.go index fcbec35f..1ead9b59 100644 --- a/volcengine/autoscaling/scaling_instance_attachment/resource_volcengine_scaling_instance_attachment.go +++ b/volcengine/autoscaling/scaling_instance_attachment/resource_volcengine_scaling_instance_attachment.go @@ -12,6 +12,7 @@ import ( Import Scaling instance attachment can be imported using the scaling_group_id and instance_id, e.g. +You can choose to remove or detach the instance according to the `delete_type` field. ``` $ terraform import volcengine_scaling_instance_attachment.default scg-mizl7m1kqccg5smt1bdpijuj:i-l8u2ai4j0fauo6mrpgk8 ``` diff --git a/volcengine/autoscaling/scaling_policy/resource_volcengine_scaling_policy.go b/volcengine/autoscaling/scaling_policy/resource_volcengine_scaling_policy.go index eded1ecc..a11261cb 100644 --- a/volcengine/autoscaling/scaling_policy/resource_volcengine_scaling_policy.go +++ b/volcengine/autoscaling/scaling_policy/resource_volcengine_scaling_policy.go @@ -64,16 +64,18 @@ func ResourceVolcengineScalingPolicy() *schema.Resource { Description: "The adjustment type of the scaling policy. Valid values: QuantityChangeInCapacity, PercentChangeInCapacity, TotalCapacity.", }, "adjustment_value": { - Type: schema.TypeInt, - Required: true, - Description: "The adjustment value of the scaling policy.", + Type: schema.TypeInt, + Required: true, + Description: "The adjustment value of the scaling policy. When the value of the `AdjustmentType` parameter is `QuantityChangeInCapacity`: -100 ~ 100, 0 is not allowed, unit: piece. " + + "When the value of the `AdjustmentType` parameter is `PercentChangeInCapacity`: -100 ~ 10000, 0 is not allowed, unit: %. " + + "When the value of the `AdjustmentType` parameter is `TotalCapacity`: the default is 0 to 100, unit: piece.", }, "cooldown": { Type: schema.TypeInt, Optional: true, Computed: true, - ValidateFunc: validation.IntBetween(-1, 86400), - Description: "The cooldown of the scaling policy. Default value is the cooldown time of the scaling group.", + ValidateFunc: validation.IntBetween(0, 86400), + Description: "The cooldown of the scaling policy. Default value is the cooldown time of the scaling group. Value: 0~86400, unit: second, if left blank, the cooling time of the scaling group will be used by default.", }, "scheduled_policy_launch_time": { Type: schema.TypeString, @@ -81,14 +83,19 @@ func ResourceVolcengineScalingPolicy() *schema.Resource { Computed: true, ValidateFunc: timeValidation, DiffSuppressFunc: policyDiffSuppressFunc("Recurrence", "Scheduled"), - Description: "The launch time of the scheduled policy of the scaling policy.", + Description: "The launch time of the scheduled policy of the scaling policy.\n" + + "When the value of `ScalingPolicyType` is `Scheduled`, it means that the trigger time of the scheduled task must be greater than the current time.\n" + + "When the value of `ScalingPolicyType` is `Recurrence`: If `ScheduledPolicy.RecurrenceType` is not specified, it means to execute only once according to the date and time specified here.\n" + + "If `ScheduledPolicy.RecurrenceType` is specified, it indicates the start time of the periodic task. Only the time within 90 days from the date of creation/modification is supported.\n" + + "When the value of `ScalingPolicyType` is `Alarm`, this parameter is invalid.", }, "scheduled_policy_recurrence_end_time": { Type: schema.TypeString, Optional: true, ValidateFunc: timeValidation, DiffSuppressFunc: policyDiffSuppressFunc("Recurrence"), - Description: "The recurrence end time of the scheduled policy of the scaling policy.", + Description: "The recurrence end time of the scheduled policy of the scaling policy. Valid and required when `ScalingPolicyType` is `Recurrence`. " + + "If not configured, it will default to the day/week/month after this moment according to the recurrence period (ScheduledPolicy.RecurrenceType).", }, "scheduled_policy_recurrence_type": { Type: schema.TypeString, @@ -101,7 +108,12 @@ func ResourceVolcengineScalingPolicy() *schema.Resource { Type: schema.TypeString, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Recurrence"), - Description: "The recurrence value the scheduled policy of the scaling policy.", + Description: "The recurrence value the scheduled policy of the scaling policy. Valid and required when `ScalingPolicyType` is `Recurrence`. " + + "When the value of the ScheduledPolicy.RecurrenceType parameter is Daily, only one value can be filled in, ranging from 1 to 31.\n" + + "When the value of the ScheduledPolicy.RecurrenceType parameter is Weekly, you can enter multiple values separated by commas (,). The values from Monday to Sunday are: 1,2,3,4,5,6,7.\n" + + "When the value of the ScheduledPolicy.RecurrenceType parameter is Monthly, the format is A-B. The value ranges of A and B are both 1~31, and B must be greater than or equal to A.\n" + + "When the value of the ScheduledPolicy.RecurrenceType parameter is Cron, it means UTC+8 time, supports 5-field expressions of minutes, hours, days, months, and weeks, " + + "and supports wildcard English commas (,), English question marks (?), and conjunctions ( -), asterisk (*), pound sign (#), slash (/), L, and W.", }, "alarm_policy_rule_type": { Type: schema.TypeString, @@ -109,40 +121,51 @@ func ResourceVolcengineScalingPolicy() *schema.Resource { Default: "Static", ValidateFunc: validation.StringInSlice([]string{"Static"}, false), DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), - Description: "The rule type of the alarm policy of the scaling policy. Valid value: Static.", + Description: "The rule type of the alarm policy of the scaling policy. Valid value: Static. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`.", }, "alarm_policy_evaluation_count": { Type: schema.TypeInt, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), ValidateFunc: validation.IntBetween(1, 180), - Description: "The evaluation count of the alarm policy of the scaling policy.", + Description: "The evaluation count of the alarm policy of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`.", }, "alarm_policy_condition_metric_name": { Type: schema.TypeString, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), - Description: "The metric name of the alarm policy condition of the scaling policy. Valid values: CpuTotal_Max, CpuTotal_Min, CpuTotal_Avg, MemoryUsedUtilization_Max, MemoryUsedUtilization_Min, MemoryUsedUtilization_Avg, Instance_CpuBusy_Max, Instance_CpuBusy_Min, Instance_CpuBusy_Avg.", + ValidateFunc: validation.StringInSlice([]string{ + "CpuTotal_Max", + "CpuTotal_Min", + "CpuTotal_Avg", + "MemoryUsedUtilization_Max", + "MemoryUsedUtilization_Min", + "MemoryUsedUtilization_Avg", + "Instance_CpuBusy_Max", + "Instance_CpuBusy_Min", + "Instance_CpuBusy_Avg", + }, false), + Description: "The metric name of the alarm policy condition of the scaling policy. Valid values: CpuTotal_Max, CpuTotal_Min, CpuTotal_Avg, MemoryUsedUtilization_Max, MemoryUsedUtilization_Min, MemoryUsedUtilization_Avg, Instance_CpuBusy_Max, Instance_CpuBusy_Min, Instance_CpuBusy_Avg.", }, "alarm_policy_condition_metric_unit": { Type: schema.TypeString, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), ValidateFunc: validation.StringInSlice([]string{"Percent"}, false), - Description: "The comparison operator of the alarm policy condition of the scaling policy.", + Description: "The comparison operator of the alarm policy condition of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`.", }, "alarm_policy_condition_comparison_operator": { Type: schema.TypeString, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), ValidateFunc: validation.StringInSlice([]string{">", "<", "="}, false), - Description: "The comparison operator of the alarm policy condition of the scaling policy. Valid values: >, <, =.", + Description: "The comparison operator of the alarm policy condition of the scaling policy. Valid values: `>`, `<`, `=`. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`.", }, "alarm_policy_condition_threshold": { Type: schema.TypeString, Optional: true, DiffSuppressFunc: policyDiffSuppressFunc("Alarm"), - Description: "The threshold of the alarm policy condition of the scaling policy.", + Description: "The threshold of the alarm policy condition of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`.", }, }, } diff --git a/volcengine/cen/cen/data_source_volcengine_cens.go b/volcengine/cen/cen/data_source_volcengine_cens.go index 4a773dbe..7f562fc6 100644 --- a/volcengine/cen/cen/data_source_volcengine_cens.go +++ b/volcengine/cen/cen/data_source_volcengine_cens.go @@ -101,6 +101,11 @@ func DataSourceVolcengineCens() *schema.Resource { Description: "A list of bandwidth package IDs of the cen.", }, "tags": ve.TagsSchemaComputed(), + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the cen instance.", + }, }, }, }, diff --git a/volcengine/cen/cen/resource_volcengine_cen.go b/volcengine/cen/cen/resource_volcengine_cen.go index c4a07dc0..b4f6e66b 100644 --- a/volcengine/cen/cen/resource_volcengine_cen.go +++ b/volcengine/cen/cen/resource_volcengine_cen.go @@ -46,6 +46,11 @@ func ResourceVolcengineCen() *schema.Resource { Description: "The description of the cen.", }, "tags": ve.TagsSchema(), + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the cen instance.", + }, }, } s := DataSourceVolcengineCens().Schema["cens"].Elem.(*schema.Resource).Schema diff --git a/volcengine/cen/cen/service_volcengine_cen.go b/volcengine/cen/cen/service_volcengine_cen.go index 7d5bef26..8ce5cc95 100644 --- a/volcengine/cen/cen/service_volcengine_cen.go +++ b/volcengine/cen/cen/service_volcengine_cen.go @@ -141,6 +141,15 @@ func (s *VolcengineCenService) RefreshResourceState(resourceData *schema.Resourc return nil, "", fmt.Errorf("cen status error, status:%s", status.(string)) } } + project, err := ve.ObtainSdkValue("ProjectName", demo) + if err != nil { + return nil, "", err + } + if resourceData.Get("project_name") != nil && resourceData.Get("project_name").(string) != "" { + if project != resourceData.Get("project_name") { + return demo, "", err + } + } //注意 返回的第一个参数不能为空 否则会一直等下去 return demo, status.(string), err }, @@ -211,6 +220,10 @@ func (s *VolcengineCenService) ModifyResource(resourceData *schema.ResourceData, callbacks = append(callbacks, callback) tagCallback := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "cen", resourceData, getUniversalInfo) callbacks = append(callbacks, tagCallback...) + if resourceData.HasChange("project_name") { + projectCallback := s.ModifyProject(resourceData) + callbacks = append(callbacks, projectCallback...) + } return callbacks } @@ -295,3 +308,59 @@ func getUniversalInfo(actionName string) ve.UniversalInfo { ContentType: ve.Default, } } + +func (s *VolcengineCenService) ModifyProject(resourceData *schema.ResourceData) []ve.Callback { + var call []ve.Callback + id := s.ReadResourceId(resourceData.Id()) + if resourceData.HasChange("project_name") { + modifyProject := ve.Callback{ + Call: ve.SdkCall{ + Action: "MoveProjectResource", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "project_name": { + ConvertType: ve.ConvertDefault, + TargetField: "TargetProjectName", + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if (*call.SdkParam)["TargetProjectName"] == nil || (*call.SdkParam)["TargetProjectName"] == "" { + return false, fmt.Errorf("Could set ProjectName to empty ") + } + //获取用户ID + input := map[string]interface{}{ + "ProjectName": (*call.SdkParam)["TargetProjectName"], + } + logger.Debug(logger.ReqFormat, "GetProject", input) + out, err := s.Client.UniversalClient.DoCall(s.getIAMUniversalInfo("GetProject"), &input) + if err != nil { + return false, err + } + accountId, err := ve.ObtainSdkValue("Result.AccountID", *out) + if err != nil { + return false, err + } + trnStr := fmt.Sprintf("trn:%s:%s:%d:%s/%s", "cen", "", int(accountId.(float64)), + "cen", id) + (*call.SdkParam)["ResourceTrn.1"] = trnStr + return true, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) + return s.Client.UniversalClient.DoCall(s.getIAMUniversalInfo(call.Action), call.SdkParam) + }, + }, + } + call = append(call, modifyProject) + } + return call +} + +func (s *VolcengineCenService) getIAMUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "iam", + Version: "2021-08-01", + HttpMethod: ve.GET, + Action: actionName, + } +} diff --git a/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go b/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go index 389343fd..8be7cfc5 100644 --- a/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go +++ b/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go @@ -48,7 +48,7 @@ func ResourceVolcengineCenAttachInstance() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "The type of the instance.", + Description: "The type of the instance. Valid values : `VPC`, `DCGW`.", ValidateFunc: validation.StringInSlice([]string{"VPC", "DCGW"}, false), }, "instance_region_id": { diff --git a/volcengine/cen/cen_bandwidth_package/data_source_volcengine_cen_bandwidth_packages.go b/volcengine/cen/cen_bandwidth_package/data_source_volcengine_cen_bandwidth_packages.go index 2f089f9c..6b0f1541 100644 --- a/volcengine/cen/cen_bandwidth_package/data_source_volcengine_cen_bandwidth_packages.go +++ b/volcengine/cen/cen_bandwidth_package/data_source_volcengine_cen_bandwidth_packages.go @@ -156,6 +156,11 @@ func DataSourceVolcengineCenBandwidthPackages() *schema.Resource { Description: "The deleted time of the cen bandwidth package.", }, "tags": ve.TagsSchemaComputed(), + "project_name": { + Type: schema.TypeString, + Computed: true, + Description: "The ProjectName of the cen bandwidth package.", + }, }, }, }, diff --git a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go index e35d90db..90bb1292 100644 --- a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go +++ b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go @@ -55,7 +55,7 @@ func ResourceVolcengineCenBandwidthPackage() *schema.Resource { Optional: true, Computed: true, ValidateFunc: validation.IntBetween(2, 10000), - Description: "The bandwidth of the cen bandwidth package.", + Description: "The bandwidth of the cen bandwidth package. Value: 2~10000.", }, "cen_bandwidth_package_name": { Type: schema.TypeString, @@ -75,7 +75,8 @@ func ResourceVolcengineCenBandwidthPackage() *schema.Resource { ForceNew: true, Default: "PrePaid", ValidateFunc: validation.StringInSlice([]string{"PrePaid"}, false), - Description: "The billing type of the cen bandwidth package. Terraform will only remove the PrePaid cen bandwidth package from the state file, not actually remove.", + Description: "The billing type of the cen bandwidth package. Only support `PrePaid` and default value is `PrePaid`.\n" + + "Terraform will only remove the PrePaid cen bandwidth package from the state file, not actually remove.", }, "period_unit": { Type: schema.TypeString, @@ -83,16 +84,21 @@ func ResourceVolcengineCenBandwidthPackage() *schema.Resource { Default: "Month", ValidateFunc: validation.StringInSlice([]string{"Month", "Year"}, false), DiffSuppressFunc: periodDiffSuppress, - Description: "The period unit of the cen bandwidth package.", + Description: "The period unit of the cen bandwidth package. Value : `Month`, `Year`. Default value is `Month`.", }, "period": { Type: schema.TypeInt, Optional: true, Default: 1, DiffSuppressFunc: periodDiffSuppress, - Description: "The period of the cen bandwidth package.", + Description: "The period of the cen bandwidth package. Default value is 1.", }, "tags": ve.TagsSchema(), + "project_name": { + Type: schema.TypeString, + Optional: true, + Description: "The ProjectName of the cen bandwidth package.", + }, }, } s := DataSourceVolcengineCenBandwidthPackages().Schema["bandwidth_packages"].Elem.(*schema.Resource).Schema diff --git a/volcengine/cen/cen_bandwidth_package/service_volcengine_cen_bandwidth_package.go b/volcengine/cen/cen_bandwidth_package/service_volcengine_cen_bandwidth_package.go index 423e6693..bc7b4832 100644 --- a/volcengine/cen/cen_bandwidth_package/service_volcengine_cen_bandwidth_package.go +++ b/volcengine/cen/cen_bandwidth_package/service_volcengine_cen_bandwidth_package.go @@ -153,6 +153,15 @@ func (s *VolcengineCenBandwidthPackageService) RefreshResourceState(resourceData return nil, "", fmt.Errorf("cen status error, status:%s", status.(string)) } } + project, err := ve.ObtainSdkValue("ProjectName", demo) + if err != nil { + return nil, "", err + } + if resourceData.Get("project_name") != nil && resourceData.Get("project_name").(string) != "" { + if project != resourceData.Get("project_name") { + return demo, "", err + } + } //注意 返回的第一个参数不能为空 否则会一直等下去 return demo, status.(string), err }, @@ -246,7 +255,11 @@ func (s *VolcengineCenBandwidthPackageService) ModifyResource(resourceData *sche callbacks = append(callbacks, callback) setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "cenbandwidthpackage", resourceData, getUniversalInfo) callbacks = append(callbacks, setResourceTagsCallbacks...) - return []ve.Callback{callback} + if resourceData.HasChange("project_name") { + projectCallback := s.ModifyProject(resourceData) + callbacks = append(callbacks, projectCallback...) + } + return callbacks } func (s *VolcengineCenBandwidthPackageService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -338,3 +351,59 @@ func getUniversalInfo(actionName string) ve.UniversalInfo { ContentType: ve.Default, } } + +func (s *VolcengineCenBandwidthPackageService) ModifyProject(resourceData *schema.ResourceData) []ve.Callback { + var call []ve.Callback + id := s.ReadResourceId(resourceData.Id()) + if resourceData.HasChange("project_name") { + modifyProject := ve.Callback{ + Call: ve.SdkCall{ + Action: "MoveProjectResource", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "project_name": { + ConvertType: ve.ConvertDefault, + TargetField: "TargetProjectName", + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if (*call.SdkParam)["TargetProjectName"] == nil || (*call.SdkParam)["TargetProjectName"] == "" { + return false, fmt.Errorf("Could set ProjectName to empty ") + } + //获取用户ID + input := map[string]interface{}{ + "ProjectName": (*call.SdkParam)["TargetProjectName"], + } + logger.Debug(logger.ReqFormat, "GetProject", input) + out, err := s.Client.UniversalClient.DoCall(s.getIAMUniversalInfo("GetProject"), &input) + if err != nil { + return false, err + } + accountId, err := ve.ObtainSdkValue("Result.AccountID", *out) + if err != nil { + return false, err + } + trnStr := fmt.Sprintf("trn:%s:%s:%d:%s/%s", "cen", "", int(accountId.(float64)), + "cenbandwidthpackage", id) + (*call.SdkParam)["ResourceTrn.1"] = trnStr + return true, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) + return s.Client.UniversalClient.DoCall(s.getIAMUniversalInfo(call.Action), call.SdkParam) + }, + }, + } + call = append(call, modifyProject) + } + return call +} + +func (s *VolcengineCenBandwidthPackageService) getIAMUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "iam", + Version: "2021-08-01", + HttpMethod: ve.GET, + Action: actionName, + } +} diff --git a/volcengine/vpn/vpn_connection/resource_volcengine_vpn_connection.go b/volcengine/vpn/vpn_connection/resource_volcengine_vpn_connection.go index 3cab3ac1..4e13b194 100644 --- a/volcengine/vpn/vpn_connection/resource_volcengine_vpn_connection.go +++ b/volcengine/vpn/vpn_connection/resource_volcengine_vpn_connection.go @@ -50,7 +50,7 @@ func ResourceVolcengineVpnConnection() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - Description: "The ID of the vpn gateway.", + Description: "The ID of the vpn gateway. If the `AttachType` is not passed or the passed value is `VpnGateway`, this parameter must be filled. If the value of `AttachType` is `TransitRouter`, this parameter does not need to be filled.", }, "customer_gateway_id": { Type: schema.TypeString, @@ -68,7 +68,7 @@ func ResourceVolcengineVpnConnection() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.IsCIDR, }, - Description: "The local subnet of the VPN connection.", + Description: "The local subnet of the VPN connection. Up to 5 network segments are supported.", }, "remote_subnet": { Type: schema.TypeSet, @@ -80,7 +80,7 @@ func ResourceVolcengineVpnConnection() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.IsCIDR, }, - Description: "The remote subnet of the VPN connection.", + Description: "The remote subnet of the VPN connection. Up to 5 network segments are supported.", }, "dpd_action": { Type: schema.TypeString, @@ -100,49 +100,49 @@ func ResourceVolcengineVpnConnection() *schema.Resource { "ike_config_psk": { Type: schema.TypeString, Required: true, - Description: "The psk of the ike config of the VPN connection.", + Description: "The psk of the ike config of the VPN connection. The length does not exceed 100 characters, and only uppercase and lowercase letters, special symbols and numbers are allowed.", }, "ike_config_version": { Type: schema.TypeString, Optional: true, Default: "ikev1", ValidateFunc: validation.StringInSlice([]string{"ikev1", "ikev2"}, false), - Description: "The version of the ike config of the VPN connection.", + Description: "The version of the ike config of the VPN connection. The value can be `ikev1` or `ikev2`. The default value is `ikev1`.", }, "ike_config_mode": { Type: schema.TypeString, Optional: true, Default: "main", ValidateFunc: validation.StringInSlice([]string{"main", "aggressive"}, false), - Description: "The mode of the ike config of the VPN connection.", + Description: "The mode of the ike config of the VPN connection. Valid values are `main`, `aggressive`, and default value is `main`.", }, "ike_config_enc_alg": { Type: schema.TypeString, Optional: true, Default: "aes", ValidateFunc: validation.StringInSlice([]string{"aes", "aes192", "aes256", "des", "3des", "sm4"}, false), - Description: "The enc alg of the ike config of the VPN connection.", + Description: "The enc alg of the ike config of the VPN connection. Valid value are `aes`, `aes192`, `aes256`, `des`, `3des`, `sm4`. The default value is `aes`.", }, "ike_config_auth_alg": { Type: schema.TypeString, Optional: true, Default: "sha1", ValidateFunc: validation.StringInSlice([]string{"sha1", "md5", "sha256", "sha384", "sha512", "sm3"}, false), - Description: "The auth alg of the ike config of the VPN connection.", + Description: "The auth alg of the ike config of the VPN connection. Valid value are `sha1`, `md5`, `sha256`, `sha384`, `sha512`, `sm3`. The default value is `sha1`.", }, "ike_config_dh_group": { Type: schema.TypeString, Optional: true, Default: "group2", ValidateFunc: validation.StringInSlice([]string{"group1", "group2", "group5", "group14"}, false), - Description: "The dk group of the ike config of the VPN connection.", + Description: "The dk group of the ike config of the VPN connection. Valid value are `group1`, `group2`, `group5`, `group14`. The default value is `group2`.", }, "ike_config_lifetime": { Type: schema.TypeInt, Optional: true, Default: 86400, - ValidateFunc: validation.IntBetween(0, 86400), - Description: "The lifetime of the ike config of the VPN connection.", + ValidateFunc: validation.IntBetween(900, 86400), + Description: "The lifetime of the ike config of the VPN connection. Value: 900~86400.", }, "ike_config_local_id": { Type: schema.TypeString, @@ -163,28 +163,28 @@ func ResourceVolcengineVpnConnection() *schema.Resource { Optional: true, Default: "aes", ValidateFunc: validation.StringInSlice([]string{"aes", "aes192", "aes256", "des", "3des", "sm4"}, false), - Description: "The enc alg of the ipsec config of the VPN connection.", + Description: "The enc alg of the ipsec config of the VPN connection. Valid value are `aes`, `aes192`, `aes256`, `des`, `3des`, `sm4`. The default value is `aes`.", }, "ipsec_config_auth_alg": { Type: schema.TypeString, Optional: true, Default: "sha1", ValidateFunc: validation.StringInSlice([]string{"sha1", "md5", "sha256", "sha384", "sha512", "sm3"}, false), - Description: "The auth alg of the ipsec config of the VPN connection.", + Description: "The auth alg of the ipsec config of the VPN connection. Valid value are `sha1`, `md5`, `sha256`, `sha384`, `sha512`, `sm3`. The default value is `sha1`.", }, "ipsec_config_dh_group": { Type: schema.TypeString, Optional: true, Default: "group2", ValidateFunc: validation.StringInSlice([]string{"group1", "group2", "group5", "group14", "disable"}, false), - Description: "The dh group of the ipsec config of the VPN connection.", + Description: "The dh group of the ipsec config of the VPN connection. Valid value are `group1`, `group2`, `group5`, `group14` and `disable`. The default value is `group2`.", }, "ipsec_config_lifetime": { Type: schema.TypeInt, Optional: true, Default: 86400, - ValidateFunc: validation.IntBetween(0, 86400), - Description: "The ipsec config of the ike config of the VPN connection.", + ValidateFunc: validation.IntBetween(900, 86400), + Description: "The ipsec config of the ike config of the VPN connection. Value: 900~86400.", }, "negotiate_instantly": { Type: schema.TypeBool, @@ -202,7 +202,12 @@ func ResourceVolcengineVpnConnection() *schema.Resource { Optional: true, ForceNew: true, Default: "VpnGateway", - Description: "The attach type of the VPN connection, the value can be VpnGateway or TransitRouter.", + Description: "The attach type of the VPN connection, the value can be `VpnGateway` or `TransitRouter`.", + }, + "log_enabled": { + Type: schema.TypeBool, + Optional: true, + Description: "Whether to enable connection logging. After enabling Connection Day, you can view and download IPsec connection logs, and use the log information to troubleshoot IPsec connection problems yourself.", }, }, } diff --git a/volcengine/vpn/vpn_connection/service_volcengine_vpn_connection.go b/volcengine/vpn/vpn_connection/service_volcengine_vpn_connection.go index 97cdb70d..52cf2e7e 100644 --- a/volcengine/vpn/vpn_connection/service_volcengine_vpn_connection.go +++ b/volcengine/vpn/vpn_connection/service_volcengine_vpn_connection.go @@ -387,6 +387,9 @@ func (s *VolcengineVpnConnectionService) ModifyResource(resourceData *schema.Res TargetField: "IpsecConfig.Lifetime", ConvertType: ve.ConvertDefault, }, + "log_enabled": { + ConvertType: ve.ConvertDefault, + }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { if len(*call.SdkParam) < 1 { diff --git a/volcengine/vpn/vpn_gateway/common_volcengine_vpn_gateway.go b/volcengine/vpn/vpn_gateway/common_volcengine_vpn_gateway.go index e00b00bd..197a95f3 100644 --- a/volcengine/vpn/vpn_gateway/common_volcengine_vpn_gateway.go +++ b/volcengine/vpn/vpn_gateway/common_volcengine_vpn_gateway.go @@ -45,5 +45,8 @@ var renewTypeResponseConvert = func(v interface{}) interface{} { } var periodDiffSuppress = func(k, old, new string, d *schema.ResourceData) bool { - return d.Get("renew_type").(string) != "ManualRenew" + if len(d.Id()) != 0 { + return d.Get("renew_type").(string) != "ManualRenew" + } + return false } diff --git a/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go b/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go index 150f14c6..8bdaffaa 100644 --- a/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go +++ b/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go @@ -50,7 +50,7 @@ func ResourceVolcengineVpnGateway() *schema.Resource { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntInSlice([]int{5, 10, 20, 50, 100, 200, 500, 1000}), - Description: "The bandwidth of the VPN gateway.", + Description: "The bandwidth of the VPN gateway. Unit: Mbps. Values: 5, 10, 20, 50, 100, 200, 500.", }, "vpn_gateway_name": { Type: schema.TypeString, @@ -70,24 +70,28 @@ func ResourceVolcengineVpnGateway() *schema.Resource { ForceNew: true, Default: "PrePaid", ValidateFunc: validation.StringInSlice([]string{"PrePaid"}, false), - Description: "The BillingType of the VPN gateway. Terraform will only remove the PrePaid VPN gateway from the state file, not actually remove.", + Description: "The BillingType of the VPN gateway. Only support `PrePaid`.\n" + + "Terraform will only remove the PrePaid VPN gateway from the state file, not actually remove.", + }, + "period_unit": { + Type: schema.TypeString, + Optional: true, + Default: "Month", + DiffSuppressFunc: periodDiffSuppress, + ValidateFunc: validation.StringInSlice([]string{"Month", "Year"}, false), + Description: "The PeriodUnit of the VPN gateway. Valid values are `Month`, `Year`. When importing resources, this attribute will not be imported. " + + "If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, - //"period_unit": { - // Type: schema.TypeString, - // Optional: true, - // ForceNew: true, - // Default: "Month", - // ValidateFunc: validation.StringInSlice([]string{"Month"}, false), - // DiffSuppressFunc: periodDiffSuppress, - // Description: "The PeriodUnit of the VPN gateway.", - //}, "period": { Type: schema.TypeInt, Optional: true, - Default: 1, - ValidateFunc: validation.IntAtLeast(1), + Default: 12, DiffSuppressFunc: periodDiffSuppress, - Description: "The Period of the VPN gateway. This parameter is only useful when creating vpn gateway. Default period unit is Month.", + ValidateFunc: validation.Any( + validation.IntBetween(1, 9), + validation.IntInSlice([]int{12, 24, 36})), + Description: "The Period of the VPN gateway. Default value is 12. This parameter is only useful when creating vpn gateway. Default period unit is Month. " + + "When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "renew_type": { Type: schema.TypeString, diff --git a/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go b/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go index e9cf87dc..640e6bff 100644 --- a/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go +++ b/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "log" - "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -177,13 +176,13 @@ func (s *VolcengineVpnGatewayService) RefreshResourceState(resourceData *schema. func (VolcengineVpnGatewayService) WithResourceResponseHandlers(v map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { - if v["BillingType"].(float64) == 1 { - ct, _ := time.Parse("2006-01-02T15:04:05", v["CreationTime"].(string)[0:strings.Index(v["CreationTime"].(string), "+")]) - et, _ := time.Parse("2006-01-02T15:04:05", v["ExpiredTime"].(string)[0:strings.Index(v["ExpiredTime"].(string), "+")]) - y := et.Year() - ct.Year() - m := et.Month() - ct.Month() - v["Period"] = y*12 + int(m) - } + //if v["BillingType"].(float64) == 1 { + // ct, _ := time.Parse("2006-01-02T15:04:05", v["CreationTime"].(string)[0:strings.Index(v["CreationTime"].(string), "+")]) + // et, _ := time.Parse("2006-01-02T15:04:05", v["ExpiredTime"].(string)[0:strings.Index(v["ExpiredTime"].(string), "+")]) + // y := et.Year() - ct.Year() + // m := et.Month() - ct.Month() + // v["Period"] = y*12 + int(m) + //} return v, map[string]ve.ResponseConvert{ "BillingType": { TargetField: "billing_type", @@ -241,13 +240,6 @@ func (s *VolcengineVpnGatewayService) CreateResource(resourceData *schema.Resour ConvertType: ve.ConvertDefault, }, }, - BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - if len(*call.SdkParam) < 1 { - return false, nil - } - (*call.SdkParam)["PeriodUnit"] = "Month" - return true, nil - }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) @@ -305,27 +297,46 @@ func (s *VolcengineVpnGatewayService) ModifyResource(resourceData *schema.Resour callbacks = append(callbacks, modifyCallback) // 续费时长 - if resourceData.Get("renew_type").(string) == "ManualRenew" && resourceData.HasChange("period") { + if resourceData.Get("renew_type").(string) == "ManualRenew" && + (resourceData.HasChange("period") || resourceData.HasChange("period_unit")) { renewVpnGateway := ve.Callback{ Call: ve.SdkCall{ Action: "RenewVpnGateway", ConvertMode: ve.RequestConvertInConvert, - Convert: map[string]ve.RequestConvert{ - "period": { - ConvertType: ve.ConvertDefault, - Convert: func(data *schema.ResourceData, i interface{}) interface{} { - o, n := data.GetChange("period") - return n.(int) - o.(int) - }, - }, - }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - if len(*call.SdkParam) > 0 { - (*call.SdkParam)["PeriodUnit"] = "Month" - (*call.SdkParam)["VpnGatewayId"] = d.Id() - return true, nil + (*call.SdkParam)["VpnGatewayId"] = d.Id() + (*call.SdkParam)["PeriodUnit"] = "Month" + // 计算差值 + month := 0 + o, n := d.GetChange("period") + oldUnit, newUnit := d.GetChange("period_unit") + // 默认为Month,不填的统一设置为Month进行计算 + if len(oldUnit.(string)) == 0 { + oldUnit = "Month" } - return false, nil + if len(newUnit.(string)) == 0 { + newUnit = "Month" + } + if oldUnit.(string) == "Month" && newUnit.(string) == "Year" { + // 月改年 + month = n.(int)*12 - o.(int) + } else if oldUnit.(string) == "Year" && newUnit.(string) == "Month" { + // 年改月 + month = n.(int) - o.(int)*12 + } else if oldUnit == "Year" && newUnit == "Year" { + // 单位没改则period必然发生了改变,直接计算差值 + // 需要区分单位是年还是月 + month = n.(int)*12 - o.(int)*12 + } else { + // 不填改月 或者 一直是月没改变 + month = n.(int) - o.(int) + } + // 如果差值小于等于0则直接报错 + if month <= 0 { + return false, fmt.Errorf("The difference modified by Period must be greater than 0. ") + } + (*call.SdkParam)["Period"] = month + return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) @@ -357,7 +368,7 @@ func (s *VolcengineVpnGatewayService) RemoveResource(resourceData *schema.Resour ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) // todo 打印前台提示日志 - log.Println("[WARN] Cannot destroy PrePaid resource volcengine_vpn_gateway. Terraform will remove this resource from the state file, however resources may remain.") + log.Println("[WARN] Terraform will unsubscribe the resource.") //return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) return nil, nil }, @@ -444,3 +455,12 @@ func (s *VolcengineVpnGatewayService) ProjectTrn() *ve.ProjectTrn { ProjectSchemaField: "project_name", } } + +func (s *VolcengineVpnGatewayService) UnsubscribeInfo(resourceData *schema.ResourceData, resource *schema.Resource) (*ve.UnsubscribeInfo, error) { + info := ve.UnsubscribeInfo{ + InstanceId: s.ReadResourceId(resourceData.Id()), + } + info.NeedUnsubscribe = true + info.Products = []string{"VPN"} + return &info, nil +} From 06909a0f1d6ed5753767d4316bd24d2f85b803a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Wed, 5 Jul 2023 14:15:19 +0800 Subject: [PATCH 03/10] feat: opt vpn and as example --- example/cen/main.tf | 2 +- example/scalingConfiguration/main.tf | 10 +-- example/scalingGroup/main.tf | 4 +- example/vpnGateway/main.tf | 2 +- .../resource_volcengine_vpn_gateway.go | 22 +++--- .../service_volcengine_vpn_gateway.go | 71 ++++++++----------- 6 files changed, 50 insertions(+), 61 deletions(-) diff --git a/example/cen/main.tf b/example/cen/main.tf index 74051910..f5c91f1f 100644 --- a/example/cen/main.tf +++ b/example/cen/main.tf @@ -1,5 +1,5 @@ resource "volcengine_cen" "foo" { cen_name = "tf-test-3" description = "tf-test" - project_name = "yuwenhao" + project_name = "default" } \ No newline at end of file diff --git a/example/scalingConfiguration/main.tf b/example/scalingConfiguration/main.tf index b05ccd29..000ec959 100644 --- a/example/scalingConfiguration/main.tf +++ b/example/scalingConfiguration/main.tf @@ -7,7 +7,7 @@ resource "volcengine_scaling_configuration" "foo" { instance_description = "" host_name = "" password = "" - key_pair_name = "renhuaxi" + key_pair_name = "tf-keypair" security_enhancement_strategy = "InActive" volumes { volume_type = "ESSD_PL0" @@ -25,12 +25,12 @@ resource "volcengine_scaling_configuration" "foo" { eip_billing_type = "PostPaidByBandwidth" user_data = "IyEvYmluL2Jhc2gKZWNobyAidGVzdCI=" tags { - key = "xx" - value = "xx" + key = "tf-key1" + value = "tf-value1" } tags { - key = "da" - value = "da" + key = "tf-key2" + value = "tf-value2" } project_name = "default" hpc_cluster_id = "" diff --git a/example/scalingGroup/main.tf b/example/scalingGroup/main.tf index ae536b6b..28039724 100644 --- a/example/scalingGroup/main.tf +++ b/example/scalingGroup/main.tf @@ -9,7 +9,7 @@ resource "volcengine_scaling_group" "foo" { default_cooldown = 10 project_name = "default" tags { - key = "xx" - value = "xxaaa" + key = "tf-key1" + value = "tf-value1" } } \ No newline at end of file diff --git a/example/vpnGateway/main.tf b/example/vpnGateway/main.tf index 7e9945ff..7b74fec7 100644 --- a/example/vpnGateway/main.tf +++ b/example/vpnGateway/main.tf @@ -2,7 +2,7 @@ resource "volcengine_vpn_gateway" "foo" { vpc_id = "vpc-12b31m7z2kc8w17q7y2fih9ts" subnet_id = "subnet-12bh8g2d7fshs17q7y2nx82uk" bandwidth = 20 - vpn_gateway_name = "tf-test-zzm" + vpn_gateway_name = "tf-test" description = "tf-test" period = 2 period_unit = "Year" diff --git a/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go b/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go index 8bdaffaa..d3d4b67c 100644 --- a/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go +++ b/volcengine/vpn/vpn_gateway/resource_volcengine_vpn_gateway.go @@ -73,15 +73,15 @@ func ResourceVolcengineVpnGateway() *schema.Resource { Description: "The BillingType of the VPN gateway. Only support `PrePaid`.\n" + "Terraform will only remove the PrePaid VPN gateway from the state file, not actually remove.", }, - "period_unit": { - Type: schema.TypeString, - Optional: true, - Default: "Month", - DiffSuppressFunc: periodDiffSuppress, - ValidateFunc: validation.StringInSlice([]string{"Month", "Year"}, false), - Description: "The PeriodUnit of the VPN gateway. Valid values are `Month`, `Year`. When importing resources, this attribute will not be imported. " + - "If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", - }, + //"period_unit": { + // Type: schema.TypeString, + // Optional: true, + // ForceNew: true, + // Default: "Month", + // ValidateFunc: validation.StringInSlice([]string{"Month"}, false), + // DiffSuppressFunc: periodDiffSuppress, + // Description: "The PeriodUnit of the VPN gateway.", + //}, "period": { Type: schema.TypeInt, Optional: true, @@ -90,8 +90,8 @@ func ResourceVolcengineVpnGateway() *schema.Resource { ValidateFunc: validation.Any( validation.IntBetween(1, 9), validation.IntInSlice([]int{12, 24, 36})), - Description: "The Period of the VPN gateway. Default value is 12. This parameter is only useful when creating vpn gateway. Default period unit is Month. " + - "When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", + Description: "The Period of the VPN gateway. Default value is 12. This parameter is only useful when creating vpn gateway. Default period unit is Month.\n" + + "Value range: 1~9, 12, 24, 36. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "renew_type": { Type: schema.TypeString, diff --git a/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go b/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go index 640e6bff..5f4ed457 100644 --- a/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go +++ b/volcengine/vpn/vpn_gateway/service_volcengine_vpn_gateway.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "log" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -176,13 +177,13 @@ func (s *VolcengineVpnGatewayService) RefreshResourceState(resourceData *schema. func (VolcengineVpnGatewayService) WithResourceResponseHandlers(v map[string]interface{}) []ve.ResourceResponseHandler { handler := func() (map[string]interface{}, map[string]ve.ResponseConvert, error) { - //if v["BillingType"].(float64) == 1 { - // ct, _ := time.Parse("2006-01-02T15:04:05", v["CreationTime"].(string)[0:strings.Index(v["CreationTime"].(string), "+")]) - // et, _ := time.Parse("2006-01-02T15:04:05", v["ExpiredTime"].(string)[0:strings.Index(v["ExpiredTime"].(string), "+")]) - // y := et.Year() - ct.Year() - // m := et.Month() - ct.Month() - // v["Period"] = y*12 + int(m) - //} + if v["BillingType"].(float64) == 1 { + ct, _ := time.Parse("2006-01-02T15:04:05", v["CreationTime"].(string)[0:strings.Index(v["CreationTime"].(string), "+")]) + et, _ := time.Parse("2006-01-02T15:04:05", v["ExpiredTime"].(string)[0:strings.Index(v["ExpiredTime"].(string), "+")]) + y := et.Year() - ct.Year() + m := et.Month() - ct.Month() + v["Period"] = y*12 + int(m) + } return v, map[string]ve.ResponseConvert{ "BillingType": { TargetField: "billing_type", @@ -240,6 +241,13 @@ func (s *VolcengineVpnGatewayService) CreateResource(resourceData *schema.Resour ConvertType: ve.ConvertDefault, }, }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if len(*call.SdkParam) < 1 { + return false, nil + } + (*call.SdkParam)["PeriodUnit"] = "Month" + return true, nil + }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) @@ -297,46 +305,27 @@ func (s *VolcengineVpnGatewayService) ModifyResource(resourceData *schema.Resour callbacks = append(callbacks, modifyCallback) // 续费时长 - if resourceData.Get("renew_type").(string) == "ManualRenew" && - (resourceData.HasChange("period") || resourceData.HasChange("period_unit")) { + if resourceData.Get("renew_type").(string) == "ManualRenew" && resourceData.HasChange("period") { renewVpnGateway := ve.Callback{ Call: ve.SdkCall{ Action: "RenewVpnGateway", ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "period": { + ConvertType: ve.ConvertDefault, + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + o, n := data.GetChange("period") + return n.(int) - o.(int) + }, + }, + }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - (*call.SdkParam)["VpnGatewayId"] = d.Id() - (*call.SdkParam)["PeriodUnit"] = "Month" - // 计算差值 - month := 0 - o, n := d.GetChange("period") - oldUnit, newUnit := d.GetChange("period_unit") - // 默认为Month,不填的统一设置为Month进行计算 - if len(oldUnit.(string)) == 0 { - oldUnit = "Month" - } - if len(newUnit.(string)) == 0 { - newUnit = "Month" + if len(*call.SdkParam) > 0 { + (*call.SdkParam)["PeriodUnit"] = "Month" + (*call.SdkParam)["VpnGatewayId"] = d.Id() + return true, nil } - if oldUnit.(string) == "Month" && newUnit.(string) == "Year" { - // 月改年 - month = n.(int)*12 - o.(int) - } else if oldUnit.(string) == "Year" && newUnit.(string) == "Month" { - // 年改月 - month = n.(int) - o.(int)*12 - } else if oldUnit == "Year" && newUnit == "Year" { - // 单位没改则period必然发生了改变,直接计算差值 - // 需要区分单位是年还是月 - month = n.(int)*12 - o.(int)*12 - } else { - // 不填改月 或者 一直是月没改变 - month = n.(int) - o.(int) - } - // 如果差值小于等于0则直接报错 - if month <= 0 { - return false, fmt.Errorf("The difference modified by Period must be greater than 0. ") - } - (*call.SdkParam)["Period"] = month - return true, nil + return false, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) From 342a6902261863eefcc62cb2b7d44dda38b0edf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Thu, 6 Jul 2023 11:43:49 +0800 Subject: [PATCH 04/10] feat: add cen route and service route --- example/cenRouteEntry/main.tf | 15 ++++ example/cenServiceRouteEntry/main.tf | 56 ++++++++++++++ example/dataCenRouteEntries/main.tf | 2 +- example/dataCenServiceRouteEntries/main.tf | 3 + example/vpnGateway/main.tf | 1 - ...ervice_volcengine_scaling_configuration.go | 3 - ...engine_scaling_configuration_attachment.go | 1 + ...source_volcengine_cen_bandwidth_package.go | 8 +- .../service_volcengine_cen_route_entry.go | 14 ++++ ...ce_volcengine_cen_service_route_entries.go | 29 ++++++++ ...urce_volcengine_cen_service_route_entry.go | 51 ++++++++++++- ...vice_volcengine_cen_service_route_entry.go | 74 ++++++++++++++++++- volcengine/provider.go | 9 ++- 13 files changed, 251 insertions(+), 15 deletions(-) create mode 100644 example/cenRouteEntry/main.tf create mode 100644 example/cenServiceRouteEntry/main.tf create mode 100644 example/dataCenServiceRouteEntries/main.tf diff --git a/example/cenRouteEntry/main.tf b/example/cenRouteEntry/main.tf new file mode 100644 index 00000000..d1c42b0d --- /dev/null +++ b/example/cenRouteEntry/main.tf @@ -0,0 +1,15 @@ +resource "volcengine_cen_route_entry" "foo" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "192.168.0.0/24" + instance_type = "VPC" + instance_region_id = "cn-beijing" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" +} + +resource "volcengine_cen_route_entry" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "192.168.17.0/24" + instance_type = "VPC" + instance_region_id = "cn-beijing" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" +} \ No newline at end of file diff --git a/example/cenServiceRouteEntry/main.tf b/example/cenServiceRouteEntry/main.tf new file mode 100644 index 00000000..fc716acc --- /dev/null +++ b/example/cenServiceRouteEntry/main.tf @@ -0,0 +1,56 @@ +resource "volcengine_cen_service_route_entry" "foo" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/11" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} + +resource "volcengine_cen_service_route_entry" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/10" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} + +resource "volcengine_cen_service_route_entry" "foo2" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/12" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} \ No newline at end of file diff --git a/example/dataCenRouteEntries/main.tf b/example/dataCenRouteEntries/main.tf index 9707fd0b..418973dc 100644 --- a/example/dataCenRouteEntries/main.tf +++ b/example/dataCenRouteEntries/main.tf @@ -1,3 +1,3 @@ data "volcengine_cen_route_entries" "foo" { - cen_id = "cen-12bjcqtr8ah3417q7y38h8t79" + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" } \ No newline at end of file diff --git a/example/dataCenServiceRouteEntries/main.tf b/example/dataCenServiceRouteEntries/main.tf new file mode 100644 index 00000000..ddf3f7e9 --- /dev/null +++ b/example/dataCenServiceRouteEntries/main.tf @@ -0,0 +1,3 @@ +data "volcengine_cen_service_route_entries" "default" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" +} \ No newline at end of file diff --git a/example/vpnGateway/main.tf b/example/vpnGateway/main.tf index 7b74fec7..ad3e70b6 100644 --- a/example/vpnGateway/main.tf +++ b/example/vpnGateway/main.tf @@ -5,6 +5,5 @@ resource "volcengine_vpn_gateway" "foo" { vpn_gateway_name = "tf-test" description = "tf-test" period = 2 - period_unit = "Year" project_name = "default" } \ No newline at end of file diff --git a/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go b/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go index 3d947f27..0353eca0 100644 --- a/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go +++ b/volcengine/autoscaling/scaling_configuration/service_volcengine_scaling_configuration.go @@ -257,15 +257,12 @@ func (s *VolcengineScalingConfigurationService) ModifyResource(resourceData *sch } if d.HasChange("tags") { if tags, ok := d.GetOk("tags"); ok { - logger.DebugInfo(logger.ReqFormat, "测试", tags) tagMap := map[string]interface{}{} for _, v := range tags.(*schema.Set).List() { - logger.DebugInfo(logger.ReqFormat, "测试", v) if vMap, ok := v.(map[string]interface{}); ok { tagMap[vMap["key"].(string)] = vMap["value"] } } - logger.DebugInfo(logger.ReqFormat, "测试", tagMap) if tagsStr, err := json.Marshal(tagMap); err != nil { return false, err } else { diff --git a/volcengine/autoscaling/scaling_configuration_attachment/resource_volcengine_scaling_configuration_attachment.go b/volcengine/autoscaling/scaling_configuration_attachment/resource_volcengine_scaling_configuration_attachment.go index 678de511..2c3db4a1 100644 --- a/volcengine/autoscaling/scaling_configuration_attachment/resource_volcengine_scaling_configuration_attachment.go +++ b/volcengine/autoscaling/scaling_configuration_attachment/resource_volcengine_scaling_configuration_attachment.go @@ -12,6 +12,7 @@ import ( Import Scaling Configuration attachment can be imported using the scaling_configuration_id e.g. +The launch template and scaling configuration cannot take effect at the same time. ``` $ terraform import volcengine_scaling_configuration_attachment.default enable:scc-ybrurj4uw6gh9zecj327 ``` diff --git a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go index 90bb1292..b510f673 100644 --- a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go +++ b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go @@ -39,16 +39,16 @@ func ResourceVolcengineCenBandwidthPackage() *schema.Resource { Optional: true, ForceNew: true, Default: "China", - ValidateFunc: validation.StringInSlice([]string{"China"}, false), - Description: "The local geographic region set id of the cen bandwidth package.", + ValidateFunc: validation.StringInSlice([]string{"China", "Asia"}, false), + Description: "The local geographic region set id of the cen bandwidth package. Valid value: `China`, `Asia`.", }, "peer_geographic_region_set_id": { Type: schema.TypeString, Optional: true, ForceNew: true, Default: "China", - ValidateFunc: validation.StringInSlice([]string{"China"}, false), - Description: "The peer geographic region set id of the cen bandwidth package.", + ValidateFunc: validation.StringInSlice([]string{"China", "Asia"}, false), + Description: "The peer geographic region set id of the cen bandwidth package. Valid value: `China`, `Asia`.", }, "bandwidth": { Type: schema.TypeInt, diff --git a/volcengine/cen/cen_route_entry/service_volcengine_cen_route_entry.go b/volcengine/cen/cen_route_entry/service_volcengine_cen_route_entry.go index 7e861099..ce2ab714 100644 --- a/volcengine/cen/cen_route_entry/service_volcengine_cen_route_entry.go +++ b/volcengine/cen/cen_route_entry/service_volcengine_cen_route_entry.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ve "github.com/volcengine/terraform-provider-volcengine/common" "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/cen/cen" ) type VolcengineCenRouteEntryService struct { @@ -158,6 +159,16 @@ func (s *VolcengineCenRouteEntryService) CreateResource(resourceData *schema.Res Target: []string{"Available"}, Timeout: resourceData.Timeout(schema.TimeoutCreate), }, + LockId: func(d *schema.ResourceData) string { + return d.Get("cen_id").(string) + }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + cen.NewCenService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("cen_id").(string), + }, + }, }, } return []ve.Callback{callback} @@ -204,6 +215,9 @@ func (s *VolcengineCenRouteEntryService) RemoveResource(resourceData *schema.Res return resource.RetryableError(callErr) }) }, + LockId: func(d *schema.ResourceData) string { + return d.Get("cen_id").(string) + }, }, } return []ve.Callback{callback} diff --git a/volcengine/cen/cen_service_route_entry/data_source_volcengine_cen_service_route_entries.go b/volcengine/cen/cen_service_route_entry/data_source_volcengine_cen_service_route_entries.go index 9ad942b8..23653b47 100644 --- a/volcengine/cen/cen_service_route_entry/data_source_volcengine_cen_service_route_entries.go +++ b/volcengine/cen/cen_service_route_entry/data_source_volcengine_cen_service_route_entries.go @@ -83,6 +83,35 @@ func DataSourceVolcengineCenServiceRouteEntries() *schema.Resource { Computed: true, Description: "The description of the cen service route entry.", }, + "publish_mode": { + Type: schema.TypeString, + Computed: true, + Description: "Publishing scope of cloud service access routes. Valid values are `LocalDCGW`(default), `Custom`.", + }, + "publish_to_instances": { + Type: schema.TypeList, + Computed: true, + Description: "The publish instances. A maximum of 100 can be uploaded in one request.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "instance_region_id": { + Type: schema.TypeString, + Computed: true, + Description: "The region where the cloud service access route needs to be published.", + }, + "instance_type": { + Type: schema.TypeString, + Computed: true, + Description: "The network instance type that needs to be published for cloud service access routes. The values are as follows: `VPC`, `DCGW`.", + }, + "instance_id": { + Type: schema.TypeString, + Computed: true, + Description: "Cloud service access routes need to publish the network instance ID.", + }, + }, + }, + }, }, }, }, diff --git a/volcengine/cen/cen_service_route_entry/resource_volcengine_cen_service_route_entry.go b/volcengine/cen/cen_service_route_entry/resource_volcengine_cen_service_route_entry.go index b1434b50..9c8f4ce2 100644 --- a/volcengine/cen/cen_service_route_entry/resource_volcengine_cen_service_route_entry.go +++ b/volcengine/cen/cen_service_route_entry/resource_volcengine_cen_service_route_entry.go @@ -22,6 +22,7 @@ $ terraform import volcengine_cen_service_route_entry.default cen-2nim00ybaylts7 func ResourceVolcengineCenServiceRouteEntry() *schema.Resource { resource := &schema.Resource{ Create: resourceVolcengineCenServiceRouteEntryCreate, + Update: resourceVolcengineCenServiceRouteEntryUpdate, Read: resourceVolcengineCenServiceRouteEntryRead, Delete: resourceVolcengineCenServiceRouteEntryDelete, Importer: &schema.ResourceImporter{ @@ -29,6 +30,7 @@ func ResourceVolcengineCenServiceRouteEntry() *schema.Resource { }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, Schema: map[string]*schema.Schema{ @@ -61,9 +63,47 @@ func ResourceVolcengineCenServiceRouteEntry() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: true, Description: "The description of the cen service route entry.", }, + "publish_mode": { + Type: schema.TypeString, + Optional: true, + Default: "LocalDCGW", + ValidateFunc: validation.StringInSlice([]string{ + "LocalDCGW", + "Custom", + }, false), + Description: "Publishing scope of cloud service access routes. Valid values are `LocalDCGW`(default), `Custom`.", + }, + "publish_to_instances": { + Type: schema.TypeList, + Optional: true, + MaxItems: 100, + Description: "The publish instances. A maximum of 100 can be uploaded in one request. This field needs to be filled in when the `publish_mode` is `Custom`.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "instance_region_id": { + Type: schema.TypeString, + Optional: true, + Description: "The region where the cloud service access route needs to be published.", + }, + "instance_type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "VPC", + "DCGW", + }, false), + Description: "The network instance type that needs to be published for cloud service access routes. The values are as follows: `VPC`, `DCGW`.", + }, + "instance_id": { + Type: schema.TypeString, + Optional: true, + Description: "Cloud service access routes need to publish the network instance ID.", + }, + }, + }, + }, }, } s := DataSourceVolcengineCenServiceRouteEntries().Schema["service_route_entries"].Elem.(*schema.Resource).Schema @@ -89,6 +129,15 @@ func resourceVolcengineCenServiceRouteEntryRead(d *schema.ResourceData, meta int return err } +func resourceVolcengineCenServiceRouteEntryUpdate(d *schema.ResourceData, meta interface{}) (err error) { + service := NewCenServiceRouteEntryService(meta.(*ve.SdkClient)) + err = ve.DefaultDispatcher().Update(service, d, ResourceVolcengineCenServiceRouteEntry()) + if err != nil { + return fmt.Errorf("error on updating cen service route entry %q, %s", d.Id(), err) + } + return resourceVolcengineCenServiceRouteEntryRead(d, meta) +} + func resourceVolcengineCenServiceRouteEntryDelete(d *schema.ResourceData, meta interface{}) (err error) { service := NewCenServiceRouteEntryService(meta.(*ve.SdkClient)) err = ve.DefaultDispatcher().Delete(service, d, ResourceVolcengineCenServiceRouteEntry()) diff --git a/volcengine/cen/cen_service_route_entry/service_volcengine_cen_service_route_entry.go b/volcengine/cen/cen_service_route_entry/service_volcengine_cen_service_route_entry.go index eb703c9c..479488e7 100644 --- a/volcengine/cen/cen_service_route_entry/service_volcengine_cen_service_route_entry.go +++ b/volcengine/cen/cen_service_route_entry/service_volcengine_cen_service_route_entry.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ve "github.com/volcengine/terraform-provider-volcengine/common" "github.com/volcengine/terraform-provider-volcengine/logger" + "github.com/volcengine/terraform-provider-volcengine/volcengine/cen/cen" ) type VolcengineCenServiceRouteEntryService struct { @@ -140,6 +141,11 @@ func (s *VolcengineCenServiceRouteEntryService) CreateResource(resourceData *sch Call: ve.SdkCall{ Action: "CreateCenServiceRouteEntry", ConvertMode: ve.RequestConvertAll, + Convert: map[string]ve.RequestConvert{ + "publish_to_instances": { + ConvertType: ve.ConvertListN, + }, + }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { return true, nil }, @@ -157,6 +163,16 @@ func (s *VolcengineCenServiceRouteEntryService) CreateResource(resourceData *sch Target: []string{"Available"}, Timeout: resourceData.Timeout(schema.TimeoutCreate), }, + LockId: func(d *schema.ResourceData) string { + return d.Get("cen_id").(string) + }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + cen.NewCenService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("cen_id").(string), + }, + }, }, } return []ve.Callback{callback} @@ -164,7 +180,60 @@ func (s *VolcengineCenServiceRouteEntryService) CreateResource(resourceData *sch } func (s *VolcengineCenServiceRouteEntryService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { - return []ve.Callback{} + callback := ve.Callback{ + Call: ve.SdkCall{ + Action: "ModifyCenServiceRouteEntryAttributes", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "cen_id": { + ForceGet: true, + }, + "destination_cidr_block": { + ForceGet: true, + }, + "service_region_id": { + ForceGet: true, + }, + "description": { + ConvertType: ve.ConvertDefault, + }, + "publish_mode": { + ForceGet: true, + ConvertType: ve.ConvertDefault, + }, + "publish_to_instances": { + ForceGet: true, + ConvertType: ve.ConvertListN, + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + mode := d.Get("publish_mode").(string) + instances := d.Get("publish_to_instances").([]interface{}) + if mode == "Custom" && len(instances) == 0 { + return false, fmt.Errorf("public_to_instances must exist when publish_mode is Custom") + } + return true, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + Refresh: &ve.StateRefresh{ + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + }, + LockId: func(d *schema.ResourceData) string { + return d.Get("cen_id").(string) + }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + cen.NewCenService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("cen_id").(string), + }, + }, + }, + } + return []ve.Callback{callback} } func (s *VolcengineCenServiceRouteEntryService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -203,6 +272,9 @@ func (s *VolcengineCenServiceRouteEntryService) RemoveResource(resourceData *sch AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { return ve.CheckResourceUtilRemoved(d, s.ReadResource, 5*time.Minute) }, + LockId: func(d *schema.ResourceData) string { + return d.Get("cen_id").(string) + }, }, } return []ve.Callback{callback} diff --git a/volcengine/provider.go b/volcengine/provider.go index eec86fab..7bfdb627 100644 --- a/volcengine/provider.go +++ b/volcengine/provider.go @@ -1,6 +1,7 @@ package volcengine import ( + "github.com/volcengine/terraform-provider-volcengine/volcengine/cen/cen_service_route_entry" "strings" "github.com/volcengine/terraform-provider-volcengine/volcengine/rds/rds_parameter_template" @@ -279,8 +280,8 @@ func Provider() terraform.ResourceProvider { "volcengine_cen_attach_instances": cen_attach_instance.DataSourceVolcengineCenAttachInstances(), "volcengine_cen_bandwidth_packages": cen_bandwidth_package.DataSourceVolcengineCenBandwidthPackages(), "volcengine_cen_inter_region_bandwidths": cen_inter_region_bandwidth.DataSourceVolcengineCenInterRegionBandwidths(), - //"volcengine_cen_service_route_entries": cen_service_route_entry.DataSourceVolcengineCenServiceRouteEntries(), - "volcengine_cen_route_entries": cen_route_entry.DataSourceVolcengineCenRouteEntries(), + "volcengine_cen_service_route_entries": cen_service_route_entry.DataSourceVolcengineCenServiceRouteEntries(), + "volcengine_cen_route_entries": cen_route_entry.DataSourceVolcengineCenRouteEntries(), // ================ VPN ================ "volcengine_vpn_gateways": vpn_gateway.DataSourceVolcengineVpnGateways(), @@ -450,8 +451,8 @@ func Provider() terraform.ResourceProvider { "volcengine_cen_bandwidth_package": cen_bandwidth_package.ResourceVolcengineCenBandwidthPackage(), "volcengine_cen_bandwidth_package_associate": cen_bandwidth_package_associate.ResourceVolcengineCenBandwidthPackageAssociate(), "volcengine_cen_inter_region_bandwidth": cen_inter_region_bandwidth.ResourceVolcengineCenInterRegionBandwidth(), - //"volcengine_cen_service_route_entry": cen_service_route_entry.ResourceVolcengineCenServiceRouteEntry(), - //"volcengine_cen_route_entry": cen_route_entry.ResourceVolcengineCenRouteEntry(), + "volcengine_cen_service_route_entry": cen_service_route_entry.ResourceVolcengineCenServiceRouteEntry(), + "volcengine_cen_route_entry": cen_route_entry.ResourceVolcengineCenRouteEntry(), // ================ VPN ================ "volcengine_vpn_gateway": vpn_gateway.ResourceVolcengineVpnGateway(), From 5f7a7344ab37c8f2875bc0b9c1f45efe1083ac15 Mon Sep 17 00:00:00 2001 From: "maoshuai.17" Date: Wed, 5 Jul 2023 22:59:53 +0800 Subject: [PATCH 05/10] feat: opt clb, nat, eip --- example/eipAddress/main.tf | 4 +- example/natGateway/main.tf | 1 + .../clb/clb/data_source_volcengine_clbs.go | 55 ++++- volcengine/clb/clb/resource_volcengine_clb.go | 29 ++- volcengine/clb/clb/service_volcengine_clb.go | 228 ++++++++++++++++-- .../common_volcengine_eip_address.go | 11 + .../resource_volcengine_eip_address.go | 69 +++++- .../service_volcengine_eip_address.go | 45 +++- .../resource_volcengine_eip_associate.go | 14 +- .../resource_volcengine_nat_gateway.go | 59 +++-- .../service_volcengine_nat_gateway.go | 62 +++-- 11 files changed, 474 insertions(+), 103 deletions(-) diff --git a/example/eipAddress/main.tf b/example/eipAddress/main.tf index 8bbef442..27e5ae5f 100644 --- a/example/eipAddress/main.tf +++ b/example/eipAddress/main.tf @@ -2,7 +2,7 @@ resource "volcengine_eip_address" "foo" { billing_type = "PostPaidByBandwidth" bandwidth = 1 isp = "ChinaUnicom" - name = "tf-project-1" + name = "tf-eip" description = "tf-test" - project_name = "yuwenhao" + project_name = "default" } \ No newline at end of file diff --git a/example/natGateway/main.tf b/example/natGateway/main.tf index bf6d0317..a977ce75 100644 --- a/example/natGateway/main.tf +++ b/example/natGateway/main.tf @@ -3,6 +3,7 @@ resource "volcengine_nat_gateway" "foo" { subnet_id = "subnet-im67x70vxla88gbssz1hy1z2" spec = "Medium" nat_gateway_name = "tf-auto-demo-1" + billing_type = "PostPaid" description = "This nat gateway auto-created by terraform. " project_name = "default" } \ No newline at end of file diff --git a/volcengine/clb/clb/data_source_volcengine_clbs.go b/volcengine/clb/clb/data_source_volcengine_clbs.go index 80eaa437..b1066594 100644 --- a/volcengine/clb/clb/data_source_volcengine_clbs.go +++ b/volcengine/clb/clb/data_source_volcengine_clbs.go @@ -154,16 +154,6 @@ func DataSourceVolcengineClbs() *schema.Resource { Computed: true, Description: "The reason why Clb is locked.", }, - "overdue_time": { - Type: schema.TypeString, - Computed: true, - Description: "The overdue time of the Clb.", - }, - "deleted_time": { - Type: schema.TypeString, - Computed: true, - Description: "The expected recycle time of the Clb.", - }, "load_balancer_spec": { Type: schema.TypeString, Computed: true, @@ -190,6 +180,51 @@ func DataSourceVolcengineClbs() *schema.Resource { Computed: true, Description: "The slave zone ID of the CLB.", }, + "renew_type": { + Type: schema.TypeString, + Computed: true, + Description: "The renew type of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", + }, + "renew_period_times": { + Type: schema.TypeInt, + Computed: true, + Description: "The renew period times of the CLB. When the value of the renew_type is `AutoRenew`, the query returns this field.", + }, + "remain_renew_times": { + Type: schema.TypeInt, + Computed: true, + Description: "The remain renew times of the CLB. When the value of the renew_type is `AutoRenew`, the query returns this field.", + }, + "instance_status": { + Type: schema.TypeInt, + Computed: true, + Description: "The billing status of the CLB.", + }, + "expired_time": { + Type: schema.TypeString, + Computed: true, + Description: "The expired time of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", + }, + "reclaim_time": { + Type: schema.TypeString, + Computed: true, + Description: "The reclaim time of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", + }, + "overdue_time": { + Type: schema.TypeString, + Computed: true, + Description: "The overdue time of the Clb. When the value of the load_balancer_billing_type is `PostPaid`, the query returns this field.", + }, + "overdue_reclaim_time": { + Type: schema.TypeString, + Computed: true, + Description: "The over reclaim time of the CLB. When the value of the load_balancer_billing_type is `PostPaid`, the query returns this field.", + }, + "deleted_time": { + Type: schema.TypeString, + Computed: true, + Description: "The expected recycle time of the Clb.", + }, }, }, }, diff --git a/volcengine/clb/clb/resource_volcengine_clb.go b/volcengine/clb/clb/resource_volcengine_clb.go index b6d82d26..06abb49b 100644 --- a/volcengine/clb/clb/resource_volcengine_clb.go +++ b/volcengine/clb/clb/resource_volcengine_clb.go @@ -91,8 +91,11 @@ func ResourceVolcengineClb() *schema.Resource { Description: "The reason of the console modification protection.", }, "load_balancer_spec": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + "small_1", "small_2", "medium_1", "medium_2", "large_1", "large_2", + }, false), Description: "The specification of the CLB, the value can be `small_1`, `small_2`, `medium_1`, `medium_2`, `large_1`, `large_2`.", }, "load_balancer_billing_type": { @@ -100,8 +103,26 @@ func ResourceVolcengineClb() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - Description: "The billing type of the CLB, the value can be `PostPaid`.", - ValidateFunc: validation.StringInSlice([]string{"PostPaid"}, false), + Description: "The billing type of the CLB, the value can be `PostPaid` or `PrePaid`.", + ValidateFunc: validation.StringInSlice([]string{"PostPaid", "PrePaid"}, false), + }, + "period": { + Type: schema.TypeInt, + Optional: true, + Default: 12, + ValidateFunc: validation.Any( + validation.IntBetween(1, 9), + validation.IntInSlice([]int{12, 24, 36})), + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return !(d.Get("load_balancer_billing_type").(string) == "PrePaid") + }, + Description: "The period of the NatGateway, the valid value range in 1~9 or 12 or 24 or 36. Default value is 12. The period unit defaults to `Month`." + + "This field is only effective when creating a PrePaid NatGateway. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", + }, + "renew_type": { + Type: schema.TypeString, + Computed: true, + Description: "The renew type of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", }, "project_name": { Type: schema.TypeString, diff --git a/volcengine/clb/clb/service_volcengine_clb.go b/volcengine/clb/clb/service_volcengine_clb.go index 72755dd4..08148b0d 100644 --- a/volcengine/clb/clb/service_volcengine_clb.go +++ b/volcengine/clb/clb/service_volcengine_clb.go @@ -31,7 +31,7 @@ func (s *VolcengineClbService) ReadResources(condition map[string]interface{}) ( results interface{} ok bool ) - return ve.WithPageNumberQuery(condition, "PageSize", "PageNumber", 20, 1, func(m map[string]interface{}) ([]interface{}, error) { + data, err = ve.WithPageNumberQuery(condition, "PageSize", "PageNumber", 20, 1, func(m map[string]interface{}) ([]interface{}, error) { clb := s.Client.ClbClient action := "DescribeLoadBalancers" logger.Debug(logger.ReqFormat, action, condition) @@ -59,6 +59,51 @@ func (s *VolcengineClbService) ReadResources(condition map[string]interface{}) ( } return data, err }) + if err != nil { + return data, err + } + + for _, value := range data { + clb, ok := value.(map[string]interface{}) + if !ok { + return data, fmt.Errorf(" Clb is not map ") + } + + action := "DescribeLoadBalancersBilling" + req := map[string]interface{}{ + "LoadBalancerIds.1": clb["LoadBalancerId"], + } + logger.Debug(logger.ReqFormat, action, condition) + resp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(action), &req) + if err != nil { + return data, err + } + logger.Debug(logger.RespFormat, action, *resp) + + billingConfigs, err := ve.ObtainSdkValue("Result.LoadBalancerBillingConfigs", *resp) + if err != nil { + return data, err + } + if billingConfigs == nil { + return data, fmt.Errorf(" DescribeLoadBalancersBilling error ") + } + configs, ok := billingConfigs.([]interface{}) + if !ok { + return data, fmt.Errorf(" Result.LoadBalancerBillingConfigs is not slice ") + } + if len(configs) == 0 { + return data, fmt.Errorf("LoadBalancerBilling of the clb instance %s is not exist ", clb["LoadBalancerId"]) + } + config, ok := configs[0].(map[string]interface{}) + if !ok { + return data, fmt.Errorf(" BillingConfigs is not map ") + } + for k, v := range config { + clb[k] = v + } + } + + return data, err } func (s *VolcengineClbService) ReadResource(resourceData *schema.ResourceData, clbId string) (data map[string]interface{}, err error) { @@ -143,6 +188,24 @@ func (VolcengineClbService) WithResourceResponseHandlers(clb map[string]interfac return i }, }, + "RenewType": { + TargetField: "renew_type", + Convert: func(i interface{}) interface{} { + if i == nil { + return nil + } + renewType := i.(float64) + switch renewType { + case 1: + return "ManualRenew" + case 2: + return "AutoRenew" + case 3: + return "NoneRenew" + } + return i + }, + }, }, nil } return []ve.ResourceResponseHandler{handler} @@ -182,6 +245,11 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, } else if regionId.(string) != *s.Client.ClbClient.Config.Region { return false, fmt.Errorf("region_id is not equal to provider region config(%s)", *s.Client.ClbClient.Config.Region) } + + // PeriodUnit 默认传 Month + if (*call.SdkParam)["LoadBalancerBillingType"] == 1 { + (*call.SdkParam)["PeriodUnit"] = "Month" + } return true, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { @@ -208,26 +276,25 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { var callbacks []ve.Callback - callback := ve.Callback{ + attributesCallback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyLoadBalancerAttributes", - ConvertMode: ve.RequestConvertAll, + ConvertMode: ve.RequestConvertInConvert, Convert: map[string]ve.RequestConvert{ - "load_balancer_billing_type": { - TargetField: "LoadBalancerBillingType", - Convert: func(data *schema.ResourceData, i interface{}) interface{} { - if i == nil { - return nil - } - billingType := i.(string) - switch billingType { - case "PrePaid": - return 1 - case "PostPaid": - return 2 - } - return i - }, + "load_balancer_name": { + TargetField: "LoadBalancerName", + }, + "description": { + TargetField: "Description", + }, + "modification_protection_status": { + TargetField: "ModificationProtectionStatus", + }, + "modification_protection_reason": { + TargetField: "ModificationProtectionReason", + }, + "load_balancer_spec": { + TargetField: "LoadBalancerSpec", }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { @@ -242,11 +309,103 @@ func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, }, Refresh: &ve.StateRefresh{ Target: []string{"Active"}, - Timeout: resourceData.Timeout(schema.TimeoutCreate), + Timeout: resourceData.Timeout(schema.TimeoutUpdate), }, }, } - callbacks = append(callbacks, callback) + callbacks = append(callbacks, attributesCallback) + + if resourceData.HasChange("load_balancer_billing_type") { + billingTypeCallback := ve.Callback{ + Call: ve.SdkCall{ + Action: "ConvertLoadBalancerBillingType", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "load_balancer_billing_type": { + TargetField: "LoadBalancerBillingType", + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + if i == nil { + return nil + } + billingType := i.(string) + switch billingType { + case "PrePaid": + return 1 + case "PostPaid": + return 2 + } + return i + }, + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if len(*call.SdkParam) > 0 { + (*call.SdkParam)["LoadBalancerId"] = d.Id() + if (*call.SdkParam)["LoadBalancerBillingType"].(int) == 2 { + return true, nil + } else { + // PeriodUnit 默认传 Month + (*call.SdkParam)["PeriodUnit"] = "Month" + (*call.SdkParam)["Period"] = d.Get("period") + } + return true, nil + } + return false, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + //修改 clb 计费类型 + return s.Client.ClbClient.ModifyLoadBalancerAttributesCommon(call.SdkParam) + }, + Refresh: &ve.StateRefresh{ + Target: []string{"Active"}, + Timeout: resourceData.Timeout(schema.TimeoutUpdate), + }, + }, + } + callbacks = append(callbacks, billingTypeCallback) + } else if resourceData.Get("renew_type").(string) == "ManualRenew" && resourceData.HasChange("period") { + renewCallback := ve.Callback{ + Call: ve.SdkCall{ + Action: "RenewLoadBalancer", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "period": { + TargetField: "Period", + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + o, n := data.GetChange("period") + return n.(int) - o.(int) + }, + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if len(*call.SdkParam) > 0 { + if (*call.SdkParam)["Period"].(int) <= 0 { + return false, fmt.Errorf("period can only be enlarged ") + } + + // PeriodUnit 默认传 Month + (*call.SdkParam)["PeriodUnit"] = "Month" + (*call.SdkParam)["LoadBalancerId"] = d.Id() + return true, nil + } + return false, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + return nil + }, + Refresh: &ve.StateRefresh{ + Target: []string{"Active"}, + Timeout: resourceData.Timeout(schema.TimeoutUpdate), + }, + }, + } + callbacks = append(callbacks, renewCallback) + } // 更新Tags setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "CLB", resourceData, getUniversalInfo) @@ -338,6 +497,24 @@ func (s *VolcengineClbService) DatasourceResources(*schema.ResourceData, *schema return i }, }, + "RenewType": { + TargetField: "renew_type", + Convert: func(i interface{}) interface{} { + if i == nil { + return nil + } + renewType := i.(float64) + switch renewType { + case 1: + return "ManualRenew" + case 2: + return "AutoRenew" + case 3: + return "NoneRenew" + } + return i + }, + }, }, } } @@ -364,3 +541,14 @@ func (s *VolcengineClbService) ProjectTrn() *ve.ProjectTrn { ProjectSchemaField: "project_name", } } + +func (s *VolcengineClbService) UnsubscribeInfo(resourceData *schema.ResourceData, resource *schema.Resource) (*ve.UnsubscribeInfo, error) { + info := ve.UnsubscribeInfo{ + InstanceId: s.ReadResourceId(resourceData.Id()), + } + if resourceData.Get("load_balancer_billing_type") == "PrePaid" { + info.Products = []string{"CLB"} + info.NeedUnsubscribe = true + } + return &info, nil +} diff --git a/volcengine/eip/eip_address/common_volcengine_eip_address.go b/volcengine/eip/eip_address/common_volcengine_eip_address.go index 3d344788..7696037f 100644 --- a/volcengine/eip/eip_address/common_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/common_volcengine_eip_address.go @@ -36,6 +36,17 @@ var billingTypeResponseConvert = func(i interface{}) interface{} { return ty } +//func periodUnitRequestConvert(value interface{}) interface{} { +// ty := 0 +// switch value.(string) { +// case "Month": +// ty = 1 +// case "Year": +// ty = 2 +// } +// return ty +//} + func RemoveSystemTags(data []interface{}) ([]interface{}, error) { var ( ok bool diff --git a/volcengine/eip/eip_address/resource_volcengine_eip_address.go b/volcengine/eip/eip_address/resource_volcengine_eip_address.go index e030f4cf..da01b758 100644 --- a/volcengine/eip/eip_address/resource_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/resource_volcengine_eip_address.go @@ -37,8 +37,54 @@ func ResourceVolcengineEipAddress() *schema.Resource { "billing_type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"PostPaidByBandwidth", "PostPaidByTraffic"}, false), - Description: "The billing type of the EIP Address. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic`.", + ValidateFunc: validation.StringInSlice([]string{"PrePaid", "PostPaidByBandwidth", "PostPaidByTraffic"}, false), + Description: "The billing type of the EIP Address. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`.", + }, + //"period_unit": { + // Type: schema.TypeString, + // Optional: true, + // Default: "Month", + // ValidateFunc: validation.StringInSlice([]string{ + // "Month", "Year", + // }, false), + // DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + // // 创建时,只有付费类型为 PrePaid 时生效 + // if d.Id() == "" { + // if d.Get("billing_type").(string) == "PrePaid" { + // return false + // } + // } else { // 修改时,只有付费类型由按量付费转为 PrePaid 时生效 + // if d.HasChange("billing_type") && d.Get("billing_type").(string) == "PrePaid" { + // return false + // } + // } + // return true + // }, + // Description: "The period unit of the EIP Address. Optional choice contains `Month` or `Year`. Default is `Month`." + + // "This field is only effective when creating a PrePaid Eip or changing the billing_type from PostPaid to PrePaid.", + //}, + "period": { + Type: schema.TypeInt, + Optional: true, + Default: 12, + ValidateFunc: validation.Any( + validation.IntBetween(1, 9), + validation.IntInSlice([]int{12, 36})), + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + // 创建时,只有付费类型为 PrePaid 时生效 + if d.Id() == "" { + if d.Get("billing_type").(string) == "PrePaid" { + return false + } + } else { // 修改时,只有付费类型由按量付费转为 PrePaid 时生效 + if d.HasChange("billing_type") && d.Get("billing_type").(string) == "PrePaid" { + return false + } + } + return true + }, + Description: "The period of the EIP Address, the valid value range in 1~9 or 12 or 36. Default value is 12. The period unit defaults to `Month`." + + "This field is only effective when creating a PrePaid Eip or changing the billing_type from PostPaid to PrePaid.", }, "bandwidth": { Type: schema.TypeInt, @@ -51,8 +97,8 @@ func ResourceVolcengineEipAddress() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - Description: "The ISP of the EIP, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom`.", - ValidateFunc: validation.StringInSlice([]string{"BGP", "ChinaMobile", "ChinaUnicom", "ChinaTelecom"}, false), + Description: "The ISP of the EIP, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom` or `SingleLine_BGP` or `Static_BGP`.", + ValidateFunc: validation.StringInSlice([]string{"BGP", "ChinaMobile", "ChinaUnicom", "ChinaTelecom", "SingleLine_BGP", "Static_BGP"}, false), }, "name": { Type: schema.TypeString, @@ -81,6 +127,21 @@ func ResourceVolcengineEipAddress() *schema.Resource { Computed: true, Description: "The ip address of the EIP.", }, + "overdue_time": { + Type: schema.TypeString, + Computed: true, + Description: "The overdue time of the EIP.", + }, + "deleted_time": { + Type: schema.TypeString, + Computed: true, + Description: "The deleted time of the EIP.", + }, + "expired_time": { + Type: schema.TypeString, + Computed: true, + Description: "The expired time of the EIP.", + }, }, } } diff --git a/volcengine/eip/eip_address/service_volcengine_eip_address.go b/volcengine/eip/eip_address/service_volcengine_eip_address.go index 7b1de82c..9e3e0028 100644 --- a/volcengine/eip/eip_address/service_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/service_volcengine_eip_address.go @@ -85,9 +85,6 @@ func (s *VolcengineEipAddressService) ReadResource(resourceData *schema.Resource if len(data) == 0 { return data, fmt.Errorf("eip address %s not exist ", allocationId) } - if data["BillingType"].(float64) == 1 { - return data, fmt.Errorf("not support PrePaid eip address") - } return data, err } @@ -154,6 +151,19 @@ func (s *VolcengineEipAddressService) CreateResource(resourceData *schema.Resour Call: ve.SdkCall{ Action: "AllocateEipAddress", ConvertMode: ve.RequestConvertAll, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + //periodUnit, ok := (*call.SdkParam)["PeriodUnit"] + //if !ok { + // return true, nil + //} + //(*call.SdkParam)["PeriodUnit"] = periodUnitRequestConvert(periodUnit) + + // PeriodUnit 默认传 1(Month) + if (*call.SdkParam)["BillingType"] == 1 { + (*call.SdkParam)["PeriodUnit"] = 1 + } + return true, nil + }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) return s.Client.VpcClient.AllocateEipAddressCommon(call.SdkParam) @@ -234,6 +244,17 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { if len(*call.SdkParam) > 0 { (*call.SdkParam)["AllocationId"] = d.Id() + if (*call.SdkParam)["BillingType"] == 1 { + //periodUnit, ok := d.GetOk("period_unit") + //if !ok { + // return false, fmt.Errorf("PeriodUnit is not exist") + //} + //(*call.SdkParam)["PeriodUnit"] = periodUnitRequestConvert(periodUnit) + + // PeriodUnit 默认传 1(Month) + (*call.SdkParam)["PeriodUnit"] = 1 + (*call.SdkParam)["Period"] = d.Get("period") + } return true, nil } return false, nil @@ -242,6 +263,13 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour logger.Debug(logger.ReqFormat, call.Action, call.SdkParam) return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) }, + AfterCall: func(d *schema.ResourceData, client *ve.SdkClient, resp *map[string]interface{}, call ve.SdkCall) error { + if d.Get("billing_type").(string) != "PrePaid" { + d.Set("period", nil) + //d.Set("period_unit", nil) + } + return nil + }, Refresh: &ve.StateRefresh{ Target: []string{"Available"}, Timeout: resourceData.Timeout(schema.TimeoutUpdate), @@ -360,3 +388,14 @@ func (s *VolcengineEipAddressService) ProjectTrn() *ve.ProjectTrn { ProjectSchemaField: "project_name", } } + +func (s *VolcengineEipAddressService) UnsubscribeInfo(resourceData *schema.ResourceData, resource *schema.Resource) (*ve.UnsubscribeInfo, error) { + info := ve.UnsubscribeInfo{ + InstanceId: s.ReadResourceId(resourceData.Id()), + } + if resourceData.Get("billing_type") == "PrePaid" { + info.Products = []string{"EIP"} + info.NeedUnsubscribe = true + } + return &info, nil +} diff --git a/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go b/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go index 2c00d125..ba8dc38a 100644 --- a/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go +++ b/volcengine/eip/eip_associate/resource_volcengine_eip_associate.go @@ -44,10 +44,16 @@ func ResourceVolcengineEipAssociate() *schema.Resource { Description: "The instance id which be associated to the EIP.", }, "instance_type": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - Description: "The type of the associated instance,the value is `NAT` or `NetworkInterface` or `ClbInstance` or `EcsInstance` or `HaVip`.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + if old == "Nat" && new == "NAT" { + return true + } + return false + }, + Description: "The type of the associated instance,the value is `Nat` or `NetworkInterface` or `ClbInstance` or `EcsInstance` or `HaVip`.", }, "private_ip_address": { Type: schema.TypeString, diff --git a/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go b/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go index e7e815a1..0d4d3b35 100644 --- a/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go +++ b/volcengine/nat/nat_gateway/resource_volcengine_nat_gateway.go @@ -47,8 +47,12 @@ func ResourceVolcengineNatGateway() *schema.Resource { Description: "The ID of the Subnet.", }, "spec": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeString, + Optional: true, + Default: "Small", + ValidateFunc: validation.StringInSlice([]string{ + "Small", "Medium", "Large", + }, false), Description: "The specification of the NatGateway. Optional choice contains `Small`(default), `Medium`, `Large`.", }, "nat_gateway_name": { @@ -66,8 +70,36 @@ func ResourceVolcengineNatGateway() *schema.Resource { Optional: true, ForceNew: true, Default: "PostPaid", - Description: "The billing type of the NatGateway, the value is `PostPaid`.", - ValidateFunc: validation.StringInSlice([]string{"PostPaid"}, false), + Description: "The billing type of the NatGateway, the value is `PostPaid` or `PrePaid`.", + ValidateFunc: validation.StringInSlice([]string{"PostPaid", "PrePaid"}, false), + }, + //"period_unit": { + // Type: schema.TypeString, + // Optional: true, + // Default: "Month", + // ForceNew: true, + // ValidateFunc: validation.StringInSlice([]string{ + // "Month", "Year", + // }, false), + // DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + // return !(d.Get("billing_type").(string) == "PrePaid") + // }, + // Description: "The period unit of the NatGateway. Optional choice contains `Month` or `Year`. Default is `Month`." + + // "This field is only effective when creating a PrePaid NatGateway. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", + //}, + "period": { + Type: schema.TypeInt, + Optional: true, + Default: 12, + ForceNew: true, + ValidateFunc: validation.Any( + validation.IntBetween(1, 9), + validation.IntInSlice([]int{12, 24, 36})), + DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { + return !(d.Get("billing_type").(string) == "PrePaid") + }, + Description: "The period of the NatGateway, the valid value range in 1~9 or 12 or 24 or 36. Default value is 12. The period unit defaults to `Month`." + + "This field is only effective when creating a PrePaid NatGateway. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields.", }, "tags": ve.TagsSchema(), "project_name": { @@ -75,25 +107,6 @@ func ResourceVolcengineNatGateway() *schema.Resource { Optional: true, Description: "The ProjectName of the NatGateway.", }, - //"period_unit": { - // Type: schema.TypeString, - // Optional: true, - // ForceNew: true, - // Description: "The period unit of the NatGateway.", - // ValidateFunc: validation.StringInSlice([]string{"Month", "Year"}, false), - // DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - // return d.Id() != "" - // }, - //}, - //"period": { - // Type: schema.TypeInt, - // Optional: true, - // ForceNew: true, - // Description: "The period of the NatGateway.", - // DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { - // return d.Id() != "" - // }, - //}, }, } } diff --git a/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go b/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go index fc85810c..76cf3292 100644 --- a/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go +++ b/volcengine/nat/nat_gateway/service_volcengine_nat_gateway.go @@ -64,9 +64,8 @@ func (s *VolcengineNatGatewayService) ReadResources(condition map[string]interfa func (s *VolcengineNatGatewayService) ReadResource(resourceData *schema.ResourceData, natGatewayId string) (data map[string]interface{}, err error) { var ( - results []interface{} - ok bool - billingType interface{} + results []interface{} + ok bool ) if natGatewayId == "" { natGatewayId = s.ReadResourceId(resourceData.Id()) @@ -87,20 +86,6 @@ func (s *VolcengineNatGatewayService) ReadResource(resourceData *schema.Resource return data, fmt.Errorf("NatGateway %s not exist ", natGatewayId) } - billingType, err = ve.ObtainSdkValue("BillingType", data) - if err != nil { - return data, err - } - - if billingType, ok = billingType.(float64); !ok { - return data, errors.New("BillingType is invalid") - } - - if billingType.(float64) == 1 { - // prepaid not support - return data, fmt.Errorf("Prepaid nat gateway %s is not supported ", natGatewayId) - } - return data, err } @@ -198,6 +183,13 @@ func (s *VolcengineNatGatewayService) CreateResource(resourceData *schema.Resour ConvertType: ve.ConvertListN, }, }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + // PeriodUnit 默认传 Month + if (*call.SdkParam)["BillingType"] == 1 { + (*call.SdkParam)["PeriodUnit"] = "Month" + } + return true, nil + }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //创建natGateway @@ -225,23 +217,16 @@ func (s *VolcengineNatGatewayService) ModifyResource(resourceData *schema.Resour callback := ve.Callback{ Call: ve.SdkCall{ Action: "ModifyNatGatewayAttributes", - ConvertMode: ve.RequestConvertAll, + ConvertMode: ve.RequestConvertInConvert, Convert: map[string]ve.RequestConvert{ - "billing_type": { - TargetField: "BillingType", - Convert: func(data *schema.ResourceData, i interface{}) interface{} { - if i == nil { - return nil - } - billingType := i.(string) - switch billingType { - case "PrePaid": - return 1 - case "PostPaid": - return 2 - } - return i - }, + "nat_gateway_name": { + TargetField: "NatGatewayName", + }, + "description": { + TargetField: "Description", + }, + "spec": { + TargetField: "Spec", }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { @@ -389,3 +374,14 @@ func (s *VolcengineNatGatewayService) ProjectTrn() *ve.ProjectTrn { ProjectSchemaField: "project_name", } } + +func (s *VolcengineNatGatewayService) UnsubscribeInfo(resourceData *schema.ResourceData, resource *schema.Resource) (*ve.UnsubscribeInfo, error) { + info := ve.UnsubscribeInfo{ + InstanceId: s.ReadResourceId(resourceData.Id()), + } + if resourceData.Get("billing_type") == "PrePaid" { + info.Products = []string{"NAT_Gateway"} + info.NeedUnsubscribe = true + } + return &info, nil +} From 9281803adffca4b4da07e7b819d10298c3944e63 Mon Sep 17 00:00:00 2001 From: "maoshuai.17" Date: Fri, 7 Jul 2023 10:34:46 +0800 Subject: [PATCH 06/10] feat: opt clb --- example/certificate/main.tf | 4 + example/clb/main.tf | 31 +++- .../data_source_volcengine_certificates.go | 2 + .../resource_volcengine_certificate.go | 5 +- .../service_volcengine_certificate.go | 60 +++++++- .../clb/clb/data_source_volcengine_clbs.go | 32 ++++- volcengine/clb/clb/resource_volcengine_clb.go | 49 ++++++- volcengine/clb/clb/service_volcengine_clb.go | 134 ++++++++++++++++-- .../listener/common_volcengine_listener.go | 6 + .../listener/resource_volcengine_listener.go | 12 ++ .../resource_volcengine_eip_address.go | 9 +- .../service_volcengine_eip_address.go | 4 +- 12 files changed, 322 insertions(+), 26 deletions(-) diff --git a/example/certificate/main.tf b/example/certificate/main.tf index 320a9b7a..39af19f0 100644 --- a/example/certificate/main.tf +++ b/example/certificate/main.tf @@ -3,4 +3,8 @@ resource "volcengine_certificate" "foo" { description = "This is a clb certificate" public_key = "public-key" private_key = "private-key" + tags { + key = "k1" + value = "v1" + } } \ No newline at end of file diff --git a/example/clb/main.tf b/example/clb/main.tf index d1481f40..7d007817 100644 --- a/example/clb/main.tf +++ b/example/clb/main.tf @@ -1,8 +1,37 @@ -resource "volcengine_clb" "foo" { +resource "volcengine_clb" "public_clb" { type = "public" subnet_id = "subnet-mj92ij84m5fk5smt1arvwrtw" load_balancer_spec = "small_1" description = "Demo" load_balancer_name = "terraform-auto-create" project_name = "yyy" + eip_billing_config { + isp = "BGP" + eip_billing_type = "PostPaidByBandwidth" + bandwidth = 1 + } +} + +resource "volcengine_clb" "private_clb" { + type = "private" + subnet_id = "subnet-mj92ij84m5fk5smt1arvwrtw" + load_balancer_spec = "small_1" + description = "Demo" + load_balancer_name = "terraform-auto-create" + project_name = "default" +} + +resource "volcengine_eip_address" "eip" { + billing_type = "PostPaidByBandwidth" + bandwidth = 1 + isp = "BGP" + name = "tf-eip" + description = "tf-test" + project_name = "default" +} + +resource "volcengine_eip_associate" "associate" { + allocation_id = volcengine_eip_address.eip.id + instance_id = volcengine_clb.private_clb.id + instance_type = "ClbInstance" } \ No newline at end of file diff --git a/volcengine/clb/certificate/data_source_volcengine_certificates.go b/volcengine/clb/certificate/data_source_volcengine_certificates.go index 83a12de6..97a61003 100644 --- a/volcengine/clb/certificate/data_source_volcengine_certificates.go +++ b/volcengine/clb/certificate/data_source_volcengine_certificates.go @@ -19,6 +19,7 @@ func DataSourceVolcengineCertificates() *schema.Resource { Set: schema.HashString, Description: "The list of Certificate IDs.", }, + "tags": ve.TagsSchema(), "name_regex": { Type: schema.TypeString, Optional: true, @@ -102,6 +103,7 @@ func DataSourceVolcengineCertificates() *schema.Resource { Computed: true, Description: "The ID list of the Listener.", }, + "tags": ve.TagsSchemaComputed(), }, }, }, diff --git a/volcengine/clb/certificate/resource_volcengine_certificate.go b/volcengine/clb/certificate/resource_volcengine_certificate.go index 955e3263..619328f6 100644 --- a/volcengine/clb/certificate/resource_volcengine_certificate.go +++ b/volcengine/clb/certificate/resource_volcengine_certificate.go @@ -22,19 +22,20 @@ func ResourceVolcengineCertificate() *schema.Resource { return &schema.Resource{ Create: resourceVolcengineCertificateCreate, Read: resourceVolcengineCertificateRead, + Update: resourceVolcengineCertificateUpdate, Delete: resourceVolcengineCertificateDelete, Importer: &schema.ResourceImporter{ State: schema.ImportStatePassthrough, }, Timeouts: &schema.ResourceTimeout{ Create: schema.DefaultTimeout(30 * time.Minute), + Update: schema.DefaultTimeout(30 * time.Minute), Delete: schema.DefaultTimeout(30 * time.Minute), }, Schema: map[string]*schema.Schema{ "certificate_name": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "The name of the Certificate.", }, "public_key": { @@ -52,7 +53,6 @@ func ResourceVolcengineCertificate() *schema.Resource { "description": { Type: schema.TypeString, Optional: true, - ForceNew: true, Description: "The description of the Certificate.", }, "project_name": { @@ -61,6 +61,7 @@ func ResourceVolcengineCertificate() *schema.Resource { ForceNew: true, Description: "The ProjectName of the Certificate.", }, + "tags": ve.TagsSchema(), }, } } diff --git a/volcengine/clb/certificate/service_volcengine_certificate.go b/volcengine/clb/certificate/service_volcengine_certificate.go index 621134e0..2ac8e9ff 100644 --- a/volcengine/clb/certificate/service_volcengine_certificate.go +++ b/volcengine/clb/certificate/service_volcengine_certificate.go @@ -104,6 +104,12 @@ func (s *VolcengineCertificateService) CreateResource(resourceData *schema.Resou Call: ve.SdkCall{ Action: "UploadCertificate", ConvertMode: ve.RequestConvertAll, + Convert: map[string]ve.RequestConvert{ + "tags": { + TargetField: "Tags", + ConvertType: ve.ConvertListN, + }, + }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //创建certificate @@ -122,7 +128,40 @@ func (s *VolcengineCertificateService) CreateResource(resourceData *schema.Resou } func (s *VolcengineCertificateService) ModifyResource(resourceData *schema.ResourceData, resource *schema.Resource) []ve.Callback { - return []ve.Callback{} + var callbacks []ve.Callback + + callback := ve.Callback{ + Call: ve.SdkCall{ + Action: "ModifyCertificateAttributes", + ConvertMode: ve.RequestConvertInConvert, + Convert: map[string]ve.RequestConvert{ + "certification_name": { + TargetField: "CertificationName", + }, + "description": { + TargetField: "Description", + }, + }, + BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { + if len(*call.SdkParam) > 0 { + (*call.SdkParam)["CertificateId"] = d.Id() + return true, nil + } + return false, nil + }, + ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { + logger.Debug(logger.RespFormat, call.Action, call.SdkParam) + return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) + }, + }, + } + callbacks = append(callbacks, callback) + + // 更新Tags + setResourceTagsCallbacks := ve.SetResourceTags(s.Client, "TagResources", "UntagResources", "Certificate", resourceData, getUniversalInfo) + callbacks = append(callbacks, setResourceTagsCallbacks...) + + return callbacks } func (s *VolcengineCertificateService) RemoveResource(resourceData *schema.ResourceData, r *schema.Resource) []ve.Callback { @@ -168,6 +207,15 @@ func (s *VolcengineCertificateService) DatasourceResources(*schema.ResourceData, TargetField: "CertificateIds", ConvertType: ve.ConvertWithN, }, + "tags": { + TargetField: "TagFilters", + ConvertType: ve.ConvertListN, + NextLevelConvert: map[string]ve.RequestConvert{ + "value": { + TargetField: "Values.1", + }, + }, + }, }, NameField: "CertificateName", IdField: "CertificateId", @@ -184,3 +232,13 @@ func (s *VolcengineCertificateService) DatasourceResources(*schema.ResourceData, func (s *VolcengineCertificateService) ReadResourceId(id string) string { return id } + +func getUniversalInfo(actionName string) ve.UniversalInfo { + return ve.UniversalInfo{ + ServiceName: "clb", + Version: "2020-04-01", + HttpMethod: ve.GET, + ContentType: ve.Default, + Action: actionName, + } +} diff --git a/volcengine/clb/clb/data_source_volcengine_clbs.go b/volcengine/clb/clb/data_source_volcengine_clbs.go index b1066594..adb84b8e 100644 --- a/volcengine/clb/clb/data_source_volcengine_clbs.go +++ b/volcengine/clb/clb/data_source_volcengine_clbs.go @@ -203,28 +203,52 @@ func DataSourceVolcengineClbs() *schema.Resource { "expired_time": { Type: schema.TypeString, Computed: true, - Description: "The expired time of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", + Description: "The expired time of the CLB.", }, "reclaim_time": { Type: schema.TypeString, Computed: true, - Description: "The reclaim time of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", + Description: "The reclaim time of the CLB.", }, "overdue_time": { Type: schema.TypeString, Computed: true, - Description: "The overdue time of the Clb. When the value of the load_balancer_billing_type is `PostPaid`, the query returns this field.", + Description: "The overdue time of the Clb.", }, "overdue_reclaim_time": { Type: schema.TypeString, Computed: true, - Description: "The over reclaim time of the CLB. When the value of the load_balancer_billing_type is `PostPaid`, the query returns this field.", + Description: "The over reclaim time of the CLB.", }, "deleted_time": { Type: schema.TypeString, Computed: true, Description: "The expected recycle time of the Clb.", }, + "eip_billing_config": { + Type: schema.TypeList, + Computed: true, + Description: "", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "isp": { + Type: schema.TypeString, + Computed: true, + Description: "The ISP of the EIP assigned to CLB, the value can be `BGP`.", + }, + "eip_billing_type": { + Type: schema.TypeString, + Computed: true, + Description: "The billing type of the EIP assigned to CLB. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`.", + }, + "bandwidth": { + Type: schema.TypeInt, + Computed: true, + Description: "The peek bandwidth of the EIP assigned to CLB. The value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic.", + }, + }, + }, + }, }, }, }, diff --git a/volcengine/clb/clb/resource_volcengine_clb.go b/volcengine/clb/clb/resource_volcengine_clb.go index 06abb49b..240c6d98 100644 --- a/volcengine/clb/clb/resource_volcengine_clb.go +++ b/volcengine/clb/clb/resource_volcengine_clb.go @@ -102,9 +102,8 @@ func ResourceVolcengineClb() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ForceNew: true, - Description: "The billing type of the CLB, the value can be `PostPaid` or `PrePaid`.", ValidateFunc: validation.StringInSlice([]string{"PostPaid", "PrePaid"}, false), + Description: "The billing type of the CLB, the value can be `PostPaid` or `PrePaid`.", }, "period": { Type: schema.TypeInt, @@ -124,6 +123,52 @@ func ResourceVolcengineClb() *schema.Resource { Computed: true, Description: "The renew type of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field.", }, + "eip_billing_config": { + Type: schema.TypeList, + Optional: true, + Computed: true, + ForceNew: true, + MaxItems: 1, + Description: "The billing configuration of the EIP which automatically associated to CLB. This field is valid when the type of CLB is `public`." + + "When the type of the CLB is `private`, suggest using a combination of resource `volcengine_eip_address` and `volcengine_eip_associate` to achieve public network access function.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "isp": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"BGP"}, false), + Description: "The ISP of the EIP which automatically associated to CLB, the value can be `BGP`.", + }, + "eip_billing_type": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringInSlice([]string{"PrePaid", "PostPaidByBandwidth", "PostPaidByTraffic"}, false), + Description: "The billing type of the EIP which automatically assigned to CLB. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`." + + "When creating a `PrePaid` public CLB, this field must be specified as `PrePaid` simultaneously." + + "When the LoadBalancerBillingType changes from `PostPaid` to `PrePaid`, please manually modify the value of this field to `PrePaid` simultaneously.", + }, + "bandwidth": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(1, 500), + Description: "The peek bandwidth of the EIP which automatically assigned to CLB. The value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic.", + }, + }, + }, + }, + "eip_id": { + Type: schema.TypeString, + Computed: true, + Description: "The Eip ID of the Clb.", + }, + "eip_address": { + Type: schema.TypeString, + Computed: true, + Description: "The Eip address of the Clb.", + }, "project_name": { Type: schema.TypeString, Optional: true, diff --git a/volcengine/clb/clb/service_volcengine_clb.go b/volcengine/clb/clb/service_volcengine_clb.go index 08148b0d..a2f048c1 100644 --- a/volcengine/clb/clb/service_volcengine_clb.go +++ b/volcengine/clb/clb/service_volcengine_clb.go @@ -69,18 +69,39 @@ func (s *VolcengineClbService) ReadResources(condition map[string]interface{}) ( return data, fmt.Errorf(" Clb is not map ") } - action := "DescribeLoadBalancersBilling" - req := map[string]interface{}{ + eipAction := "DescribeLoadBalancerAttributes" + eipReq := map[string]interface{}{ + "LoadBalancerId": clb["LoadBalancerId"], + } + logger.Debug(logger.ReqFormat, eipAction, eipReq) + eipResp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(eipAction), &eipReq) + if err != nil { + return data, err + } + logger.Debug(logger.RespFormat, eipAction, *eipResp) + + eipConfig, err := ve.ObtainSdkValue("Result.Eip", *eipResp) + if err != nil { + return data, err + } + clb["EipBillingConfig"] = eipConfig + + // `PostPaid` 实例不需查询续费相关信息 + if billingType := clb["LoadBalancerBillingType"]; billingType == 2.0 { + continue + } + billingAction := "DescribeLoadBalancersBilling" + billingReq := map[string]interface{}{ "LoadBalancerIds.1": clb["LoadBalancerId"], } - logger.Debug(logger.ReqFormat, action, condition) - resp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(action), &req) + logger.Debug(logger.ReqFormat, billingAction, billingReq) + billingResp, err := s.Client.UniversalClient.DoCall(getUniversalInfo(billingAction), &billingReq) if err != nil { return data, err } - logger.Debug(logger.RespFormat, action, *resp) + logger.Debug(logger.RespFormat, billingAction, *billingResp) - billingConfigs, err := ve.ObtainSdkValue("Result.LoadBalancerBillingConfigs", *resp) + billingConfigs, err := ve.ObtainSdkValue("Result.LoadBalancerBillingConfigs", *billingResp) if err != nil { return data, err } @@ -206,6 +227,30 @@ func (VolcengineClbService) WithResourceResponseHandlers(clb map[string]interfac return i }, }, + "EipID": { + TargetField: "eip_id", + }, + "ISP": { + TargetField: "isp", + }, + "EipBillingType": { + TargetField: "eip_billing_type", + Convert: func(i interface{}) interface{} { + if i == nil { + return nil + } + billingType := i.(float64) + switch billingType { + case 1: + return "PrePaid" + case 2: + return "PostPaidByBandwidth" + case 3: + return "PostPaidByTraffic" + } + return i + }, + }, }, nil } return []ve.ResourceResponseHandler{handler} @@ -234,6 +279,33 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, return i }, }, + "eip_billing_config": { + TargetField: "EipBillingConfig", + ConvertType: ve.ConvertListUnique, + NextLevelConvert: map[string]ve.RequestConvert{ + "isp": { + TargetField: "ISP", + }, + "eip_billing_type": { + TargetField: "EipBillingType", + Convert: func(data *schema.ResourceData, i interface{}) interface{} { + if i == nil { + return nil + } + billingType := i.(string) + switch billingType { + case "PrePaid": + return 1 + case "PostPaidByBandwidth": + return 2 + case "PostPaidByTraffic": + return 3 + } + return i + }, + }, + }, + }, "tags": { TargetField: "Tags", ConvertType: ve.ConvertListN, @@ -246,6 +318,25 @@ func (s *VolcengineClbService) CreateResource(resourceData *schema.ResourceData, return false, fmt.Errorf("region_id is not equal to provider region config(%s)", *s.Client.ClbClient.Config.Region) } + // private 类型不传 eip_billing_config + if (*call.SdkParam)["Type"] == "private" { + delete(*call.SdkParam, "EipBillingConfig.ISP") + delete(*call.SdkParam, "EipBillingConfig.EipBillingType") + delete(*call.SdkParam, "EipBillingConfig.Bandwidth") + } + if eipBillingType, exist := (*call.SdkParam)["EipBillingConfig.EipBillingType"]; exist { + ty := 0 + switch eipBillingType.(string) { + case "PrePaid": + ty = 1 + case "PostPaidByBandwidth": + ty = 2 + case "PostPaidByTraffic": + ty = 3 + } + (*call.SdkParam)["EipBillingConfig.EipBillingType"] = ty + } + // PeriodUnit 默认传 Month if (*call.SdkParam)["LoadBalancerBillingType"] == 1 { (*call.SdkParam)["PeriodUnit"] = "Month" @@ -298,9 +389,11 @@ func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, }, }, BeforeCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (bool, error) { - (*call.SdkParam)["LoadBalancerId"] = d.Id() - delete(*call.SdkParam, "Tags") - return true, nil + if len(*call.SdkParam) > 0 { + (*call.SdkParam)["LoadBalancerId"] = d.Id() + return true, nil + } + return false, nil }, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) @@ -355,7 +448,7 @@ func (s *VolcengineClbService) ModifyResource(resourceData *schema.ResourceData, ExecuteCall: func(d *schema.ResourceData, client *ve.SdkClient, call ve.SdkCall) (*map[string]interface{}, error) { logger.Debug(logger.RespFormat, call.Action, call.SdkParam) //修改 clb 计费类型 - return s.Client.ClbClient.ModifyLoadBalancerAttributesCommon(call.SdkParam) + return s.Client.UniversalClient.DoCall(getUniversalInfo(call.Action), call.SdkParam) }, Refresh: &ve.StateRefresh{ Target: []string{"Active"}, @@ -515,6 +608,27 @@ func (s *VolcengineClbService) DatasourceResources(*schema.ResourceData, *schema return i }, }, + "ISP": { + TargetField: "isp", + }, + "EipBillingType": { + TargetField: "eip_billing_type", + Convert: func(i interface{}) interface{} { + if i == nil { + return nil + } + billingType := i.(float64) + switch billingType { + case 1: + return "PrePaid" + case 2: + return "PostPaidByBandwidth" + case 3: + return "PostPaidByTraffic" + } + return i + }, + }, }, } } diff --git a/volcengine/clb/listener/common_volcengine_listener.go b/volcengine/clb/listener/common_volcengine_listener.go index 28567301..bd6d4fb5 100644 --- a/volcengine/clb/listener/common_volcengine_listener.go +++ b/volcengine/clb/listener/common_volcengine_listener.go @@ -8,6 +8,12 @@ func HealthCheckHTTPOnlyFieldDiffSuppress(k, old, new string, d *schema.Resource return healthCheckEnabled == "off" || protocol == "TCP" || protocol == "UDP" } +func HealthCheckUDPOnlyFieldDiffSuppress(k, old, new string, d *schema.ResourceData) bool { + healthCheckEnabled := d.Get("health_check").([]interface{})[0].(map[string]interface{})["enabled"].(string) + protocol := d.Get("protocol").(string) + return !(healthCheckEnabled == "on" && protocol == "UDP") +} + func HealthCheckFieldDiffSuppress(k, old, new string, d *schema.ResourceData) bool { healthCheckEnabled := d.Get("health_check").([]interface{})[0].(map[string]interface{})["enabled"].(string) return healthCheckEnabled == "off" diff --git a/volcengine/clb/listener/resource_volcengine_listener.go b/volcengine/clb/listener/resource_volcengine_listener.go index 68d92a30..62bf4d25 100644 --- a/volcengine/clb/listener/resource_volcengine_listener.go +++ b/volcengine/clb/listener/resource_volcengine_listener.go @@ -190,6 +190,18 @@ func ResourceVolcengineListener() *schema.Resource { Description: "The normal http status code of health check, the value can be `http_2xx` or `http_3xx` or `http_4xx` or `http_5xx`.", DiffSuppressFunc: HealthCheckHTTPOnlyFieldDiffSuppress, }, + "udp_request": { + Type: schema.TypeString, + Optional: true, + Description: "The UDP request of health check. This field must be specified simultaneously with field `udp_expect`.", + DiffSuppressFunc: HealthCheckUDPOnlyFieldDiffSuppress, + }, + "udp_expect": { + Type: schema.TypeString, + Optional: true, + Description: "The UDP expect of health check. This field must be specified simultaneously with field `udp_request`.", + DiffSuppressFunc: HealthCheckUDPOnlyFieldDiffSuppress, + }, }, }, }, diff --git a/volcengine/eip/eip_address/resource_volcengine_eip_address.go b/volcengine/eip/eip_address/resource_volcengine_eip_address.go index da01b758..5c0250bd 100644 --- a/volcengine/eip/eip_address/resource_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/resource_volcengine_eip_address.go @@ -87,10 +87,11 @@ func ResourceVolcengineEipAddress() *schema.Resource { "This field is only effective when creating a PrePaid Eip or changing the billing_type from PostPaid to PrePaid.", }, "bandwidth": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Description: "The peek bandwidth of the EIP, the value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic.", + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.IntBetween(1, 500), + Description: "The peek bandwidth of the EIP, the value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic.", }, "isp": { Type: schema.TypeString, diff --git a/volcengine/eip/eip_address/service_volcengine_eip_address.go b/volcengine/eip/eip_address/service_volcengine_eip_address.go index 9e3e0028..24a64c2a 100644 --- a/volcengine/eip/eip_address/service_volcengine_eip_address.go +++ b/volcengine/eip/eip_address/service_volcengine_eip_address.go @@ -215,7 +215,7 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour return s.Client.VpcClient.ModifyEipAddressAttributesCommon(call.SdkParam) }, Refresh: &ve.StateRefresh{ - Target: []string{"Available"}, + Target: []string{"Available", "Attached"}, Timeout: resourceData.Timeout(schema.TimeoutUpdate), }, Convert: map[string]ve.RequestConvert{ @@ -271,7 +271,7 @@ func (s *VolcengineEipAddressService) ModifyResource(resourceData *schema.Resour return nil }, Refresh: &ve.StateRefresh{ - Target: []string{"Available"}, + Target: []string{"Available", "Attached"}, Timeout: resourceData.Timeout(schema.TimeoutUpdate), }, }, From ef76f062d237020580c72e3be5d0f414f3bd0f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Thu, 13 Jul 2023 14:51:38 +0800 Subject: [PATCH 07/10] fix: fix cen attach instance lock err --- example/cenAttachInstance/main.tf | 13 ++++++++++--- .../service_volcengine_cen_attach_instance.go | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/example/cenAttachInstance/main.tf b/example/cenAttachInstance/main.tf index bcf7b24e..67216d97 100644 --- a/example/cenAttachInstance/main.tf +++ b/example/cenAttachInstance/main.tf @@ -1,6 +1,13 @@ resource "volcengine_cen_attach_instance" "foo" { - cen_id = "cen-2bzrl3srxsv0g2dx0efyoojn3" - instance_id = "vpc-2d686ofu89pfk58ozfd8z9khe" + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + instance_id = "vpc-2fe5dpn0av2m859gp68rhk2dc" instance_type = "VPC" - instance_region_id = "cn-guilin-boe" + instance_region_id = "cn-beijing" +} + +resource "volcengine_cen_attach_instance" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + instance_id = "vpc-in66ktl5t24g8gbssz0sqva1" + instance_type = "VPC" + instance_region_id = "cn-beijing" } \ No newline at end of file diff --git a/volcengine/cen/cen_attach_instance/service_volcengine_cen_attach_instance.go b/volcengine/cen/cen_attach_instance/service_volcengine_cen_attach_instance.go index d0f9c93d..8814dcde 100644 --- a/volcengine/cen/cen_attach_instance/service_volcengine_cen_attach_instance.go +++ b/volcengine/cen/cen_attach_instance/service_volcengine_cen_attach_instance.go @@ -162,7 +162,7 @@ func (s *VolcengineCenAttachInstanceService) CreateResource(resourceData *schema }, }, LockId: func(d *schema.ResourceData) string { - return d.Get("instance_id").(string) + return d.Get("cen_id").(string) }, }, } @@ -219,7 +219,7 @@ func (s *VolcengineCenAttachInstanceService) RemoveResource(resourceData *schema }, }, LockId: func(d *schema.ResourceData) string { - return d.Get("instance_id").(string) + return d.Get("cen_id").(string) }, }, } From 8bba274bd8d5e43bdc7f5eb5319a6854734082f4 Mon Sep 17 00:00:00 2001 From: zhangpeihua Date: Thu, 13 Jul 2023 15:31:34 +0800 Subject: [PATCH 08/10] feat: opt ecs disk doc --- .../resource_volcengine_ecs_instance.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go index 784ad15a..7e357d22 100644 --- a/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go +++ b/volcengine/ecs/ecs_instance/resource_volcengine_ecs_instance.go @@ -222,9 +222,10 @@ func ResourceVolcengineEcsInstance() *schema.Resource { }, "system_volume_size": { - Type: schema.TypeInt, - Required: true, - Description: "The size of system volume.", + Type: schema.TypeInt, + Required: true, + Description: "The size of system volume. " + + "The value range of the system volume size is ESSD_PL0: 20~2048, ESSD_FlexPL: 20~2048, PTSSD: 10~500.", }, "system_volume_id": { @@ -278,10 +279,11 @@ func ResourceVolcengineEcsInstance() *schema.Resource { Description: "The type of volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`.", }, "size": { - Type: schema.TypeInt, - Required: true, - ForceNew: true, - Description: "The size of volume.", + Type: schema.TypeInt, + Required: true, + ForceNew: true, + Description: "The size of volume. " + + "The value range of the data volume size is ESSD_PL0: 10~32768, ESSD_FlexPL: 10~32768, PTSSD: 20~8192.", }, "delete_with_instance": { Type: schema.TypeBool, From 9ac0ca1640793169b7e5537ba6a0d08d7dcbbf60 Mon Sep 17 00:00:00 2001 From: "maoshuai.17" Date: Thu, 13 Jul 2023 20:30:34 +0800 Subject: [PATCH 09/10] fix: fix network_interface and network_acl --- .../service_volcengine_network_acl.go | 54 +++++++++++++++---- ...ervice_volcengine_network_acl_associate.go | 8 ++- ...ta_source_volcengine_network_interfaces.go | 14 +---- 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/volcengine/vpc/network_acl/service_volcengine_network_acl.go b/volcengine/vpc/network_acl/service_volcengine_network_acl.go index 0d38805b..6ebb454f 100644 --- a/volcengine/vpc/network_acl/service_volcengine_network_acl.go +++ b/volcengine/vpc/network_acl/service_volcengine_network_acl.go @@ -3,13 +3,15 @@ package network_acl import ( "errors" "fmt" + "strconv" + "time" + "github.com/google/uuid" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ve "github.com/volcengine/terraform-provider-volcengine/common" "github.com/volcengine/terraform-provider-volcengine/logger" - "strconv" - "time" + "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/vpc" ) type VolcengineNetworkAclService struct { @@ -89,20 +91,22 @@ func (s *VolcengineNetworkAclService) ReadResource(resourceData *schema.Resource // 删除默认创建的拒绝规则 if ingressAclEntries, ok := data["IngressAclEntries"]; ok { - for index, entry := range ingressAclEntries.([]interface{}) { - if priority, ok := entry.(map[string]interface{})["Priority"]; ok && priority.(float64) > 100 { - ingressAclEntries = append(ingressAclEntries.([]interface{})[:index], ingressAclEntries.([]interface{})[index+1:]...) - data["IngressAclEntries"] = ingressAclEntries + var tempEntries []interface{} + for _, entry := range ingressAclEntries.([]interface{}) { + if priority, ok := entry.(map[string]interface{})["Priority"]; ok && priority.(float64) < 100 { + tempEntries = append(tempEntries, entry) } } + data["IngressAclEntries"] = tempEntries } if egressAclEntries, ok := data["EgressAclEntries"]; ok { - for index, entry := range egressAclEntries.([]interface{}) { - if priority, ok := entry.(map[string]interface{})["Priority"]; ok && priority.(float64) > 100 { - egressAclEntries = append(egressAclEntries.([]interface{})[:index], egressAclEntries.([]interface{})[index+1:]...) - data["EgressAclEntries"] = egressAclEntries + var tempEntries []interface{} + for _, entry := range egressAclEntries.([]interface{}) { + if priority, ok := entry.(map[string]interface{})["Priority"]; ok && priority.(float64) < 100 { + tempEntries = append(tempEntries, entry) } } + data["EgressAclEntries"] = tempEntries } return data, err @@ -177,6 +181,16 @@ func (s *VolcengineNetworkAclService) CreateResource(resourceData *schema.Resour Target: []string{"Available"}, Timeout: resourceData.Timeout(schema.TimeoutCreate), }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + vpc.NewVpcService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("vpc_id").(string), + }, + }, + LockId: func(d *schema.ResourceData) string { + return d.Get("vpc_id").(string) + }, }, } callbacks = append(callbacks, callback) @@ -254,6 +268,16 @@ func (s *VolcengineNetworkAclService) ModifyResource(resourceData *schema.Resour Target: []string{"Available"}, Timeout: resourceData.Timeout(schema.TimeoutCreate), }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + vpc.NewVpcService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("vpc_id").(string), + }, + }, + LockId: func(d *schema.ResourceData) string { + return d.Get("vpc_id").(string) + }, }, } callbacks = append(callbacks, callback) @@ -365,6 +389,16 @@ func (s *VolcengineNetworkAclService) RemoveResource(resourceData *schema.Resour return resource.RetryableError(callErr) }) }, + ExtraRefresh: map[ve.ResourceService]*ve.StateRefresh{ + vpc.NewVpcService(s.Client): { + Target: []string{"Available"}, + Timeout: resourceData.Timeout(schema.TimeoutCreate), + ResourceId: resourceData.Get("vpc_id").(string), + }, + }, + LockId: func(d *schema.ResourceData) string { + return d.Get("vpc_id").(string) + }, }, } callbacks = append(callbacks, removeCallback) diff --git a/volcengine/vpc/network_acl_associate/service_volcengine_network_acl_associate.go b/volcengine/vpc/network_acl_associate/service_volcengine_network_acl_associate.go index c731e63b..24667c1d 100644 --- a/volcengine/vpc/network_acl_associate/service_volcengine_network_acl_associate.go +++ b/volcengine/vpc/network_acl_associate/service_volcengine_network_acl_associate.go @@ -3,13 +3,14 @@ package network_acl_associate import ( "errors" "fmt" + "strings" + "time" + "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" ve "github.com/volcengine/terraform-provider-volcengine/common" "github.com/volcengine/terraform-provider-volcengine/logger" "github.com/volcengine/terraform-provider-volcengine/volcengine/vpc/network_acl" - "strings" - "time" ) type VolcengineNetworkAclAssociateService struct { @@ -54,6 +55,9 @@ func (s *VolcengineNetworkAclAssociateService) ReadResources(condition map[strin if err != nil { return []interface{}{}, err } + if results == nil { + results = []interface{}{} + } if _, ok = results.([]interface{}); !ok { return []interface{}{}, errors.New("Result.NetworkAcls is not Slice") } diff --git a/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go index 1c3c0a08..f9a1023a 100644 --- a/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go +++ b/volcengine/vpc/network_interface/data_source_volcengine_network_interfaces.go @@ -217,7 +217,7 @@ func DataSourceVolcengineNetworkInterfaces() *schema.Resource { Description: "Whether the network card has been authorized to be used by other account services.", }, "private_ip_sets": { - Type: schema.TypeSet, + Type: schema.TypeList, Computed: true, Description: "The IP address of secondary private network interface.", Elem: &schema.Resource{ @@ -228,7 +228,7 @@ func DataSourceVolcengineNetworkInterfaces() *schema.Resource { Description: "The secondary private network IP address of the network interface card.", }, "associated_elastic_ip": { - Type: schema.TypeSet, + Type: schema.TypeList, Computed: true, Description: "The public IP that secondary private network IP associated with.", Elem: &schema.Resource{ @@ -254,16 +254,6 @@ func DataSourceVolcengineNetworkInterfaces() *schema.Resource { }, }, }, - //"associated_elastic_ip_id": { - // Type: schema.TypeString, - // Computed: true, - // Description: "The allocation id of the EIP to which the ENI associates.", - //}, - //"associated_elastic_ip_address": { - // Type: schema.TypeString, - // Computed: true, - // Description: "The IP address of the EIP to which the ENI associates.", - //}, "project_name": { Type: schema.TypeString, Computed: true, From 84cb034b61b1c74f41db2f4ce28746ca0d7b6dfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=93=B2=E9=93=AD?= Date: Mon, 17 Jul 2023 10:39:59 +0800 Subject: [PATCH 10/10] feat: update doc and version --- common/common_volcengine_version.go | 2 +- ...resource_volcengine_cen_attach_instance.go | 2 +- ...source_volcengine_cen_bandwidth_package.go | 2 +- .../d/cen_bandwidth_packages.html.markdown | 1 + .../docs/d/cen_route_entries.html.markdown | 2 +- .../d/cen_service_route_entries.html.markdown | 42 ++++++++ website/docs/d/cens.html.markdown | 1 + website/docs/d/certificates.html.markdown | 9 ++ website/docs/d/clbs.html.markdown | 7 ++ .../d/scaling_configurations.html.markdown | 6 ++ website/docs/d/scaling_groups.html.markdown | 4 + website/docs/r/cen.html.markdown | 6 +- .../docs/r/cen_attach_instance.html.markdown | 15 ++- .../r/cen_bandwidth_package.html.markdown | 15 +-- website/docs/r/cen_route_entry.html.markdown | 50 ++++++++++ .../r/cen_service_route_entry.html.markdown | 98 +++++++++++++++++++ website/docs/r/certificate.html.markdown | 14 ++- website/docs/r/clb.html.markdown | 45 ++++++++- website/docs/r/ecs_instance.html.markdown | 30 ++++-- .../r/ecs_key_pair_associate.html.markdown | 5 + website/docs/r/eip_address.html.markdown | 12 ++- website/docs/r/eip_associate.html.markdown | 2 +- website/docs/r/listener.html.markdown | 2 + website/docs/r/nat_gateway.html.markdown | 4 +- website/docs/r/network_acl.html.markdown | 25 +++-- .../r/scaling_configuration.html.markdown | 42 +++++--- ...ing_configuration_attachment.html.markdown | 1 + website/docs/r/scaling_group.html.markdown | 30 ++++-- .../scaling_instance_attachment.html.markdown | 1 + website/docs/r/scaling_policy.html.markdown | 25 +++-- website/docs/r/vpn_connection.html.markdown | 36 +++---- website/docs/r/vpn_gateway.html.markdown | 14 +-- website/volcengine.erb | 9 ++ 33 files changed, 465 insertions(+), 94 deletions(-) create mode 100644 website/docs/d/cen_service_route_entries.html.markdown create mode 100644 website/docs/r/cen_route_entry.html.markdown create mode 100644 website/docs/r/cen_service_route_entry.html.markdown diff --git a/common/common_volcengine_version.go b/common/common_volcengine_version.go index 62457ab6..385b4706 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.87" + TerraformProviderVersion = "0.0.88" ) diff --git a/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go b/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go index 8be7cfc5..1a3063ca 100644 --- a/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go +++ b/volcengine/cen/cen_attach_instance/resource_volcengine_cen_attach_instance.go @@ -48,7 +48,7 @@ func ResourceVolcengineCenAttachInstance() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - Description: "The type of the instance. Valid values : `VPC`, `DCGW`.", + Description: "The type of the instance. Valid values: `VPC`, `DCGW`.", ValidateFunc: validation.StringInSlice([]string{"VPC", "DCGW"}, false), }, "instance_region_id": { diff --git a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go index b510f673..6569c4a6 100644 --- a/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go +++ b/volcengine/cen/cen_bandwidth_package/resource_volcengine_cen_bandwidth_package.go @@ -84,7 +84,7 @@ func ResourceVolcengineCenBandwidthPackage() *schema.Resource { Default: "Month", ValidateFunc: validation.StringInSlice([]string{"Month", "Year"}, false), DiffSuppressFunc: periodDiffSuppress, - Description: "The period unit of the cen bandwidth package. Value : `Month`, `Year`. Default value is `Month`.", + Description: "The period unit of the cen bandwidth package. Value: `Month`, `Year`. Default value is `Month`.", }, "period": { Type: schema.TypeInt, diff --git a/website/docs/d/cen_bandwidth_packages.html.markdown b/website/docs/d/cen_bandwidth_packages.html.markdown index 3f8364d9..f09b041f 100644 --- a/website/docs/d/cen_bandwidth_packages.html.markdown +++ b/website/docs/d/cen_bandwidth_packages.html.markdown @@ -48,6 +48,7 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the cen bandwidth package. * `local_geographic_region_set_id` - The local geographic region set id of the cen bandwidth package. * `peer_geographic_region_set_id` - The peer geographic region set id of the cen bandwidth package. + * `project_name` - The ProjectName of the cen bandwidth package. * `remaining_bandwidth` - The remain bandwidth of the cen bandwidth package. * `status` - The status of the cen bandwidth package. * `tags` - Tags. diff --git a/website/docs/d/cen_route_entries.html.markdown b/website/docs/d/cen_route_entries.html.markdown index 4b18b090..bae0ea59 100644 --- a/website/docs/d/cen_route_entries.html.markdown +++ b/website/docs/d/cen_route_entries.html.markdown @@ -11,7 +11,7 @@ Use this data source to query detailed information of cen route entries ## Example Usage ```hcl data "volcengine_cen_route_entries" "foo" { - cen_id = "cen-12bjcqtr8ah3417q7y38h8t79" + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" } ``` ## Argument Reference diff --git a/website/docs/d/cen_service_route_entries.html.markdown b/website/docs/d/cen_service_route_entries.html.markdown new file mode 100644 index 00000000..d9103be9 --- /dev/null +++ b/website/docs/d/cen_service_route_entries.html.markdown @@ -0,0 +1,42 @@ +--- +subcategory: "CEN(BETA)" +layout: "volcengine" +page_title: "Volcengine: volcengine_cen_service_route_entries" +sidebar_current: "docs-volcengine-datasource-cen_service_route_entries" +description: |- + Use this data source to query detailed information of cen service route entries +--- +# volcengine_cen_service_route_entries +Use this data source to query detailed information of cen service route entries +## Example Usage +```hcl +data "volcengine_cen_service_route_entries" "default" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" +} +``` +## Argument Reference +The following arguments are supported: +* `cen_id` - (Optional) A cen ID. +* `destination_cidr_block` - (Optional) A destination cidr block. +* `output_file` - (Optional) File name where to save data source results. +* `service_region_id` - (Optional) A service region id. +* `service_vpc_id` - (Optional) A service VPC id. + +## Attributes Reference +In addition to all arguments above, the following attributes are exported: +* `service_route_entries` - The collection of cen service route entry query. + * `cen_id` - The cen ID of the cen service route entry. + * `creation_time` - The create time of the cen service route entry. + * `description` - The description of the cen service route entry. + * `destination_cidr_block` - The destination cidr block of the cen service route entry. + * `publish_mode` - Publishing scope of cloud service access routes. Valid values are `LocalDCGW`(default), `Custom`. + * `publish_to_instances` - The publish instances. A maximum of 100 can be uploaded in one request. + * `instance_id` - Cloud service access routes need to publish the network instance ID. + * `instance_region_id` - The region where the cloud service access route needs to be published. + * `instance_type` - The network instance type that needs to be published for cloud service access routes. The values are as follows: `VPC`, `DCGW`. + * `service_region_id` - The service region id of the cen service route entry. + * `service_vpc_id` - The service VPC id of the cen service route entry. + * `status` - The status of the cen service route entry. +* `total_count` - The total count of cen service route entry. + + diff --git a/website/docs/d/cens.html.markdown b/website/docs/d/cens.html.markdown index 340b52a1..f8a418d2 100644 --- a/website/docs/d/cens.html.markdown +++ b/website/docs/d/cens.html.markdown @@ -37,6 +37,7 @@ In addition to all arguments above, the following attributes are exported: * `creation_time` - The create time of the cen. * `description` - The description of the cen. * `id` - The ID of the cen. + * `project_name` - The ProjectName of the cen instance. * `status` - The status of the cen. * `tags` - Tags. * `key` - The Key of Tags. diff --git a/website/docs/d/certificates.html.markdown b/website/docs/d/certificates.html.markdown index e73793dc..32885807 100644 --- a/website/docs/d/certificates.html.markdown +++ b/website/docs/d/certificates.html.markdown @@ -21,6 +21,12 @@ The following arguments are supported: * `name_regex` - (Optional) The Name Regex of Certificate. * `output_file` - (Optional) File name where to save data source results. * `project_name` - (Optional) The ProjectName of Certificate. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -34,6 +40,9 @@ In addition to all arguments above, the following attributes are exported: * `id` - The ID of the Certificate. * `listeners` - The ID list of the Listener. * `project_name` - The ProjectName of the Certificate. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `total_count` - The total count of Certificate query. diff --git a/website/docs/d/clbs.html.markdown b/website/docs/d/clbs.html.markdown index c49232d8..05972d78 100644 --- a/website/docs/d/clbs.html.markdown +++ b/website/docs/d/clbs.html.markdown @@ -41,7 +41,9 @@ In addition to all arguments above, the following attributes are exported: * `eip_id` - The Eip ID of the Clb. * `eni_address` - The Eni address of the Clb. * `eni_id` - The Eni ID of the Clb. + * `expired_time` - The expired time of the CLB. * `id` - The ID of the Clb. + * `instance_status` - The billing status of the CLB. * `load_balancer_billing_type` - The billing type of the Clb. * `load_balancer_id` - The ID of the Clb. * `load_balancer_name` - The name of the Clb. @@ -50,8 +52,13 @@ In addition to all arguments above, the following attributes are exported: * `master_zone_id` - The master zone ID of the CLB. * `modification_protection_reason` - The modification protection reason of the Clb. * `modification_protection_status` - The modification protection status of the Clb. + * `overdue_reclaim_time` - The over reclaim time of the CLB. * `overdue_time` - The overdue time of the Clb. * `project_name` - The ProjectName of the Clb. + * `reclaim_time` - The reclaim time of the CLB. + * `remain_renew_times` - The remain renew times of the CLB. When the value of the renew_type is `AutoRenew`, the query returns this field. + * `renew_period_times` - The renew period times of the CLB. When the value of the renew_type is `AutoRenew`, the query returns this field. + * `renew_type` - The renew type of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field. * `slave_zone_id` - The slave zone ID of the CLB. * `status` - The status of the Clb. * `subnet_id` - The subnet ID of the Clb. diff --git a/website/docs/d/scaling_configurations.html.markdown b/website/docs/d/scaling_configurations.html.markdown index b943377a..b06c9438 100644 --- a/website/docs/d/scaling_configurations.html.markdown +++ b/website/docs/d/scaling_configurations.html.markdown @@ -30,6 +30,7 @@ In addition to all arguments above, the following attributes are exported: * `eip_billing_type` - The EIP ISP which the scaling configuration set. * `eip_isp` - The EIP ISP which the scaling configuration set. * `host_name` - The ECS hostname which the scaling configuration set. + * `hpc_cluster_id` - The ID of the HPC cluster to which the instance belongs. Valid only when InstanceTypes.N specifies High Performance Computing GPU Type. * `id` - The id of the scaling configuration. * `image_id` - The ECS image id which the scaling configuration set. * `instance_description` - The ECS instance description which the scaling configuration set. @@ -37,11 +38,16 @@ In addition to all arguments above, the following attributes are exported: * `instance_types` - The list of the ECS instance type which the scaling configuration set. * `key_pair_name` - The ECS key pair name which the scaling configuration set. * `lifecycle_state` - The lifecycle state of the scaling configuration. + * `project_name` - The project to which the instance created by the scaling configuration belongs. * `scaling_configuration_id` - The id of the scaling configuration. * `scaling_configuration_name` - The name of the scaling configuration. * `scaling_group_id` - The id of the scaling group to which the scaling configuration belongs. * `security_enhancement_strategy` - The Ecs security enhancement strategy which the scaling configuration set. * `security_group_ids` - The list of the security group id of the networkInterface which the scaling configuration set. + * `spot_strategy` - The preemption policy of the instance. Valid Value: NoSpot (default), SpotAsPriceGo. + * `tags` - The label of the instance created by the scaling configuration. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `updated_at` - The create time of the scaling configuration. * `user_data` - The ECS user data which the scaling configuration set. * `volumes` - The list of volume of the scaling configuration. diff --git a/website/docs/d/scaling_groups.html.markdown b/website/docs/d/scaling_groups.html.markdown index 40ff7c84..4b0b11fa 100644 --- a/website/docs/d/scaling_groups.html.markdown +++ b/website/docs/d/scaling_groups.html.markdown @@ -37,6 +37,7 @@ In addition to all arguments above, the following attributes are exported: * `max_instance_number` - The max instance number of the scaling group. * `min_instance_number` - The min instance number of the scaling group. * `multi_az_policy` - The multi az policy of the scaling group. Valid values: PRIORITY, BALANCE. + * `project_name` - The ProjectName of scaling group. * `scaling_group_id` - The id of the scaling group. * `scaling_group_name` - The name of the scaling group. * `server_group_attributes` - The list of server group attributes. @@ -45,6 +46,9 @@ In addition to all arguments above, the following attributes are exported: * `server_group_id` - The server group id. * `weight` - The weight of the instance. * `subnet_ids` - The list of the subnet id to which the ENI is connected. + * `tags` - Tags. + * `key` - The Key of Tags. + * `value` - The Value of Tags. * `total_instance_count` - The total instance count of the scaling group. * `updated_at` - The create time of the scaling group. * `vpc_id` - The VPC id of the scaling group. diff --git a/website/docs/r/cen.html.markdown b/website/docs/r/cen.html.markdown index 20e399b3..23dfd8cb 100644 --- a/website/docs/r/cen.html.markdown +++ b/website/docs/r/cen.html.markdown @@ -11,14 +11,16 @@ Provides a resource to manage cen ## Example Usage ```hcl resource "volcengine_cen" "foo" { - cen_name = "tf-test" - description = "tf-test" + cen_name = "tf-test-3" + description = "tf-test" + project_name = "default" } ``` ## Argument Reference The following arguments are supported: * `cen_name` - (Optional) The name of the cen. * `description` - (Optional) The description of the cen. +* `project_name` - (Optional) The ProjectName of the cen instance. * `tags` - (Optional) Tags. The `tags` object supports the following: diff --git a/website/docs/r/cen_attach_instance.html.markdown b/website/docs/r/cen_attach_instance.html.markdown index 869ecd05..26b4c23f 100644 --- a/website/docs/r/cen_attach_instance.html.markdown +++ b/website/docs/r/cen_attach_instance.html.markdown @@ -11,10 +11,17 @@ Provides a resource to manage cen attach instance ## Example Usage ```hcl resource "volcengine_cen_attach_instance" "foo" { - cen_id = "cen-2bzrl3srxsv0g2dx0efyoojn3" - instance_id = "vpc-2d686ofu89pfk58ozfd8z9khe" + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + instance_id = "vpc-2fe5dpn0av2m859gp68rhk2dc" instance_type = "VPC" - instance_region_id = "cn-guilin-boe" + instance_region_id = "cn-beijing" +} + +resource "volcengine_cen_attach_instance" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + instance_id = "vpc-in66ktl5t24g8gbssz0sqva1" + instance_type = "VPC" + instance_region_id = "cn-beijing" } ``` ## Argument Reference @@ -22,7 +29,7 @@ The following arguments are supported: * `cen_id` - (Required, ForceNew) The ID of the cen. * `instance_id` - (Required, ForceNew) The ID of the instance. * `instance_region_id` - (Required, ForceNew) The region ID of the instance. -* `instance_type` - (Required, ForceNew) The type of the instance. +* `instance_type` - (Required, ForceNew) The type of the instance. Valid values: `VPC`, `DCGW`. * `instance_owner_id` - (Optional, ForceNew) The owner ID of the instance. ## Attributes Reference diff --git a/website/docs/r/cen_bandwidth_package.html.markdown b/website/docs/r/cen_bandwidth_package.html.markdown index 31227448..d71dc47d 100644 --- a/website/docs/r/cen_bandwidth_package.html.markdown +++ b/website/docs/r/cen_bandwidth_package.html.markdown @@ -23,18 +23,21 @@ resource "volcengine_cen_bandwidth_package" "foo" { billing_type = "PrePaid" period_unit = "Year" period = 1 + project_name = "default" } ``` ## Argument Reference The following arguments are supported: -* `bandwidth` - (Optional) The bandwidth of the cen bandwidth package. -* `billing_type` - (Optional, ForceNew) The billing type of the cen bandwidth package. Terraform will only remove the PrePaid cen bandwidth package from the state file, not actually remove. +* `bandwidth` - (Optional) The bandwidth of the cen bandwidth package. Value: 2~10000. +* `billing_type` - (Optional, ForceNew) The billing type of the cen bandwidth package. Only support `PrePaid` and default value is `PrePaid`. +Terraform will only remove the PrePaid cen bandwidth package from the state file, not actually remove. * `cen_bandwidth_package_name` - (Optional) The name of the cen bandwidth package. * `description` - (Optional) The description of the cen bandwidth package. -* `local_geographic_region_set_id` - (Optional, ForceNew) The local geographic region set id of the cen bandwidth package. -* `peer_geographic_region_set_id` - (Optional, ForceNew) The peer geographic region set id of the cen bandwidth package. -* `period_unit` - (Optional) The period unit of the cen bandwidth package. -* `period` - (Optional) The period of the cen bandwidth package. +* `local_geographic_region_set_id` - (Optional, ForceNew) The local geographic region set id of the cen bandwidth package. Valid value: `China`, `Asia`. +* `peer_geographic_region_set_id` - (Optional, ForceNew) The peer geographic region set id of the cen bandwidth package. Valid value: `China`, `Asia`. +* `period_unit` - (Optional) The period unit of the cen bandwidth package. Value: `Month`, `Year`. Default value is `Month`. +* `period` - (Optional) The period of the cen bandwidth package. Default value is 1. +* `project_name` - (Optional) The ProjectName of the cen bandwidth package. * `tags` - (Optional) Tags. The `tags` object supports the following: diff --git a/website/docs/r/cen_route_entry.html.markdown b/website/docs/r/cen_route_entry.html.markdown new file mode 100644 index 00000000..26e5ac24 --- /dev/null +++ b/website/docs/r/cen_route_entry.html.markdown @@ -0,0 +1,50 @@ +--- +subcategory: "CEN(BETA)" +layout: "volcengine" +page_title: "Volcengine: volcengine_cen_route_entry" +sidebar_current: "docs-volcengine-resource-cen_route_entry" +description: |- + Provides a resource to manage cen route entry +--- +# volcengine_cen_route_entry +Provides a resource to manage cen route entry +## Example Usage +```hcl +resource "volcengine_cen_route_entry" "foo" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "192.168.0.0/24" + instance_type = "VPC" + instance_region_id = "cn-beijing" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" +} + +resource "volcengine_cen_route_entry" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "192.168.17.0/24" + instance_type = "VPC" + instance_region_id = "cn-beijing" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" +} +``` +## Argument Reference +The following arguments are supported: +* `cen_id` - (Required, ForceNew) The cen ID of the cen route entry. +* `destination_cidr_block` - (Required, ForceNew) The destination cidr block of the cen route entry. +* `instance_id` - (Required, ForceNew) The instance id of the next hop of the cen route entry. +* `instance_region_id` - (Required, ForceNew) The instance region id of the next hop of the cen route entry. +* `instance_type` - (Optional, ForceNew) The instance type of the next hop of the cen route entry. + +## Attributes Reference +In addition to all arguments above, the following attributes are exported: +* `id` - ID of the resource. +* `as_path` - The AS path of the cen route entry. +* `publish_status` - The publish status of the cen route entry. +* `status` - The status of the cen route entry. + + +## Import +CenRouteEntry can be imported using the CenId:DestinationCidrBlock:InstanceId:InstanceType:InstanceRegionId, e.g. +``` +$ terraform import volcengine_cen_route_entry.default cen-2nim00ybaylts7trquyzt****:100.XX.XX.0/24:vpc-vtbnbb04qw3k2hgi12cv****:VPC:cn-beijing +``` + diff --git a/website/docs/r/cen_service_route_entry.html.markdown b/website/docs/r/cen_service_route_entry.html.markdown new file mode 100644 index 00000000..e5a74c12 --- /dev/null +++ b/website/docs/r/cen_service_route_entry.html.markdown @@ -0,0 +1,98 @@ +--- +subcategory: "CEN(BETA)" +layout: "volcengine" +page_title: "Volcengine: volcengine_cen_service_route_entry" +sidebar_current: "docs-volcengine-resource-cen_service_route_entry" +description: |- + Provides a resource to manage cen service route entry +--- +# volcengine_cen_service_route_entry +Provides a resource to manage cen service route entry +## Example Usage +```hcl +resource "volcengine_cen_service_route_entry" "foo" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/11" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} + +resource "volcengine_cen_service_route_entry" "foo1" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/10" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} + +resource "volcengine_cen_service_route_entry" "foo2" { + cen_id = "cen-12ar8uclj68sg17q7y20v9gil" + destination_cidr_block = "100.64.0.0/12" + service_region_id = "cn-beijing" + service_vpc_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + description = "test-tf" + publish_mode = "Custom" + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-2fepz36a5ra4g59gp67w197xo" + } + publish_to_instances { + instance_region_id = "cn-beijing" + instance_type = "VPC" + instance_id = "vpc-im67wjcikxkw8gbssx8ufpj8" + } +} +``` +## Argument Reference +The following arguments are supported: +* `cen_id` - (Required, ForceNew) The cen ID of the cen service route entry. +* `destination_cidr_block` - (Required, ForceNew) The destination cidr block of the cen service route entry. +* `service_region_id` - (Required, ForceNew) The service region id of the cen service route entry. +* `service_vpc_id` - (Required, ForceNew) The service VPC id of the cen service route entry. +* `description` - (Optional) The description of the cen service route entry. +* `publish_mode` - (Optional) Publishing scope of cloud service access routes. Valid values are `LocalDCGW`(default), `Custom`. +* `publish_to_instances` - (Optional) The publish instances. A maximum of 100 can be uploaded in one request. This field needs to be filled in when the `publish_mode` is `Custom`. + +The `publish_to_instances` object supports the following: + +* `instance_id` - (Optional) Cloud service access routes need to publish the network instance ID. +* `instance_region_id` - (Optional) The region where the cloud service access route needs to be published. +* `instance_type` - (Optional) The network instance type that needs to be published for cloud service access routes. The values are as follows: `VPC`, `DCGW`. + +## Attributes Reference +In addition to all arguments above, the following attributes are exported: +* `id` - ID of the resource. +* `creation_time` - The create time of the cen service route entry. +* `status` - The status of the cen service route entry. + + +## Import +CenServiceRouteEntry can be imported using the CenId:DestinationCidrBlock:ServiceRegionId:ServiceVpcId, e.g. +``` +$ terraform import volcengine_cen_service_route_entry.default cen-2nim00ybaylts7trquyzt****:100.XX.XX.0/24:cn-beijing:vpc-3rlkeggyn6tc010exd32q**** +``` + diff --git a/website/docs/r/certificate.html.markdown b/website/docs/r/certificate.html.markdown index 976f5bdf..4c69e907 100644 --- a/website/docs/r/certificate.html.markdown +++ b/website/docs/r/certificate.html.markdown @@ -15,15 +15,25 @@ resource "volcengine_certificate" "foo" { description = "This is a clb certificate" public_key = "public-key" private_key = "private-key" + tags { + key = "k1" + value = "v1" + } } ``` ## Argument Reference The following arguments are supported: * `private_key` - (Required, ForceNew) The private key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `public_key` - (Required, ForceNew) The public key of the Certificate. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. -* `certificate_name` - (Optional, ForceNew) The name of the Certificate. -* `description` - (Optional, ForceNew) The description of the Certificate. +* `certificate_name` - (Optional) The name of the Certificate. +* `description` - (Optional) The description of the Certificate. * `project_name` - (Optional, ForceNew) The ProjectName of the Certificate. +* `tags` - (Optional) Tags. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/clb.html.markdown b/website/docs/r/clb.html.markdown index 2600d373..ce54c3b9 100644 --- a/website/docs/r/clb.html.markdown +++ b/website/docs/r/clb.html.markdown @@ -14,13 +14,42 @@ in [Volcengine Console](https://console.volcengine.com/finance/unsubscribe/),wh use 'terraform state rm ${resourceId}' to remove. ## Example Usage ```hcl -resource "volcengine_clb" "foo" { +resource "volcengine_clb" "public_clb" { type = "public" subnet_id = "subnet-mj92ij84m5fk5smt1arvwrtw" load_balancer_spec = "small_1" description = "Demo" load_balancer_name = "terraform-auto-create" project_name = "yyy" + eip_billing_config { + isp = "BGP" + eip_billing_type = "PostPaidByBandwidth" + bandwidth = 1 + } +} + +resource "volcengine_clb" "private_clb" { + type = "private" + subnet_id = "subnet-mj92ij84m5fk5smt1arvwrtw" + load_balancer_spec = "small_1" + description = "Demo" + load_balancer_name = "terraform-auto-create" + project_name = "default" +} + +resource "volcengine_eip_address" "eip" { + billing_type = "PostPaidByBandwidth" + bandwidth = 1 + isp = "BGP" + name = "tf-eip" + description = "tf-test" + project_name = "default" +} + +resource "volcengine_eip_associate" "associate" { + allocation_id = volcengine_eip_address.eip.id + instance_id = volcengine_clb.private_clb.id + instance_type = "ClbInstance" } ``` ## Argument Reference @@ -29,18 +58,26 @@ The following arguments are supported: * `subnet_id` - (Required, ForceNew) The id of the Subnet. * `type` - (Required, ForceNew) The type of the CLB. And optional choice contains `public` or `private`. * `description` - (Optional) The description of the CLB. +* `eip_billing_config` - (Optional, ForceNew) The billing configuration of the EIP which automatically associated to CLB. This field is valid when the type of CLB is `public`.When the type of the CLB is `private`, suggest using a combination of resource `volcengine_eip_address` and `volcengine_eip_associate` to achieve public network access function. * `eni_address` - (Optional, ForceNew) The eni address of the CLB. -* `load_balancer_billing_type` - (Optional, ForceNew) The billing type of the CLB, the value can be `PostPaid`. +* `load_balancer_billing_type` - (Optional) The billing type of the CLB, the value can be `PostPaid` or `PrePaid`. * `load_balancer_name` - (Optional) The name of the CLB. * `master_zone_id` - (Optional) The master zone ID of the CLB. * `modification_protection_reason` - (Optional) The reason of the console modification protection. * `modification_protection_status` - (Optional) The status of the console modification protection, the value can be `NonProtection` or `ConsoleProtection`. +* `period` - (Optional) The period of the NatGateway, the valid value range in 1~9 or 12 or 24 or 36. Default value is 12. The period unit defaults to `Month`.This field is only effective when creating a PrePaid NatGateway. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `project_name` - (Optional) The ProjectName of the CLB. * `region_id` - (Optional, ForceNew) The region of the request. * `slave_zone_id` - (Optional) The slave zone ID of the CLB. * `tags` - (Optional) Tags. * `vpc_id` - (Optional, ForceNew) The id of the VPC. +The `eip_billing_config` object supports the following: + +* `eip_billing_type` - (Required, ForceNew) The billing type of the EIP which automatically assigned to CLB. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`.When creating a `PrePaid` public CLB, this field must be specified as `PrePaid` simultaneously.When the LoadBalancerBillingType changes from `PostPaid` to `PrePaid`, please manually modify the value of this field to `PrePaid` simultaneously. +* `isp` - (Required, ForceNew) The ISP of the EIP which automatically associated to CLB, the value can be `BGP`. +* `bandwidth` - (Optional) The peek bandwidth of the EIP which automatically assigned to CLB. The value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic. + The `tags` object supports the following: * `key` - (Required) The Key of Tags. @@ -49,7 +86,9 @@ The `tags` object supports the following: ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. - +* `eip_address` - The Eip address of the Clb. +* `eip_id` - The Eip ID of the Clb. +* `renew_type` - The renew type of the CLB. When the value of the load_balancer_billing_type is `PrePaid`, the query returns this field. ## Import diff --git a/website/docs/r/ecs_instance.html.markdown b/website/docs/r/ecs_instance.html.markdown index ee691a84..94506b67 100644 --- a/website/docs/r/ecs_instance.html.markdown +++ b/website/docs/r/ecs_instance.html.markdown @@ -34,8 +34,8 @@ 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" - description = "xym-tf-test-desc-1" + instance_name = "tf-ecs-test" + description = "tf-ecs-test-desc" password = "93f0cb0614Aab12" instance_charge_type = "PostPaid" system_volume_type = "PTSSD" @@ -47,12 +47,28 @@ resource "volcengine_ecs_instance" "default" { size = 100 delete_with_instance = true } - deployment_set_id = "" - ipv6_address_count = 1 + data_volumes { + volume_type = "PTSSD" + size = 50 + delete_with_instance = true + } + # deployment_set_id = "" + # ipv6_address_count = 1 # secondary_network_interfaces { # subnet_id = volcengine_subnet.foo1.id # security_group_ids = [volcengine_security_group.foo1.id] # } + + tags { + key = "tfk1" + value = "tfv1" + } + + tags { + key = "tfk2" + value = "tfv2" + } + } ``` ## Argument Reference @@ -61,7 +77,7 @@ The following arguments are supported: * `instance_type` - (Required) The instance type of ECS instance. * `security_group_ids` - (Required) The security group ID set of primary networkInterface. * `subnet_id` - (Required, ForceNew) The subnet ID of primary networkInterface. -* `system_volume_size` - (Required) The size of system volume. +* `system_volume_size` - (Required) The size of system volume. The value range of the system volume size is ESSD_PL0: 20~2048, ESSD_FlexPL: 20~2048, PTSSD: 10~500. * `system_volume_type` - (Required, ForceNew) The type of system volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`. * `auto_renew_period` - (Optional, ForceNew) The auto renew period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 1.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `auto_renew` - (Optional, ForceNew) The auto renew flag of ECS instance.Only effective when instance_charge_type is PrePaid. Default is true.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. @@ -83,7 +99,7 @@ The following arguments are supported: * `password` - (Optional) The password of ECS instance. * `period` - (Optional) The period of ECS instance.Only effective when instance_charge_type is PrePaid. Default is 12. Unit is Month. * `project_name` - (Optional) The ProjectName of the ecs instance. -* `secondary_network_interfaces` - (Optional) The secondary networkInterface detail collection of ECS instance. +* `secondary_network_interfaces` - (Optional, ForceNew) The secondary networkInterface detail collection of ECS instance. * `security_enhancement_strategy` - (Optional, ForceNew) The security enhancement strategy of ECS instance. The value can be Active or InActive. Default is Active.When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `spot_strategy` - (Optional, ForceNew) The spot strategy will autoremove instance in some conditions.Please make sure you can maintain instance lifecycle before auto remove.The spot strategy of ECS instance, the value can be `NoSpot` or `SpotAsPriceGo`. * `tags` - (Optional) Tags. @@ -92,7 +108,7 @@ The following arguments are supported: The `data_volumes` object supports the following: -* `size` - (Required, ForceNew) The size of volume. +* `size` - (Required, ForceNew) The size of volume. The value range of the data volume size is ESSD_PL0: 10~32768, ESSD_FlexPL: 10~32768, PTSSD: 20~8192. * `volume_type` - (Required, ForceNew) The type of volume, the value is `PTSSD` or `ESSD_PL0` or `ESSD_PL1` or `ESSD_PL2` or `ESSD_FlexPL`. * `delete_with_instance` - (Optional, ForceNew) The delete with instance flag of volume. diff --git a/website/docs/r/ecs_key_pair_associate.html.markdown b/website/docs/r/ecs_key_pair_associate.html.markdown index 515f807e..3c90c861 100644 --- a/website/docs/r/ecs_key_pair_associate.html.markdown +++ b/website/docs/r/ecs_key_pair_associate.html.markdown @@ -28,6 +28,11 @@ In addition to all arguments above, the following attributes are exported: ## Import ECS key pair associate can be imported using the id, e.g. + +After binding the key pair, the instance needs to be restarted for the key pair to take effect. + +After the key pair is bound, the password login method will automatically become invalid. If your instance has been set for password login, after the key pair is bound, you will no longer be able to use the password login method. + ``` $ terraform import volcengine_ecs_key_pair_associate.default kp-ybti5tkpkv2udbfolrft:i-mizl7m1kqccg5smt1bdpijuj ``` diff --git a/website/docs/r/eip_address.html.markdown b/website/docs/r/eip_address.html.markdown index dd184fe7..59d77b46 100644 --- a/website/docs/r/eip_address.html.markdown +++ b/website/docs/r/eip_address.html.markdown @@ -18,18 +18,19 @@ resource "volcengine_eip_address" "foo" { billing_type = "PostPaidByBandwidth" bandwidth = 1 isp = "ChinaUnicom" - name = "tf-project-1" + name = "tf-eip" description = "tf-test" - project_name = "yuwenhao" + project_name = "default" } ``` ## Argument Reference The following arguments are supported: -* `billing_type` - (Required) The billing type of the EIP Address. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic`. +* `billing_type` - (Required) The billing type of the EIP Address. And optional choice contains `PostPaidByBandwidth` or `PostPaidByTraffic` or `PrePaid`. * `bandwidth` - (Optional) The peek bandwidth of the EIP, the value range in 1~500 for PostPaidByBandwidth, and 1~200 for PostPaidByTraffic. * `description` - (Optional) The description of the EIP. -* `isp` - (Optional, ForceNew) The ISP of the EIP, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom`. +* `isp` - (Optional, ForceNew) The ISP of the EIP, the value can be `BGP` or `ChinaMobile` or `ChinaUnicom` or `ChinaTelecom` or `SingleLine_BGP` or `Static_BGP`. * `name` - (Optional) The name of the EIP Address. +* `period` - (Optional) The period of the EIP Address, the valid value range in 1~9 or 12 or 36. Default value is 12. The period unit defaults to `Month`.This field is only effective when creating a PrePaid Eip or changing the billing_type from PostPaid to PrePaid. * `project_name` - (Optional) The ProjectName of the EIP. * `tags` - (Optional) Tags. @@ -41,7 +42,10 @@ The `tags` object supports the following: ## Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. +* `deleted_time` - The deleted time of the EIP. * `eip_address` - The ip address of the EIP. +* `expired_time` - The expired time of the EIP. +* `overdue_time` - The overdue time of the EIP. * `status` - The status of the EIP. diff --git a/website/docs/r/eip_associate.html.markdown b/website/docs/r/eip_associate.html.markdown index 009f4f08..d3e93ad6 100644 --- a/website/docs/r/eip_associate.html.markdown +++ b/website/docs/r/eip_associate.html.markdown @@ -20,7 +20,7 @@ resource "volcengine_eip_associate" "foo" { The following arguments are supported: * `allocation_id` - (Required, ForceNew) The allocation id of the EIP. * `instance_id` - (Required, ForceNew) The instance id which be associated to the EIP. -* `instance_type` - (Required, ForceNew) The type of the associated instance,the value is `NAT` or `NetworkInterface` or `ClbInstance` or `EcsInstance` or `HaVip`. +* `instance_type` - (Required, ForceNew) The type of the associated instance,the value is `Nat` or `NetworkInterface` or `ClbInstance` or `EcsInstance` or `HaVip`. * `private_ip_address` - (Optional, ForceNew) The private IP address of the instance will be associated to the EIP. ## Attributes Reference diff --git a/website/docs/r/listener.html.markdown b/website/docs/r/listener.html.markdown index 224a3702..fd356af3 100644 --- a/website/docs/r/listener.html.markdown +++ b/website/docs/r/listener.html.markdown @@ -92,6 +92,8 @@ The `health_check` object supports the following: * `interval` - (Optional) The interval executing health check, default 2, range in 1~300. * `method` - (Optional) The method of health check, the value can be `GET` or `HEAD`. * `timeout` - (Optional) The response timeout of health check, default 2, range in 1~60.. +* `udp_expect` - (Optional) The UDP expect of health check. This field must be specified simultaneously with field `udp_request`. +* `udp_request` - (Optional) The UDP request of health check. This field must be specified simultaneously with field `udp_expect`. * `un_healthy_threshold` - (Optional) The unhealthy threshold of health check, default 3, range in 2~10. * `uri` - (Optional) The uri of health check. diff --git a/website/docs/r/nat_gateway.html.markdown b/website/docs/r/nat_gateway.html.markdown index 061104f1..425db2fc 100644 --- a/website/docs/r/nat_gateway.html.markdown +++ b/website/docs/r/nat_gateway.html.markdown @@ -19,6 +19,7 @@ resource "volcengine_nat_gateway" "foo" { subnet_id = "subnet-im67x70vxla88gbssz1hy1z2" spec = "Medium" nat_gateway_name = "tf-auto-demo-1" + billing_type = "PostPaid" description = "This nat gateway auto-created by terraform. " project_name = "default" } @@ -27,9 +28,10 @@ resource "volcengine_nat_gateway" "foo" { The following arguments are supported: * `subnet_id` - (Required, ForceNew) The ID of the Subnet. * `vpc_id` - (Required, ForceNew) The ID of the VPC. -* `billing_type` - (Optional, ForceNew) The billing type of the NatGateway, the value is `PostPaid`. +* `billing_type` - (Optional, ForceNew) The billing type of the NatGateway, the value is `PostPaid` or `PrePaid`. * `description` - (Optional) The description of the NatGateway. * `nat_gateway_name` - (Optional) The name of the NatGateway. +* `period` - (Optional, ForceNew) The period of the NatGateway, the valid value range in 1~9 or 12 or 24 or 36. Default value is 12. The period unit defaults to `Month`.This field is only effective when creating a PrePaid NatGateway. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `project_name` - (Optional) The ProjectName of the NatGateway. * `spec` - (Optional) The specification of the NatGateway. Optional choice contains `Small`(default), `Medium`, `Large`. * `tags` - (Optional) Tags. diff --git a/website/docs/r/network_acl.html.markdown b/website/docs/r/network_acl.html.markdown index 51320cf5..dafdca2e 100644 --- a/website/docs/r/network_acl.html.markdown +++ b/website/docs/r/network_acl.html.markdown @@ -11,20 +11,31 @@ Provides a resource to manage network acl ## Example Usage ```hcl resource "volcengine_network_acl" "foo" { - vpc_id = "vpc-12bk4qjc69reo17q7y36shv6z" + vpc_id = "vpc-2d6jskar243k058ozfdae13ne" network_acl_name = "tf-test-acl" + ingress_acl_entries { network_acl_entry_name = "ingress1" policy = "accept" protocol = "all" source_cidr_ip = "192.168.0.0/24" } + egress_acl_entries { network_acl_entry_name = "egress2" policy = "accept" protocol = "all" destination_cidr_ip = "192.168.0.0/16" } + + ingress_acl_entries { + network_acl_entry_name = "ingress3" + policy = "accept" + protocol = "tcp" + port = "80/80" + source_cidr_ip = "192.168.0.0/24" + } + project_name = "default" } ``` @@ -42,17 +53,17 @@ The `egress_acl_entries` object supports the following: * `description` - (Optional) The description of entry. * `destination_cidr_ip` - (Optional) The DestinationCidrIp of entry. * `network_acl_entry_name` - (Optional) The name of entry. -* `policy` - (Optional) The policy of entry. -* `port` - (Optional) The port of entry. -* `protocol` - (Optional) The protocol of entry. +* `policy` - (Optional) The policy of entry. Default is `accept`. The value can be `accept` or `drop`. +* `port` - (Optional) The port of entry. Default is `-1/-1`. When Protocol is `all`, `icmp` or `gre`, the port range is `-1/-1`, which means no port restriction.When the Protocol is `tcp` or `udp`, the port range is `1~65535`, and the format is `1/200`, `80/80`,which means port 1 to port 200, port 80. +* `protocol` - (Optional) The protocol of entry. The value can be `icmp` or `gre` or `tcp` or `udp` or `all`. Default is `all`. The `ingress_acl_entries` object supports the following: * `description` - (Optional) The description of entry. * `network_acl_entry_name` - (Optional) The name of entry. -* `policy` - (Optional) The policy of entry. -* `port` - (Optional) The port of entry. -* `protocol` - (Optional) The protocol of entry. +* `policy` - (Optional) The policy of entry, default is `accept`. The value can be `accept` or `drop`. +* `port` - (Optional) The port of entry. Default is `-1/-1`. When Protocol is `all`, `icmp` or `gre`, the port range is `-1/-1`, which means no port restriction. When the Protocol is `tcp` or `udp`, the port range is `1~65535`, and the format is `1/200`, `80/80`, which means port 1 to port 200, port 80. +* `protocol` - (Optional) The protocol of entry, default is `all`. The value can be `icmp` or `gre` or `tcp` or `udp` or `all`. * `source_cidr_ip` - (Optional) The SourceCidrIp of entry. ## Attributes Reference diff --git a/website/docs/r/scaling_configuration.html.markdown b/website/docs/r/scaling_configuration.html.markdown index ee1ecd0f..7a6ae524 100644 --- a/website/docs/r/scaling_configuration.html.markdown +++ b/website/docs/r/scaling_configuration.html.markdown @@ -16,14 +16,14 @@ use 'terraform state rm ${resourceId}' to remove. ```hcl resource "volcengine_scaling_configuration" "foo" { scaling_configuration_name = "tf-test" - scaling_group_id = "scg-ybru8pazhgl8j1di4tyd" - image_id = "image-ybpbrfay1gl8j1srwwyz" - instance_types = ["ecs.g1.4xlarge"] + scaling_group_id = "scg-ycinx27x25gh9y31p0fy" + image_id = "image-ycgud4t4hxgso0e27bdl" + instance_types = ["ecs.g2i.large"] instance_name = "tf-test" instance_description = "" host_name = "" password = "" - key_pair_name = "renhuaxi" + key_pair_name = "tf-keypair" security_enhancement_strategy = "InActive" volumes { volume_type = "ESSD_PL0" @@ -35,35 +35,55 @@ resource "volcengine_scaling_configuration" "foo" { size = 20 delete_with_instance = true } - security_group_ids = ["sg-2ff4fhdtlo8ao59gp67iiq9o3"] - eip_bandwidth = 0 + security_group_ids = ["sg-2fepz3c793g1s59gp67y21r34"] + eip_bandwidth = 10 eip_isp = "ChinaMobile" eip_billing_type = "PostPaidByBandwidth" user_data = "IyEvYmluL2Jhc2gKZWNobyAidGVzdCI=" + tags { + key = "tf-key1" + value = "tf-value1" + } + tags { + key = "tf-key2" + value = "tf-value2" + } + project_name = "default" + hpc_cluster_id = "" + spot_strategy = "NoSpot" } ``` ## Argument Reference The following arguments are supported: * `image_id` - (Required) The ECS image id which the scaling configuration set. * `instance_name` - (Required) The ECS instance name which the scaling configuration set. -* `instance_types` - (Required) The list of the ECS instance type which the scaling configuration set. +* `instance_types` - (Required) The list of the ECS instance type which the scaling configuration set. The maximum number of instance types is 10. * `scaling_configuration_name` - (Required) The name of the scaling configuration. * `scaling_group_id` - (Required, ForceNew) The id of the scaling group to which the scaling configuration belongs. -* `security_group_ids` - (Required) The list of the security group id of the networkInterface which the scaling configuration set. -* `volumes` - (Required) The list of volume of the scaling configuration. -* `eip_bandwidth` - (Optional) The EIP bandwidth which the scaling configuration set. +* `security_group_ids` - (Required) The list of the security group id of the networkInterface which the scaling configuration set. A maximum of 5 security groups can be bound at the same time, and the value ranges from 1 to 5. +* `volumes` - (Required) The list of volume of the scaling configuration. The number of supported volumes ranges from 1 to 15. +* `eip_bandwidth` - (Optional) The EIP bandwidth which the scaling configuration set. When the value of Eip.BillingType is PostPaidByBandwidth, the value is 1 to 500. When the value of Eip.BillingType is PostPaidByTraffic, the value is 1 to 200. * `eip_billing_type` - (Optional) The EIP billing type which the scaling configuration set. Valid values: PostPaidByBandwidth, PostPaidByTraffic. * `eip_isp` - (Optional) The EIP ISP which the scaling configuration set. Valid values: BGP, ChinaMobile, ChinaUnicom, ChinaTelecom. * `host_name` - (Optional) The ECS hostname which the scaling configuration set. +* `hpc_cluster_id` - (Optional) The ID of the HPC cluster to which the instance belongs. Valid only when InstanceTypes.N specifies High Performance Computing GPU Type. * `instance_description` - (Optional) The ECS instance description which the scaling configuration set. * `key_pair_name` - (Optional) The ECS key pair name which the scaling configuration set. * `password` - (Optional) The ECS password which the scaling configuration set. +* `project_name` - (Optional) The project to which the instance created by the scaling configuration belongs. * `security_enhancement_strategy` - (Optional) The Ecs security enhancement strategy which the scaling configuration set. Valid values: Active, InActive. +* `spot_strategy` - (Optional) The preemption policy of the instance. Valid Value: NoSpot (default), SpotAsPriceGo. +* `tags` - (Optional) The label of the instance created by the scaling configuration. Up to 20 tags are supported. * `user_data` - (Optional) The ECS user data which the scaling configuration set. +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. + The `volumes` object supports the following: -* `size` - (Required) The size of volume. +* `size` - (Required) The size of volume. System disk value range: 10 - 500. The value range of the data disk: 10 - 8192. * `volume_type` - (Required) The type of volume. * `delete_with_instance` - (Optional) The delete with instance flag of volume. Valid values: true, false. Default value: true. diff --git a/website/docs/r/scaling_configuration_attachment.html.markdown b/website/docs/r/scaling_configuration_attachment.html.markdown index 57896ee1..180b48f9 100644 --- a/website/docs/r/scaling_configuration_attachment.html.markdown +++ b/website/docs/r/scaling_configuration_attachment.html.markdown @@ -26,6 +26,7 @@ In addition to all arguments above, the following attributes are exported: ## Import Scaling Configuration attachment can be imported using the scaling_configuration_id e.g. +The launch template and scaling configuration cannot take effect at the same time. ``` $ terraform import volcengine_scaling_configuration_attachment.default enable:scc-ybrurj4uw6gh9zecj327 ``` diff --git a/website/docs/r/scaling_group.html.markdown b/website/docs/r/scaling_group.html.markdown index 0d7d2e8a..b2a04a65 100644 --- a/website/docs/r/scaling_group.html.markdown +++ b/website/docs/r/scaling_group.html.markdown @@ -11,35 +11,47 @@ Provides a resource to manage scaling group ## Example Usage ```hcl resource "volcengine_scaling_group" "foo" { - scaling_group_name = "tf-test" - subnet_ids = ["subnet-2ff1n75eyf08w59gp67qhnhqm"] + scaling_group_name = "test-tf" + subnet_ids = ["subnet-2fe79j7c8o5c059gp68ksxr93"] multi_az_policy = "BALANCE" desire_instance_number = 0 min_instance_number = 0 max_instance_number = 1 instance_terminate_policy = "OldestInstance" default_cooldown = 10 + project_name = "default" + tags { + key = "tf-key1" + value = "tf-value1" + } } ``` ## Argument Reference The following arguments are supported: -* `max_instance_number` - (Required) The max instance number of the scaling group. -* `min_instance_number` - (Required) The min instance number of the scaling group. +* `max_instance_number` - (Required) The max instance number of the scaling group. Value range: 0 ~ 100. +* `min_instance_number` - (Required) The min instance number of the scaling group. Value range: 0 ~ 100. * `scaling_group_name` - (Required) The name of the scaling group. * `subnet_ids` - (Required) The list of the subnet id to which the ENI is connected. -* `default_cooldown` - (Optional) The default cooldown interval of the scaling group. Default value: 300. +* `default_cooldown` - (Optional) The default cooldown interval of the scaling group. Value range: 5 ~ 86400, unit: second. Default value: 300. * `desire_instance_number` - (Optional) The desire instance number of the scaling group. * `instance_terminate_policy` - (Optional) The instance terminate policy of the scaling group. Valid values: OldestInstance, NewestInstance, OldestScalingConfigurationWithOldestInstance, OldestScalingConfigurationWithNewestInstance. Default value: OldestScalingConfigurationWithOldestInstance. -* `launch_template_id` - (Optional) The ID of the launch template bound to the scaling group. -* `launch_template_version` - (Optional) The version of the launch template bound to the scaling group. +* `launch_template_id` - (Optional) The ID of the launch template bound to the scaling group. The launch template and scaling configuration cannot take effect at the same time. +* `launch_template_version` - (Optional) The version of the launch template bound to the scaling group. Valid values are the version number, Latest, or Default. * `multi_az_policy` - (Optional) The multi az policy of the scaling group. Valid values: PRIORITY, BALANCE. Default value: PRIORITY. +* `project_name` - (Optional) The ProjectName of the scaling group. * `server_group_attributes` - (Optional) The load balancer server group attributes of the scaling group. +* `tags` - (Optional) Tags. The `server_group_attributes` object supports the following: -* `port` - (Required) The port receiving request of the server group. +* `port` - (Required) The port receiving request of the server group. Value range: 1 ~ 65535. * `server_group_id` - (Required) The id of the server group. -* `weight` - (Required) The weight of the instance. +* `weight` - (Required) The weight of the instance. Value range: 0 ~ 100. + +The `tags` object supports the following: + +* `key` - (Required) The Key of Tags. +* `value` - (Required) The Value of Tags. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/scaling_instance_attachment.html.markdown b/website/docs/r/scaling_instance_attachment.html.markdown index 42eb85ce..35158ca6 100644 --- a/website/docs/r/scaling_instance_attachment.html.markdown +++ b/website/docs/r/scaling_instance_attachment.html.markdown @@ -34,6 +34,7 @@ In addition to all arguments above, the following attributes are exported: ## Import Scaling instance attachment can be imported using the scaling_group_id and instance_id, e.g. +You can choose to remove or detach the instance according to the `delete_type` field. ``` $ terraform import volcengine_scaling_instance_attachment.default scg-mizl7m1kqccg5smt1bdpijuj:i-l8u2ai4j0fauo6mrpgk8 ``` diff --git a/website/docs/r/scaling_policy.html.markdown b/website/docs/r/scaling_policy.html.markdown index 87993fc7..22c1072d 100644 --- a/website/docs/r/scaling_policy.html.markdown +++ b/website/docs/r/scaling_policy.html.markdown @@ -33,22 +33,29 @@ resource "volcengine_scaling_policy" "foo" { ## Argument Reference The following arguments are supported: * `adjustment_type` - (Required) The adjustment type of the scaling policy. Valid values: QuantityChangeInCapacity, PercentChangeInCapacity, TotalCapacity. -* `adjustment_value` - (Required) The adjustment value of the scaling policy. +* `adjustment_value` - (Required) The adjustment value of the scaling policy. When the value of the `AdjustmentType` parameter is `QuantityChangeInCapacity`: -100 ~ 100, 0 is not allowed, unit: piece. When the value of the `AdjustmentType` parameter is `PercentChangeInCapacity`: -100 ~ 10000, 0 is not allowed, unit: %. When the value of the `AdjustmentType` parameter is `TotalCapacity`: the default is 0 to 100, unit: piece. * `scaling_group_id` - (Required, ForceNew) The id of the scaling group to which the scaling policy belongs. * `scaling_policy_name` - (Required) The name of the scaling policy. * `scaling_policy_type` - (Required, ForceNew) The type of scaling policy. Valid values: Scheduled, Recurrence, Alarm. * `active` - (Optional) The active flag of the scaling policy. [Warning] the scaling policy can be active only when the scaling group be active otherwise will fail. -* `alarm_policy_condition_comparison_operator` - (Optional) The comparison operator of the alarm policy condition of the scaling policy. Valid values: >, <, =. +* `alarm_policy_condition_comparison_operator` - (Optional) The comparison operator of the alarm policy condition of the scaling policy. Valid values: `>`, `<`, `=`. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`. * `alarm_policy_condition_metric_name` - (Optional) The metric name of the alarm policy condition of the scaling policy. Valid values: CpuTotal_Max, CpuTotal_Min, CpuTotal_Avg, MemoryUsedUtilization_Max, MemoryUsedUtilization_Min, MemoryUsedUtilization_Avg, Instance_CpuBusy_Max, Instance_CpuBusy_Min, Instance_CpuBusy_Avg. -* `alarm_policy_condition_metric_unit` - (Optional) The comparison operator of the alarm policy condition of the scaling policy. -* `alarm_policy_condition_threshold` - (Optional) The threshold of the alarm policy condition of the scaling policy. -* `alarm_policy_evaluation_count` - (Optional) The evaluation count of the alarm policy of the scaling policy. -* `alarm_policy_rule_type` - (Optional) The rule type of the alarm policy of the scaling policy. Valid value: Static. -* `cooldown` - (Optional) The cooldown of the scaling policy. Default value is the cooldown time of the scaling group. +* `alarm_policy_condition_metric_unit` - (Optional) The comparison operator of the alarm policy condition of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`. +* `alarm_policy_condition_threshold` - (Optional) The threshold of the alarm policy condition of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`. +* `alarm_policy_evaluation_count` - (Optional) The evaluation count of the alarm policy of the scaling policy. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`. +* `alarm_policy_rule_type` - (Optional) The rule type of the alarm policy of the scaling policy. Valid value: Static. It is only valid and required when the value of `ScalingPolicyType` is `Alarm`. +* `cooldown` - (Optional) The cooldown of the scaling policy. Default value is the cooldown time of the scaling group. Value: 0~86400, unit: second, if left blank, the cooling time of the scaling group will be used by default. * `scheduled_policy_launch_time` - (Optional) The launch time of the scheduled policy of the scaling policy. -* `scheduled_policy_recurrence_end_time` - (Optional) The recurrence end time of the scheduled policy of the scaling policy. +When the value of `ScalingPolicyType` is `Scheduled`, it means that the trigger time of the scheduled task must be greater than the current time. +When the value of `ScalingPolicyType` is `Recurrence`: If `ScheduledPolicy.RecurrenceType` is not specified, it means to execute only once according to the date and time specified here. +If `ScheduledPolicy.RecurrenceType` is specified, it indicates the start time of the periodic task. Only the time within 90 days from the date of creation/modification is supported. +When the value of `ScalingPolicyType` is `Alarm`, this parameter is invalid. +* `scheduled_policy_recurrence_end_time` - (Optional) The recurrence end time of the scheduled policy of the scaling policy. Valid and required when `ScalingPolicyType` is `Recurrence`. If not configured, it will default to the day/week/month after this moment according to the recurrence period (ScheduledPolicy.RecurrenceType). * `scheduled_policy_recurrence_type` - (Optional) The recurrence type the scheduled policy of the scaling policy. Valid values: Daily, Weekly, Monthly, Cron. -* `scheduled_policy_recurrence_value` - (Optional) The recurrence value the scheduled policy of the scaling policy. +* `scheduled_policy_recurrence_value` - (Optional) The recurrence value the scheduled policy of the scaling policy. Valid and required when `ScalingPolicyType` is `Recurrence`. When the value of the ScheduledPolicy.RecurrenceType parameter is Daily, only one value can be filled in, ranging from 1 to 31. +When the value of the ScheduledPolicy.RecurrenceType parameter is Weekly, you can enter multiple values separated by commas (,). The values from Monday to Sunday are: 1,2,3,4,5,6,7. +When the value of the ScheduledPolicy.RecurrenceType parameter is Monthly, the format is A-B. The value ranges of A and B are both 1~31, and B must be greater than or equal to A. +When the value of the ScheduledPolicy.RecurrenceType parameter is Cron, it means UTC+8 time, supports 5-field expressions of minutes, hours, days, months, and weeks, and supports wildcard English commas (,), English question marks (?), and conjunctions ( -), asterisk (*), pound sign (#), slash (/), L, and W. ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/vpn_connection.html.markdown b/website/docs/r/vpn_connection.html.markdown index d77482b0..28fa6781 100644 --- a/website/docs/r/vpn_connection.html.markdown +++ b/website/docs/r/vpn_connection.html.markdown @@ -25,42 +25,43 @@ resource "volcengine_vpn_connection" "foo" { ike_config_enc_alg = "aes" ike_config_auth_alg = "md5" ike_config_dh_group = "group2" - ike_config_lifetime = 100 + ike_config_lifetime = 9000 ike_config_local_id = "tf_test" ike_config_remote_id = "tf_test" ipsec_config_enc_alg = "aes" ipsec_config_auth_alg = "sha256" ipsec_config_dh_group = "group2" - ipsec_config_lifetime = 100 + ipsec_config_lifetime = 9000 project_name = "default" } ``` ## Argument Reference The following arguments are supported: * `customer_gateway_id` - (Required, ForceNew) The ID of the customer gateway. -* `ike_config_psk` - (Required) The psk of the ike config of the VPN connection. -* `local_subnet` - (Required) The local subnet of the VPN connection. -* `remote_subnet` - (Required) The remote subnet of the VPN connection. -* `attach_type` - (Optional, ForceNew) The attach type of the VPN connection, the value can be VpnGateway or TransitRouter. +* `ike_config_psk` - (Required) The psk of the ike config of the VPN connection. The length does not exceed 100 characters, and only uppercase and lowercase letters, special symbols and numbers are allowed. +* `local_subnet` - (Required) The local subnet of the VPN connection. Up to 5 network segments are supported. +* `remote_subnet` - (Required) The remote subnet of the VPN connection. Up to 5 network segments are supported. +* `attach_type` - (Optional, ForceNew) The attach type of the VPN connection, the value can be `VpnGateway` or `TransitRouter`. * `description` - (Optional) The description of the VPN connection. * `dpd_action` - (Optional) The dpd action of the VPN connection. -* `ike_config_auth_alg` - (Optional) The auth alg of the ike config of the VPN connection. -* `ike_config_dh_group` - (Optional) The dk group of the ike config of the VPN connection. -* `ike_config_enc_alg` - (Optional) The enc alg of the ike config of the VPN connection. -* `ike_config_lifetime` - (Optional) The lifetime of the ike config of the VPN connection. +* `ike_config_auth_alg` - (Optional) The auth alg of the ike config of the VPN connection. Valid value are `sha1`, `md5`, `sha256`, `sha384`, `sha512`, `sm3`. The default value is `sha1`. +* `ike_config_dh_group` - (Optional) The dk group of the ike config of the VPN connection. Valid value are `group1`, `group2`, `group5`, `group14`. The default value is `group2`. +* `ike_config_enc_alg` - (Optional) The enc alg of the ike config of the VPN connection. Valid value are `aes`, `aes192`, `aes256`, `des`, `3des`, `sm4`. The default value is `aes`. +* `ike_config_lifetime` - (Optional) The lifetime of the ike config of the VPN connection. Value: 900~86400. * `ike_config_local_id` - (Optional) The local_id of the ike config of the VPN connection. -* `ike_config_mode` - (Optional) The mode of the ike config of the VPN connection. +* `ike_config_mode` - (Optional) The mode of the ike config of the VPN connection. Valid values are `main`, `aggressive`, and default value is `main`. * `ike_config_remote_id` - (Optional) The remote id of the ike config of the VPN connection. -* `ike_config_version` - (Optional) The version of the ike config of the VPN connection. -* `ipsec_config_auth_alg` - (Optional) The auth alg of the ipsec config of the VPN connection. -* `ipsec_config_dh_group` - (Optional) The dh group of the ipsec config of the VPN connection. -* `ipsec_config_enc_alg` - (Optional) The enc alg of the ipsec config of the VPN connection. -* `ipsec_config_lifetime` - (Optional) The ipsec config of the ike config of the VPN connection. +* `ike_config_version` - (Optional) The version of the ike config of the VPN connection. The value can be `ikev1` or `ikev2`. The default value is `ikev1`. +* `ipsec_config_auth_alg` - (Optional) The auth alg of the ipsec config of the VPN connection. Valid value are `sha1`, `md5`, `sha256`, `sha384`, `sha512`, `sm3`. The default value is `sha1`. +* `ipsec_config_dh_group` - (Optional) The dh group of the ipsec config of the VPN connection. Valid value are `group1`, `group2`, `group5`, `group14` and `disable`. The default value is `group2`. +* `ipsec_config_enc_alg` - (Optional) The enc alg of the ipsec config of the VPN connection. Valid value are `aes`, `aes192`, `aes256`, `des`, `3des`, `sm4`. The default value is `aes`. +* `ipsec_config_lifetime` - (Optional) The ipsec config of the ike config of the VPN connection. Value: 900~86400. +* `log_enabled` - (Optional) Whether to enable connection logging. After enabling Connection Day, you can view and download IPsec connection logs, and use the log information to troubleshoot IPsec connection problems yourself. * `nat_traversal` - (Optional) The nat traversal of the VPN connection. * `negotiate_instantly` - (Optional) Whether to initiate negotiation mode immediately. * `project_name` - (Optional) The project name of the VPN connection. * `vpn_connection_name` - (Optional) The name of the VPN connection. -* `vpn_gateway_id` - (Optional, ForceNew) The ID of the vpn gateway. +* `vpn_gateway_id` - (Optional, ForceNew) The ID of the vpn gateway. If the `AttachType` is not passed or the passed value is `VpnGateway`, this parameter must be filled. If the value of `AttachType` is `TransitRouter`, this parameter does not need to be filled. ## Attributes Reference In addition to all arguments above, the following attributes are exported: @@ -72,7 +73,6 @@ In addition to all arguments above, the following attributes are exported: * `creation_time` - The create time of VPN connection. * `deleted_time` - The delete time of resource, valid when the attach type is 'TransitRouter'. * `ip_address` - The ip address of transit router, valid when the attach type is 'TransitRouter'. -* `log_enabled` - Whether to enable the connection log. * `overdue_time` - The overdue time of resource, valid when the attach type is 'TransitRouter'. * `status` - The status of the VPN connection. * `transit_router_id` - The id of transit router, valid when the attach type is 'TransitRouter'. diff --git a/website/docs/r/vpn_gateway.html.markdown b/website/docs/r/vpn_gateway.html.markdown index 3265fbe4..5240f82b 100644 --- a/website/docs/r/vpn_gateway.html.markdown +++ b/website/docs/r/vpn_gateway.html.markdown @@ -15,23 +15,25 @@ use 'terraform state rm ${resourceId}' to remove. ## Example Usage ```hcl resource "volcengine_vpn_gateway" "foo" { - vpc_id = "vpc-2fe19q1dn2g3k59gp68n7w3rr" - subnet_id = "subnet-2fe19qp20f3sw59gp67w8om25" + vpc_id = "vpc-12b31m7z2kc8w17q7y2fih9ts" + subnet_id = "subnet-12bh8g2d7fshs17q7y2nx82uk" bandwidth = 20 vpn_gateway_name = "tf-test" description = "tf-test" period = 2 - project_name = "yuwenhao" + project_name = "default" } ``` ## Argument Reference The following arguments are supported: -* `bandwidth` - (Required) The bandwidth of the VPN gateway. +* `bandwidth` - (Required) The bandwidth of the VPN gateway. Unit: Mbps. Values: 5, 10, 20, 50, 100, 200, 500. * `subnet_id` - (Required, ForceNew) The ID of the subnet where you want to create the VPN gateway. * `vpc_id` - (Required, ForceNew) The ID of the VPC where you want to create the VPN gateway. -* `billing_type` - (Optional, ForceNew) The BillingType of the VPN gateway. Terraform will only remove the PrePaid VPN gateway from the state file, not actually remove. +* `billing_type` - (Optional, ForceNew) The BillingType of the VPN gateway. Only support `PrePaid`. +Terraform will only remove the PrePaid VPN gateway from the state file, not actually remove. * `description` - (Optional) The description of the VPN gateway. -* `period` - (Optional) The Period of the VPN gateway. This parameter is only useful when creating vpn gateway. Default period unit is Month. +* `period` - (Optional) The Period of the VPN gateway. Default value is 12. This parameter is only useful when creating vpn gateway. Default period unit is Month. +Value range: 1~9, 12, 24, 36. When importing resources, this attribute will not be imported. If this attribute is set, please use lifecycle and ignore_changes ignore changes in fields. * `project_name` - (Optional) The project name of the VPN gateway. * `tags` - (Optional) Tags. * `vpn_gateway_name` - (Optional) The name of the VPN gateway. diff --git a/website/volcengine.erb b/website/volcengine.erb index 571d596c..921c0139 100644 --- a/website/volcengine.erb +++ b/website/volcengine.erb @@ -115,6 +115,9 @@
  • cen_route_entries
  • +
  • + cen_service_route_entries +
  • @@ -138,6 +141,12 @@
  • cen_inter_region_bandwidth
  • +
  • + cen_route_entry +
  • +
  • + cen_service_route_entry +