diff --git a/CHANGELOG.md b/CHANGELOG.md index 95ebb9dcb4..631bbc96a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,20 @@ -## 1.56.9 (Unreleased) +## 1.56.10 (Unreleased) +## 1.56.9 (Jun 09, 2021) + +BUG FIXES: + +* Resource `tencentcloud_instance` fix words spell, in tencendcloud/resource_tc_instance.go L45, data.tencentcloud_availability_zones.my_favorate_zones.zones.0.name change to data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name". +* Resource `tencentcloud_kubernetes_clusters` fix the description of is_non_static_ip_mode + +ENHANCEMENTS: + +* Resource `tencentcloud_clb_target_group` add create target group. +* Resource `tencentcloud_clb_instance` add internal CLB supports security group. +* Resource `tencentcloud_clb_instance` add supports open and close CLB security group, default is open. +* Resource `tencentcloud_clb_instance` add external CLB create multi AZ instance. +* Resource `tencentcloud_kubernetes_cluster` add supports params of img_id to assign image. +* Resource `tencentcloud_as_scaling_group` add MultiZoneSubnetPolicy. + ## 1.56.8 (May 26, 2021) ENHANCEMENTS: diff --git a/tencentcloud/data_source_tc_as_scaling_groups.go b/tencentcloud/data_source_tc_as_scaling_groups.go index ca36bf88ea..073450a064 100644 --- a/tencentcloud/data_source_tc_as_scaling_groups.go +++ b/tencentcloud/data_source_tc_as_scaling_groups.go @@ -196,6 +196,11 @@ func dataSourceTencentCloudAsScalingGroups() *schema.Resource { Computed: true, Description: "Tags of the scaling group.", }, + "multi_zone_subnet_policy": { + Type: schema.TypeString, + Computed: true, + Description: "Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY.", + }, }, }, }, @@ -241,23 +246,24 @@ func dataSourceTencentCloudAsScalingGroupRead(d *schema.ResourceData, meta inter } mapping := map[string]interface{}{ - "scaling_group_id": scalingGroup.AutoScalingGroupId, - "scaling_group_name": scalingGroup.AutoScalingGroupName, - "configuration_id": scalingGroup.LaunchConfigurationId, - "status": scalingGroup.AutoScalingGroupStatus, - "instance_count": scalingGroup.InstanceCount, - "max_size": scalingGroup.MaxSize, - "min_size": scalingGroup.MinSize, - "vpc_id": scalingGroup.VpcId, - "subnet_ids": helper.StringsInterfaces(scalingGroup.SubnetIdSet), - "zones": helper.StringsInterfaces(scalingGroup.ZoneSet), - "default_cooldown": scalingGroup.DefaultCooldown, - "desired_capacity": scalingGroup.DesiredCapacity, - "load_balancer_ids": helper.StringsInterfaces(scalingGroup.LoadBalancerIdSet), - "termination_policies": helper.StringsInterfaces(scalingGroup.TerminationPolicySet), - "retry_policy": scalingGroup.RetryPolicy, - "create_time": scalingGroup.CreatedTime, - "tags": tags, + "scaling_group_id": scalingGroup.AutoScalingGroupId, + "scaling_group_name": scalingGroup.AutoScalingGroupName, + "configuration_id": scalingGroup.LaunchConfigurationId, + "status": scalingGroup.AutoScalingGroupStatus, + "instance_count": scalingGroup.InstanceCount, + "max_size": scalingGroup.MaxSize, + "min_size": scalingGroup.MinSize, + "vpc_id": scalingGroup.VpcId, + "subnet_ids": helper.StringsInterfaces(scalingGroup.SubnetIdSet), + "zones": helper.StringsInterfaces(scalingGroup.ZoneSet), + "default_cooldown": scalingGroup.DefaultCooldown, + "desired_capacity": scalingGroup.DesiredCapacity, + "load_balancer_ids": helper.StringsInterfaces(scalingGroup.LoadBalancerIdSet), + "termination_policies": helper.StringsInterfaces(scalingGroup.TerminationPolicySet), + "retry_policy": scalingGroup.RetryPolicy, + "create_time": scalingGroup.CreatedTime, + "tags": tags, + "multi_zone_subnet_policy": scalingGroup.MultiZoneSubnetPolicy, } if scalingGroup.ForwardLoadBalancerSet != nil && len(scalingGroup.ForwardLoadBalancerSet) > 0 { forwardLoadBalancers := make([]map[string]interface{}, 0, len(scalingGroup.ForwardLoadBalancerSet)) diff --git a/tencentcloud/data_source_tc_clb_instances.go b/tencentcloud/data_source_tc_clb_instances.go index 5b627f0f91..207b90f2ff 100644 --- a/tencentcloud/data_source_tc_clb_instances.go +++ b/tencentcloud/data_source_tc_clb_instances.go @@ -56,6 +56,11 @@ func dataSourceTencentCloudClbInstances() *schema.Resource { Optional: true, Description: "Used to save results.", }, + "master_zone": { + Type: schema.TypeString, + Optional: true, + Description: "Master available zone id.", + }, "clb_list": { Type: schema.TypeList, Computed: true, @@ -154,6 +159,31 @@ func dataSourceTencentCloudClbInstances() *schema.Resource { Computed: true, Description: "Max bandwidth out, only applicable to open CLB. Valid value ranges is [1, 2048]. Unit is MB.", }, + "zone_id": { + Type: schema.TypeInt, + Computed: true, + Description: "Available zone unique id(numerical representation), This field maybe null, means cannot get a valid value.", + }, + "zone": { + Type: schema.TypeString, + Computed: true, + Description: "Available zone unique id(string representation), This field maybe null, means cannot get a valid value.", + }, + "zone_name": { + Type: schema.TypeString, + Computed: true, + Description: "Available zone name, This field maybe null, means cannot get a valid value.", + }, + "zone_region": { + Type: schema.TypeString, + Computed: true, + Description: "Region that this available zone belong to, This field maybe null, means cannot get a valid value.", + }, + "local_zone": { + Type: schema.TypeBool, + Computed: true, + Description: "Whether this available zone is local zone, This field maybe null, means cannot get a valid value.", + }, }, }, }, @@ -180,6 +210,9 @@ func dataSourceTencentCloudClbInstancesRead(d *schema.ResourceData, meta interfa if v, ok := d.GetOk("network_type"); ok { params["network_type"] = v.(string) } + if v, ok := d.GetOk("master_zone"); ok { + params["master_zone"] = v.(string) + } clbService := ClbService{ client: meta.(*TencentCloudClient).apiV3Conn, @@ -221,6 +254,14 @@ func dataSourceTencentCloudClbInstancesRead(d *schema.ResourceData, meta interfa mapping["internet_charge_type"] = *clbInstance.NetworkAttributes.InternetChargeType mapping["internet_bandwidth_max_out"] = *clbInstance.NetworkAttributes.InternetMaxBandwidthOut } + if clbInstance.MasterZone != nil { + mapping["zone_id"] = *clbInstance.MasterZone.ZoneId + mapping["zone"] = *clbInstance.MasterZone.Zone + mapping["zone_name"] = *clbInstance.MasterZone.ZoneName + mapping["zone_region"] = *clbInstance.MasterZone.ZoneRegion + mapping["local_zone"] = *clbInstance.MasterZone.LocalZone + } + if clbInstance.Tags != nil { tags := make(map[string]interface{}, len(clbInstance.Tags)) for _, t := range clbInstance.Tags { diff --git a/tencentcloud/data_source_tc_kubernetes_clusters.go b/tencentcloud/data_source_tc_kubernetes_clusters.go index 84f5f65410..e224f34fab 100644 --- a/tencentcloud/data_source_tc_kubernetes_clusters.go +++ b/tencentcloud/data_source_tc_kubernetes_clusters.go @@ -137,7 +137,7 @@ func tkeClusterInfo() map[string]*schema.Schema { "is_non_static_ip_mode": { Type: schema.TypeBool, Computed: true, - Description: "Indicates whether static ip mode is enabled.", + Description: "Indicates whether non-static ip mode is enabled.", }, "kube_proxy_mode": { Type: schema.TypeString, diff --git a/tencentcloud/extension_as.go b/tencentcloud/extension_as.go index fbd7e9202d..befe897056 100644 --- a/tencentcloud/extension_as.go +++ b/tencentcloud/extension_as.go @@ -147,3 +147,8 @@ const ( SCALING_GROUP_IN_ACTIVITY_STATUS = "IN_ACTIVITY" SCALING_GROUP_NOT_IN_ACTIVITY_STATUS = "NOT_IN_ACTIVITY" ) + +const ( + MultiZoneSubnetPolicyPriority = "PRIORITY" + MultiZoneSubnetPolicyEquality = "EQUALITY" +) diff --git a/tencentcloud/resource_tc_as_scaling_group.go b/tencentcloud/resource_tc_as_scaling_group.go index 54fd0616a2..7fe92412db 100644 --- a/tencentcloud/resource_tc_as_scaling_group.go +++ b/tencentcloud/resource_tc_as_scaling_group.go @@ -216,6 +216,13 @@ func resourceTencentCloudAsScalingGroup() *schema.Resource { Computed: true, Description: "The time when the AS group was created.", }, + "multi_zone_subnet_policy": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateAllowedStringValue([]string{MultiZoneSubnetPolicyPriority, + MultiZoneSubnetPolicyEquality}), + Description: "Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY.", + }, }, } } @@ -303,6 +310,10 @@ func resourceTencentCloudAsScalingGroupCreate(d *schema.ResourceData, meta inter } } + if v, ok := d.GetOk("multi_zone_subnet_policy"); ok { + request.MultiZoneSubnetPolicy = helper.String(v.(string)) + } + var id string if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) @@ -408,6 +419,7 @@ func resourceTencentCloudAsScalingGroupRead(d *schema.ResourceData, meta interfa _ = d.Set("termination_policies", helper.StringsInterfaces(scalingGroup.TerminationPolicySet)) _ = d.Set("retry_policy", scalingGroup.RetryPolicy) _ = d.Set("create_time", scalingGroup.CreatedTime) + _ = d.Set("multi_zone_subnet_policy", scalingGroup.MultiZoneSubnetPolicy) if scalingGroup.ForwardLoadBalancerSet != nil && len(scalingGroup.ForwardLoadBalancerSet) > 0 { forwardLoadBalancers := make([]map[string]interface{}, 0, len(scalingGroup.ForwardLoadBalancerSet)) @@ -521,6 +533,11 @@ func resourceTencentCloudAsScalingGroupUpdate(d *schema.ResourceData, meta inter } } + if d.HasChange("multi_zone_subnet_policy") { + updateAttrs = append(updateAttrs, "multi_zone_subnet_policy") + request.MultiZoneSubnetPolicy = helper.String(d.Get("multi_zone_subnet_policy").(string)) + } + if err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { ratelimit.Check(request.GetAction()) diff --git a/tencentcloud/resource_tc_clb_instance.go b/tencentcloud/resource_tc_clb_instance.go index 67e3f05882..c89b8c511c 100644 --- a/tencentcloud/resource_tc_clb_instance.go +++ b/tencentcloud/resource_tc_clb_instance.go @@ -37,6 +37,60 @@ resource "tencentcloud_clb_instance" "open_clb" { } ``` +Default enable + +```hcl +resource "tencentcloud_subnet" "subnet" { + availability_zone = "ap-guangzhou-1" + name = "sdk-feature-test" + vpc_id = tencentcloud_vpc.foo.id + cidr_block = "10.0.20.0/28" + is_multicast = false +} + +resource "tencentcloud_security_group" "sglab" { + name = "sg_o0ek7r93" + description = "favourite sg" + project_id = 0 +} + +resource "tencentcloud_vpc" "foo" { + name = "for-my-open-clb" + cidr_block = "10.0.0.0/16" + + tags = { + "test" = "mytest" + } +} + +resource "tencentcloud_clb_instance" "open_clb" { + network_type = "OPEN" + clb_name = "my-open-clb" + project_id = 0 + vpc_id = tencentcloud_vpc.foo.id + load_balancer_pass_to_target = true + + security_groups = [tencentcloud_security_group.sglab.id] + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + + tags = { + test = "open" + } +} +``` + +CREATE multiple instance + +```hcl +resource "tencentcloud_clb_instance" "open_clb1" { + network_type = "OPEN" + clb_name = "hello" + master_zone_id = "ap-guangzhou-3" +} +~ +``` + Import CLB instance can be imported using the id, e.g. @@ -135,7 +189,7 @@ func resourceTencentCloudClbInstance() *schema.Resource { Type: schema.TypeList, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, - Description: "Security groups of the CLB instance. Only supports `OPEN` CLBs.", + Description: "Security groups of the CLB instance. Supports both `OPEN` and `INTERNAL` CLBs.", }, "target_region_info_region": { Type: schema.TypeString, @@ -159,6 +213,27 @@ func resourceTencentCloudClbInstance() *schema.Resource { Computed: true, Description: "Network operator, only applicable to open CLB. Valid values are `CMCC`(China Mobile), `CTCC`(Telecom), `CUCC`(China Unicom) and `BGP`. If this ISP is specified, network billing method can only use the bandwidth package billing (BANDWIDTH_PACKAGE).", }, + "load_balancer_pass_to_target": { + Type: schema.TypeBool, + Optional: true, + Default: true, + Description: "Whether the target allow flow come from clb. If value is true, only check security group of clb, or check both clb and backend instance security group.", + }, + "master_zone_id": { + Type: schema.TypeString, + Optional: true, + Description: "Setting master zone id of cross available zone disaster recovery, only applicable to open CLB.", + }, + "zone_id": { + Type: schema.TypeString, + Optional: true, + Description: "Available zone id, only applicable to open CLB.", + }, + "slave_zone_id": { + Type: schema.TypeString, + Optional: true, + Description: "Setting slave zone id of cross available zone disaster recovery, only applicable to open CLB. this zone will undertake traffic when the master is down.", + }, }, } } @@ -197,11 +272,7 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac if (targetRegionInfoRegion != "" && targetRegionInfoVpcId == "") || (targetRegionInfoRegion == "" && targetRegionInfoVpcId != "") { return fmt.Errorf("[CHECK][CLB instance][Create] check: region and vpc_id must be set at same time") } - if _, ok := d.GetOk("security_groups"); ok { - if networkType == CLB_NETWORK_TYPE_INTERNAL { - return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support this operation with sercurity_groups") - } - } + request := clb.NewCreateLoadBalancerRequest() request.LoadBalancerType = helper.String(networkType) request.LoadBalancerName = helper.String(clbName) @@ -252,6 +323,26 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac } } + if v, ok := d.GetOk("master_zone_id"); ok { + if networkType == CLB_NETWORK_TYPE_INTERNAL { + return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support master zone id setting") + } + request.MasterZoneId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("zone_id"); ok { + if networkType == CLB_NETWORK_TYPE_INTERNAL { + return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support zone id setting") + } + request.ZoneId = helper.String(v.(string)) + } + + if v, ok := d.GetOk("slave_zone_id"); ok { + if networkType == CLB_NETWORK_TYPE_INTERNAL { + return fmt.Errorf("[CHECK][CLB instance][Create] check: INTERNAL network_type do not support slave zone id setting") + } + request.SlaveZoneId = helper.String(v.(string)) + } clbId := "" var response *clb.CreateLoadBalancerResponse err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { @@ -312,6 +403,7 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac } if targetRegionInfoRegion != "" { + isLoadBalancePassToTgt := d.Get("load_balancer_pass_to_target").(bool) targetRegionInfo := clb.TargetRegionInfo{ Region: &targetRegionInfoRegion, VpcId: &targetRegionInfoVpcId, @@ -319,6 +411,7 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac mRequest := clb.NewModifyLoadBalancerAttributesRequest() mRequest.LoadBalancerId = helper.String(clbId) mRequest.TargetRegionInfo = &targetRegionInfo + mRequest.LoadBalancerPassToTarget = &isLoadBalancePassToTgt err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { mResponse, e := meta.(*TencentCloudClient).apiV3Conn.UseClbClient().ModifyLoadBalancerAttributes(mRequest) if e != nil { @@ -402,6 +495,11 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{ _ = d.Set("internet_charge_type", instance.NetworkAttributes.InternetChargeType) } + _ = d.Set("load_balancer_pass_to_target", instance.LoadBalancerPassToTarget) + _ = d.Set("master_zone_id", instance.MasterZone) + _ = d.Set("zone_id", instance.MasterZone) + _ = d.Set("slave_zone_id", instance.MasterZone) + tcClient := meta.(*TencentCloudClient).apiV3Conn tagService := &TagService{client: tcClient} tags, err := tagService.DescribeResourceTags(ctx, "clb", "clb", tcClient.Region, d.Id()) @@ -428,6 +526,7 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac targetRegionInfo := clb.TargetRegionInfo{} internet := clb.InternetAccessible{} changed := false + isLoadBalancerPassToTgt := false if d.HasChange("clb_name") { changed = true @@ -469,6 +568,11 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac } } + if d.HasChange("load_balancer_pass_to_target") { + changed = true + isLoadBalancerPassToTgt = d.Get("load_balancer_pass_to_target").(bool) + } + if changed { request := clb.NewModifyLoadBalancerAttributesRequest() request.LoadBalancerId = helper.String(clbId) @@ -481,6 +585,9 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac if d.HasChange("internet_charge_type") || d.HasChange("internet_bandwidth_max_out") { request.InternetChargeInfo = &internet } + if d.HasChange("load_balancer_pass_to_target") { + request.LoadBalancerPassToTarget = &isLoadBalancerPassToTgt + } err := resource.Retry(writeRetryTimeout, func() *resource.RetryError { response, e := meta.(*TencentCloudClient).apiV3Conn.UseClbClient().ModifyLoadBalancerAttributes(request) if e != nil { @@ -515,9 +622,7 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac } if d.HasChange("security_groups") { - if d.Get("network_type") == CLB_NETWORK_TYPE_INTERNAL { - return fmt.Errorf("[CHECK][CLB instance %s][Update] check: INTERNAL network_type do not support this operation with sercurity_groups", clbId) - } + sgRequest := clb.NewSetLoadBalancerSecurityGroupsRequest() sgRequest.LoadBalancerId = helper.String(clbId) securityGroups := d.Get("security_groups").([]interface{}) diff --git a/tencentcloud/resource_tc_clb_instance_test.go b/tencentcloud/resource_tc_clb_instance_test.go index 30df298088..eb68d7c861 100644 --- a/tencentcloud/resource_tc_clb_instance_test.go +++ b/tencentcloud/resource_tc_clb_instance_test.go @@ -116,6 +116,82 @@ func TestAccTencentCloudClbInstance_internal(t *testing.T) { }) } +func TestAccTencentCloudClbInstance_default_enable(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccClbInstance_default_enable, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.default_enable"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "clb_name", "my_open_clb"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "project_id", "0"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "vpc_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "load_balancer_pass_to_target", "true"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "security_groups.0"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "target_region_info_region", "ap-guangzhou"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "target_region_info_vpc_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "tags.test", "open"), + ), + }, + { + Config: testAccClbInstance_default_enable_open, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.default_enable"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "clb_name", "my_open_clb"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "project_id", "0"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "vpc_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "load_balancer_pass_to_target", "true"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "security_groups.0"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "target_region_info_region", "ap-guangzhou"), + resource.TestCheckResourceAttrSet("tencentcloud_clb_instance.default_enable", "target_region_info_vpc_id"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.default_enable", "tags.test", "hello"), + ), + }, + }, + }) +} + +func TestAccTencentCloudClbInstance_multiple_instance(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccClbInstance__multi_instance, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.multiple_instance"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "clb_name", "my_open_clb"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "master_zone_id", "10001"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "slave_zone_id", "10002"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "tags.test", "mytest"), + ), + }, + { + Config: testAccClbInstance__multi_instance_update, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.multiple_instance"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "network_type", "OPEN"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "clb_name", "my_open_clb"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "master_zone_id", "10001"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "slave_zone_id", "10002"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.multiple_instance", "tags.test", "open"), + ), + }, + }, + }) +} + func testAccCheckClbInstanceDestroy(s *terraform.State) error { logId := getLogId(contextNil) ctx := context.WithValue(context.TODO(), logIdKey, logId) @@ -280,3 +356,119 @@ resource "tencentcloud_clb_instance" "clb_open" { } } ` + +const testAccClbInstance_default_enable = ` +variable "availability_zone" { + default = "ap-guangzhou-1" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = var.availability_zone + name = "sdk-feature-test" + vpc_id = tencentcloud_vpc.foo.id + cidr_block = "10.0.20.0/28" + is_multicast = false +} + +resource "tencentcloud_security_group" "sglab" { + name = "sg_o0ek7r93" + description = "favourite sg" + project_id = 0 +} + +resource "tencentcloud_vpc" "foo" { + name = "for-my-open-clb" + cidr_block = "10.0.0.0/16" + + tags = { + "test" = "mytest" + } +} + +resource "tencentcloud_clb_instance" "default_enable" { + network_type = "OPEN" + clb_name = "my-open-clb" + project_id = 0 + vpc_id = tencentcloud_vpc.foo.id + load_balancer_pass_to_target = true + + security_groups = [tencentcloud_security_group.sglab.id] + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + + tags = { + test = "open" + } +} +` + +const testAccClbInstance_default_enable_open = ` +variable "availability_zone" { + default = "ap-guangzhou-1" +} + +resource "tencentcloud_subnet" "subnet" { + availability_zone = var.availability_zone + name = "sdk-feature-test" + vpc_id = tencentcloud_vpc.foo.id + cidr_block = "10.0.20.0/28" + is_multicast = false +} + +resource "tencentcloud_security_group" "sglab" { + name = "sg_o0ek7r93" + description = "favourite sg" + project_id = 0 +} + +resource "tencentcloud_vpc" "foo" { + name = "for-my-open-clb" + cidr_block = "10.0.0.0/16" + + tags = { + "test" = "mytest" + } +} + +resource "tencentcloud_clb_instance" "default_enable" { + network_type = "OPEN" + clb_name = "my-open-clb" + project_id = 0 + vpc_id = tencentcloud_vpc.foo.id + load_balancer_pass_to_target = true + + security_groups = [tencentcloud_security_group.sglab.id] + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + + tags = { + test = "hello" + } +} +` + +const testAccClbInstance__multi_instance = ` +resource "tencentcloud_clb_instance" "multiple_instance" { + network_type = "OPEN" + clb_name = "my-open-clb" + master_zone_id = "10001" + slave_zone_id = "10002" + + tags = { + test = "open" + } +} +` + +const testAccClbInstance__multi_instance_update = ` +resource "tencentcloud_clb_instance" "multiple_instance" { + network_type = "OPEN" + clb_name = "my-open-clb" + master_zone_id = "10001" + slave_zone_id = "10002" + + tags = { + test = "open" + } +} +` diff --git a/tencentcloud/resource_tc_clb_target_group.go b/tencentcloud/resource_tc_clb_target_group.go index 510b8f9b6b..9f46a3ef40 100644 --- a/tencentcloud/resource_tc_clb_target_group.go +++ b/tencentcloud/resource_tc_clb_target_group.go @@ -10,6 +10,19 @@ resource "tencentcloud_clb_target_group" "test"{ } ``` +Create target group + +```hcl +resource "tencentcloud_clb_target_group" "test"{ + target_group_name = "hello1" + port = 18082 + target_group_instances { + bind_ip = "10.0.0.4" + port = 18080 + } +} +``` + Import CLB target group can be imported using the id, e.g. @@ -22,7 +35,6 @@ package tencentcloud import ( "context" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" clb "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb/v20180317" ) @@ -50,6 +62,44 @@ func resourceTencentCloudClbTargetGroup() *schema.Resource { ForceNew: true, Description: "VPC ID, default is based on the network.", }, + "port": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validatePort, + Description: "The default port of target group, add server after can use it.", + }, + "target_group_instances": { + Type: schema.TypeList, + Optional: true, + Description: "The backend server of target group bind.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "bind_ip": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validateIp, + Description: "The internal ip of target group instance.", + }, + "port": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validatePort, + Description: "The port of target group instance.", + }, + "weight": { + Type: schema.TypeInt, + Optional: true, + Description: "The weight of target group instance.", + }, + "new_port": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validatePort, + Description: "The new port of target group instance.", + }, + }, + }, + }, }, } } @@ -63,12 +113,31 @@ func resourceTencentCloudClbTargetCreate(d *schema.ResourceData, meta interface{ clbService = ClbService{client: meta.(*TencentCloudClient).apiV3Conn} vpcId = d.Get("vpc_id").(string) targetGroupName = d.Get("target_group_name").(string) + port = uint64(d.Get("port").(int)) insAttachments = make([]*clb.TargetGroupInstance, 0) targetGroupId string err error ) - targetGroupId, err = clbService.CreateTargetGroup(ctx, targetGroupName, vpcId, insAttachments) + if v, ok := d.GetOk("target_group_instances"); ok { + targetGroupInstances := v.([]interface{}) + for _, v1 := range targetGroupInstances { + value := v1.(map[string]interface{}) + bindIP := value["bind_ip"].(string) + port := uint64(value["port"].(int)) + weight := uint64(value["weight"].(int)) + newPort := uint64(value["new_port"].(int)) + tgtGrp := &clb.TargetGroupInstance{ + BindIP: &bindIP, + Port: &port, + Weight: &weight, + NewPort: &newPort, + } + insAttachments = append(insAttachments, tgtGrp) + } + } + + targetGroupId, err = clbService.CreateTargetGroup(ctx, targetGroupName, vpcId, port, insAttachments) if err != nil { return err } @@ -99,6 +168,7 @@ func resourceTencentCloudClbTargetRead(d *schema.ResourceData, meta interface{}) } _ = d.Set("target_group_name", targetGroupInfos[0].TargetGroupName) _ = d.Set("vpc_id", targetGroupInfos[0].VpcId) + _ = d.Set("port", targetGroupInfos[0].Port) return nil } @@ -111,15 +181,28 @@ func resourceTencentCloudClbTargetUpdate(d *schema.ResourceData, meta interface{ ctx = context.WithValue(context.TODO(), logIdKey, logId) clbService = ClbService{client: meta.(*TencentCloudClient).apiV3Conn} targetGroupId = d.Id() + port uint64 + tgtGroupName string ) + isChanged := false + if d.HasChange("port") { + isChanged = true + port = uint64(d.Get("port").(int)) + } + if d.HasChange("target_group_name") { - targetGroupName := d.Get("target_group_name").(string) - err := clbService.ModifyTargetGroup(ctx, targetGroupId, targetGroupName) + isChanged = true + tgtGroupName = d.Get("target_group_name").(string) + } + + if isChanged { + err := clbService.ModifyTargetGroup(ctx, targetGroupId, tgtGroupName, port) if err != nil { return err } } + return resourceTencentCloudClbTargetRead(d, meta) } diff --git a/tencentcloud/resource_tc_clb_target_group_test.go b/tencentcloud/resource_tc_clb_target_group_test.go index a30d3b0d6d..d9a0ac5639 100644 --- a/tencentcloud/resource_tc_clb_target_group_test.go +++ b/tencentcloud/resource_tc_clb_target_group_test.go @@ -28,6 +28,38 @@ func TestAccTencentCloudClbTargetGroup_basic(t *testing.T) { }) } +func TestAccTencentCloudClbInstanceTargetGroup(t *testing.T) { + t.Parallel() + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckClbInstanceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccClbInstanceTargetGroup, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.target_group"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_name", "tgt_grp_test"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "port", "33"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_instances.bind_ip", "10.0.0.4"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_instances.port", "33"), + ), + }, + { + Config: testAccClbInstanceTargetGroupUpdate, + Check: resource.ComposeTestCheckFunc( + testAccCheckClbInstanceExists("tencentcloud_clb_instance.target_group"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_name", "tgt_grp_test"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "port", "33"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_instances.bind_ip", "10.0.0.4"), + resource.TestCheckResourceAttr("tencentcloud_clb_instance.target_group", "target_group_instances.port", "44"), + ), + }, + }, + }) +} + func testAccCheckClbTargetGroupDestroy(s *terraform.State) error { logId := getLogId(contextNil) ctx := context.WithValue(context.TODO(), logIdKey, logId) @@ -81,3 +113,25 @@ resource "tencentcloud_clb_target_group" "test"{ target_group_name = "qwe" } ` + +const testAccClbInstanceTargetGroup = ` +resource "tencentcloud_clb_instance" "target_group" { + target_group_name = "tgt_grp_test" + port = 33 + target_group_instances { + bind_ip = "10.0.0.4" + port = 18800 + } +} +` + +const testAccClbInstanceTargetGroupUpdate = ` +resource "tencentcloud_clb_instance" "target_group" { + target_group_name = "tgt_grp_test" + port = 44 + target_group_instances { + bind_ip = "10.0.0.4" + port = 18800 + } +} +` diff --git a/tencentcloud/resource_tc_instance.go b/tencentcloud/resource_tc_instance.go index 859f378fb5..a1afc7acbc 100644 --- a/tencentcloud/resource_tc_instance.go +++ b/tencentcloud/resource_tc_instance.go @@ -42,7 +42,7 @@ resource "tencentcloud_subnet" "app" { // Create 2 CVM instances to host awesome_app resource "tencentcloud_instance" "my_awesome_app" { instance_name = "awesome_app" - availability_zone = data.tencentcloud_availability_zones.my_favorate_zones.zones.0.name + availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" diff --git a/tencentcloud/resource_tc_kubernetes_cluster.go b/tencentcloud/resource_tc_kubernetes_cluster.go index 09ea6efb12..e5a80aae90 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster.go +++ b/tencentcloud/resource_tc_kubernetes_cluster.go @@ -54,6 +54,7 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = data.tencentcloud_vpc_subnets.vpc_first.instance_list.0.subnet_id + img_id = "img-rkiynh11" data_disk { disk_type = "CLOUD_PREMIUM" @@ -549,12 +550,18 @@ func TkeCvmCreateInfo() map[string]*schema.Schema { Elem: &schema.Schema{Type: schema.TypeString}, Description: "Disaster recover groups to which a CVM instance belongs. Only support maximum 1.", }, + "img_id": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateImageID, + Description: "The valid image id, format of img-xxx.", + }, // InstanceAdvancedSettingsOverrides "desired_pod_num": { - Type: schema.TypeInt, - ForceNew: true, - Optional: true, - Default: -1, + Type: schema.TypeInt, + ForceNew: true, + Optional: true, + Default: -1, Description: "Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, " + "and it override `[globe_]desired_pod_num` for current node. Either all the fields `desired_pod_num` or none.", }, @@ -564,11 +571,11 @@ func TkeCvmCreateInfo() map[string]*schema.Schema { func TkeExistCvmCreateInfo() map[string]*schema.Schema { return map[string]*schema.Schema{ "node_role": { - Type: schema.TypeString, - ForceNew: true, - Optional: true, + Type: schema.TypeString, + ForceNew: true, + Optional: true, ValidateFunc: validateAllowedStringValue([]string{TKE_ROLE_WORKER, TKE_ROLE_MASTER_ETCD}), - Description: "Role of existed node. value:MASTER_ETCD or WORKER.", + Description: "Role of existed node. value:MASTER_ETCD or WORKER.", }, "instances_para": { Type: schema.TypeList, @@ -598,7 +605,6 @@ func TkeExistCvmCreateInfo() map[string]*schema.Schema { } } - func TkeNodePoolGlobalConfig() map[string]*schema.Schema { return map[string]*schema.Schema{ "is_scale_in_enabled": { @@ -787,24 +793,24 @@ func resourceTencentCloudTkeCluster() *schema.Resource { Description: "Cluster network type, GR or VPC-CNI. Default is GR.", }, "enable_customized_pod_cidr": { - Type: schema.TypeBool, - ForceNew: true, - Optional: true, - Default: false, - Description: "Whether to enable the custom mode of node podCIDR size. Default is false.", + Type: schema.TypeBool, + ForceNew: true, + Optional: true, + Default: false, + Description: "Whether to enable the custom mode of node podCIDR size. Default is false.", }, "base_pod_num": { - Type: schema.TypeInt, - ForceNew: true, - Optional: true, - Description: "The number of basic pods. valid when enable_customized_pod_cidr=true.", + Type: schema.TypeInt, + ForceNew: true, + Optional: true, + Description: "The number of basic pods. valid when enable_customized_pod_cidr=true.", }, "is_non_static_ip_mode": { Type: schema.TypeBool, ForceNew: true, Optional: true, Default: false, - Description: "Indicates whether static ip mode is enabled. Default is false.", + Description: "Indicates whether non-static ip mode is enabled. Default is false.", }, "deletion_protection": { Type: schema.TypeBool, @@ -1337,6 +1343,10 @@ func tkeGetCvmRunInstancesPara(dMap map[string]interface{}, meta interface{}, } } + if v, ok := dMap["img_id"]; ok { + request.ImageId = helper.String(v.(string)) + } + cvmJson = request.ToJsonString() cvmJson = strings.Replace(cvmJson, `"Password":"",`, "", -1) diff --git a/tencentcloud/resource_tc_kubernetes_cluster_test.go b/tencentcloud/resource_tc_kubernetes_cluster_test.go index aabb556f46..1e2049da1b 100644 --- a/tencentcloud/resource_tc_kubernetes_cluster_test.go +++ b/tencentcloud/resource_tc_kubernetes_cluster_test.go @@ -173,6 +173,7 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = data.tencentcloud_vpc_subnets.vpc.instance_list.0.subnet_id + img_id = "img-rkiynh11" data_disk { disk_type = "CLOUD_PREMIUM" diff --git a/tencentcloud/service_tencentcloud_clb.go b/tencentcloud/service_tencentcloud_clb.go index cd94744019..90f661f2dc 100644 --- a/tencentcloud/service_tencentcloud_clb.go +++ b/tencentcloud/service_tencentcloud_clb.go @@ -78,6 +78,9 @@ func (me *ClbService) DescribeLoadBalancerByFilter(ctx context.Context, params m projectId := int64(v.(int)) request.ProjectId = &projectId } + if k == "master_zone" { + request.MasterZone = helper.String(v.(string)) + } } offset := int64(0) @@ -1025,13 +1028,14 @@ func clbNewTarget(instanceId, port, weight interface{}) *clb.Target { return &bk } -func (me *ClbService) CreateTargetGroup(ctx context.Context, targetGroupName string, vpcId string, +func (me *ClbService) CreateTargetGroup(ctx context.Context, targetGroupName string, vpcId string, port uint64, targetGroupInstances []*clb.TargetGroupInstance) (targetGroupId string, err error) { var response *clb.CreateTargetGroupResponse request := clb.NewCreateTargetGroupRequest() request.TargetGroupName = &targetGroupName request.TargetGroupInstances = targetGroupInstances + request.Port = &port if vpcId != "" { request.VpcId = &vpcId } @@ -1054,10 +1058,11 @@ func (me *ClbService) CreateTargetGroup(ctx context.Context, targetGroupName str return } -func (me *ClbService) ModifyTargetGroup(ctx context.Context, targetGroupId string, targetGroupName string) (err error) { +func (me *ClbService) ModifyTargetGroup(ctx context.Context, targetGroupId, targetGroupName string, port uint64) (err error) { request := clb.NewModifyTargetGroupAttributeRequest() request.TargetGroupId = &targetGroupId request.TargetGroupName = &targetGroupName + request.Port = &port err = resource.Retry(writeRetryTimeout, func() *resource.RetryError { _, err := me.client.UseClbClient().ModifyTargetGroupAttribute(request) diff --git a/tencentcloud/validators.go b/tencentcloud/validators.go index 71506624e3..85b0baec97 100644 --- a/tencentcloud/validators.go +++ b/tencentcloud/validators.go @@ -65,6 +65,14 @@ func validateIp(v interface{}, k string) (ws []string, errors []error) { return } +func validateImageID(v interface{}, k string) (ws []string, errors []error) { + value := v.(string) + if !strings.HasPrefix(value, "img-") { + errors = append(errors, fmt.Errorf("the format of %q is invalid: %s, it should begin with `img-`", k, value)) + } + return +} + // NOTE not exactly strict, but ok for now func validateIntegerInRange(min, max int64) schema.SchemaValidateFunc { return func(v interface{}, k string) (ws []string, errors []error) { diff --git a/website/docs/d/as_scaling_groups.html.markdown b/website/docs/d/as_scaling_groups.html.markdown index 9cf6713bad..2d90f243e6 100644 --- a/website/docs/d/as_scaling_groups.html.markdown +++ b/website/docs/d/as_scaling_groups.html.markdown @@ -51,6 +51,7 @@ In addition to all arguments above, the following attributes are exported: * `load_balancer_ids` - A list of traditional clb ids which the CVM instances attached to. * `max_size` - The maximum number of CVM instances. * `min_size` - The minimum number of CVM instances. + * `multi_zone_subnet_policy` - Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY. * `project_id` - ID of the project to which the scaling group belongs. Default value is 0. * `retry_policy` - A retry policy can be used when a creation fails. * `scaling_group_id` - Auto scaling group ID. diff --git a/website/docs/d/clb_instances.html.markdown b/website/docs/d/clb_instances.html.markdown index 20480263b7..9a2123cb37 100644 --- a/website/docs/d/clb_instances.html.markdown +++ b/website/docs/d/clb_instances.html.markdown @@ -29,6 +29,7 @@ The following arguments are supported: * `clb_id` - (Optional) ID of the CLB to be queried. * `clb_name` - (Optional) Name of the CLB to be queried. +* `master_zone` - (Optional) Master available zone id. * `network_type` - (Optional) Type of CLB instance, and available values include `OPEN` and `INTERNAL`. * `project_id` - (Optional) Project ID of the CLB. * `result_output_file` - (Optional) Used to save results. @@ -45,6 +46,7 @@ In addition to all arguments above, the following attributes are exported: * `create_time` - Create time of the CLB. * `internet_bandwidth_max_out` - Max bandwidth out, only applicable to open CLB. Valid value ranges is [1, 2048]. Unit is MB. * `internet_charge_type` - Internet charge type, only applicable to open CLB. Valid values are `TRAFFIC_POSTPAID_BY_HOUR`, `BANDWIDTH_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`. + * `local_zone` - Whether this available zone is local zone, This field maybe null, means cannot get a valid value. * `network_type` - Types of CLB. * `project_id` - ID of the project. * `security_groups` - ID set of the security groups. @@ -56,5 +58,9 @@ In addition to all arguments above, the following attributes are exported: * `target_region_info_vpc_id` - VpcId information of backend service are attached the CLB. * `vip_isp` - Network operator, only applicable to open CLB. Valid values are `CMCC`(China Mobile), `CTCC`(Telecom), `CUCC`(China Unicom) and `BGP`. If this ISP is specified, network billing method can only use the bandwidth package billing (BANDWIDTH_PACKAGE). * `vpc_id` - ID of the VPC. + * `zone_id` - Available zone unique id(numerical representation), This field maybe null, means cannot get a valid value. + * `zone_name` - Available zone name, This field maybe null, means cannot get a valid value. + * `zone_region` - Region that this available zone belong to, This field maybe null, means cannot get a valid value. + * `zone` - Available zone unique id(string representation), This field maybe null, means cannot get a valid value. diff --git a/website/docs/d/kubernetes_clusters.html.markdown b/website/docs/d/kubernetes_clusters.html.markdown index 062d90c6dc..85ff8f6878 100644 --- a/website/docs/d/kubernetes_clusters.html.markdown +++ b/website/docs/d/kubernetes_clusters.html.markdown @@ -60,7 +60,7 @@ In addition to all arguments above, the following attributes are exported: * `domain` - Domain name for access. * `eni_subnet_ids` - Subnet IDs for cluster with VPC-CNI network mode. * `ignore_cluster_cidr_conflict` - Indicates whether to ignore the cluster cidr conflict error. - * `is_non_static_ip_mode` - Indicates whether static ip mode is enabled. + * `is_non_static_ip_mode` - Indicates whether non-static ip mode is enabled. * `kube_config` - kubernetes config. * `kube_proxy_mode` - Cluster kube-proxy mode. * `network_type` - Cluster network type. diff --git a/website/docs/r/as_scaling_group.html.markdown b/website/docs/r/as_scaling_group.html.markdown index 22cbd47ee5..8cccf3da58 100644 --- a/website/docs/r/as_scaling_group.html.markdown +++ b/website/docs/r/as_scaling_group.html.markdown @@ -53,6 +53,7 @@ The following arguments are supported: * `desired_capacity` - (Optional) Desired volume of CVM instances, which is between `max_size` and `min_size`. * `forward_balancer_ids` - (Optional) List of application load balancers, which can't be specified with `load_balancer_ids` together. * `load_balancer_ids` - (Optional) ID list of traditional load balancers. +* `multi_zone_subnet_policy` - (Optional) Multi zone or subnet strategy, Valid values: PRIORITY and EQUALITY. * `project_id` - (Optional) Specifies to which project the scaling group belongs. * `retry_policy` - (Optional) Available values for retry policies. Valid values: IMMEDIATE_RETRY and INCREMENTAL_INTERVALS. * `subnet_ids` - (Optional) ID list of subnet, and for VPC it is required. diff --git a/website/docs/r/clb_instance.html.markdown b/website/docs/r/clb_instance.html.markdown index ab9bc9fbee..81d40c09ee 100644 --- a/website/docs/r/clb_instance.html.markdown +++ b/website/docs/r/clb_instance.html.markdown @@ -47,6 +47,60 @@ resource "tencentcloud_clb_instance" "open_clb" { } ``` +Default enable + +```hcl +resource "tencentcloud_subnet" "subnet" { + availability_zone = "ap-guangzhou-1" + name = "sdk-feature-test" + vpc_id = tencentcloud_vpc.foo.id + cidr_block = "10.0.20.0/28" + is_multicast = false +} + +resource "tencentcloud_security_group" "sglab" { + name = "sg_o0ek7r93" + description = "favourite sg" + project_id = 0 +} + +resource "tencentcloud_vpc" "foo" { + name = "for-my-open-clb" + cidr_block = "10.0.0.0/16" + + tags = { + "test" = "mytest" + } +} + +resource "tencentcloud_clb_instance" "open_clb" { + network_type = "OPEN" + clb_name = "my-open-clb" + project_id = 0 + vpc_id = tencentcloud_vpc.foo.id + load_balancer_pass_to_target = true + + security_groups = [tencentcloud_security_group.sglab.id] + target_region_info_region = "ap-guangzhou" + target_region_info_vpc_id = tencentcloud_vpc.foo.id + + tags = { + test = "open" + } +} +``` + +CREATE multiple instance + +```hcl +resource "tencentcloud_clb_instance" "open_clb1" { + network_type = "OPEN" + clb_name = "hello" + master_zone_id = "ap-guangzhou-3" +} +~ +``` + ## Argument Reference The following arguments are supported: @@ -56,13 +110,17 @@ The following arguments are supported: * `address_ip_version` - (Optional) IP version, only applicable to open CLB. Valid values are `ipv4`, `ipv6` and `IPv6FullChain`. * `internet_bandwidth_max_out` - (Optional) Max bandwidth out, only applicable to open CLB. Valid value ranges is [1, 2048]. Unit is MB. * `internet_charge_type` - (Optional) Internet charge type, only applicable to open CLB. Valid values are `TRAFFIC_POSTPAID_BY_HOUR`, `BANDWIDTH_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`. +* `load_balancer_pass_to_target` - (Optional) Whether the target allow flow come from clb. If value is true, only check security group of clb, or check both clb and backend instance security group. +* `master_zone_id` - (Optional) Setting master zone id of cross available zone disaster recovery, only applicable to open CLB. * `project_id` - (Optional, ForceNew) ID of the project within the CLB instance, `0` - Default Project. -* `security_groups` - (Optional) Security groups of the CLB instance. Only supports `OPEN` CLBs. +* `security_groups` - (Optional) Security groups of the CLB instance. Supports both `OPEN` and `INTERNAL` CLBs. +* `slave_zone_id` - (Optional) Setting slave zone id of cross available zone disaster recovery, only applicable to open CLB. this zone will undertake traffic when the master is down. * `subnet_id` - (Optional, ForceNew) Subnet ID of the CLB. Effective only for CLB within the VPC. Only supports `INTERNAL` CLBs. Default is `ipv4`. * `tags` - (Optional) The available tags within this CLB. * `target_region_info_region` - (Optional) Region information of backend services are attached the CLB instance. Only supports `OPEN` CLBs. * `target_region_info_vpc_id` - (Optional) Vpc information of backend services are attached the CLB instance. Only supports `OPEN` CLBs. * `vpc_id` - (Optional, ForceNew) VPC ID of the CLB. +* `zone_id` - (Optional) Available zone id, only applicable to open CLB. ## Attributes Reference diff --git a/website/docs/r/clb_target_group.html.markdown b/website/docs/r/clb_target_group.html.markdown index 5c9c406024..13c416b1c4 100644 --- a/website/docs/r/clb_target_group.html.markdown +++ b/website/docs/r/clb_target_group.html.markdown @@ -20,13 +20,35 @@ resource "tencentcloud_clb_target_group" "test" { } ``` +Create target group + +```hcl +resource "tencentcloud_clb_target_group" "test" { + target_group_name = "hello1" + port = 18082 + target_group_instances { + bind_ip = "10.0.0.4" + port = 18080 + } +} +``` + ## Argument Reference The following arguments are supported: +* `port` - (Optional) The default port of target group, add server after can use it. +* `target_group_instances` - (Optional) The backend server of target group bind. * `target_group_name` - (Optional) Target group name. * `vpc_id` - (Optional, ForceNew) VPC ID, default is based on the network. +The `target_group_instances` object supports the following: + +* `bind_ip` - (Required) The internal ip of target group instance. +* `port` - (Required) The port of target group instance. +* `new_port` - (Optional) The new port of target group instance. +* `weight` - (Optional) The weight of target group instance. + ## Attributes Reference In addition to all arguments above, the following attributes are exported: diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index 3b5ffb8c7d..0b2d4582ae 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -52,7 +52,7 @@ resource "tencentcloud_subnet" "app" { // Create 2 CVM instances to host awesome_app resource "tencentcloud_instance" "my_awesome_app" { instance_name = "awesome_app" - availability_zone = data.tencentcloud_availability_zones.my_favorate_zones.zones.0.name + availability_zone = data.tencentcloud_availability_zones.my_favorite_zones.zones.0.name image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type system_disk_type = "CLOUD_PREMIUM" diff --git a/website/docs/r/kubernetes_cluster.html.markdown b/website/docs/r/kubernetes_cluster.html.markdown index 61810e72a9..c0a19cd1b7 100644 --- a/website/docs/r/kubernetes_cluster.html.markdown +++ b/website/docs/r/kubernetes_cluster.html.markdown @@ -64,6 +64,7 @@ resource "tencentcloud_kubernetes_cluster" "managed_cluster" { internet_max_bandwidth_out = 100 public_ip_assigned = true subnet_id = data.tencentcloud_vpc_subnets.vpc_first.instance_list.0.subnet_id + img_id = "img-rkiynh11" data_disk { disk_type = "CLOUD_PREMIUM" @@ -304,7 +305,7 @@ The following arguments are supported: * `extra_args` - (Optional, ForceNew) Custom parameter information related to the node. * `globe_desired_pod_num` - (Optional, ForceNew) Indicate to set desired pod number in node. valid when enable_customized_pod_cidr=true, and it takes effect for all nodes. * `ignore_cluster_cidr_conflict` - (Optional, ForceNew) Indicates whether to ignore the cluster cidr conflict error. Default is false. -* `is_non_static_ip_mode` - (Optional, ForceNew) Indicates whether static ip mode is enabled. Default is false. +* `is_non_static_ip_mode` - (Optional, ForceNew) Indicates whether non-static ip mode is enabled. Default is false. * `kube_proxy_mode` - (Optional) Cluster kube-proxy mode, the available values include: 'kube-proxy-bpf'. Default is not set.When set to kube-proxy-bpf, cluster version greater than 1.14 and with Tencent Linux 2.4 is required. * `labels` - (Optional, ForceNew) Labels of tke cluster nodes. * `managed_cluster_internet_security_policies` - (Optional) Security policies for managed cluster internet, like:'192.168.1.0/24' or '113.116.51.27', '0.0.0.0/0' means all. This field can only set when field `cluster_deploy_type` is 'MANAGED_CLUSTER' and `cluster_internet` is true. `managed_cluster_internet_security_policies` can not delete or empty once be set. @@ -355,6 +356,7 @@ The `master_config` object supports the following: * `enhanced_monitor_service` - (Optional, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE. * `enhanced_security_service` - (Optional, ForceNew) To specify whether to enable cloud security service. Default is TRUE. * `hostname` - (Optional, ForceNew) The host name of the attached instance. Dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-). +* `img_id` - (Optional) The valid image id, format of img-xxx. * `instance_charge_type_prepaid_period` - (Optional, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired. @@ -394,6 +396,7 @@ The `worker_config` object supports the following: * `enhanced_monitor_service` - (Optional, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE. * `enhanced_security_service` - (Optional, ForceNew) To specify whether to enable cloud security service. Default is TRUE. * `hostname` - (Optional, ForceNew) The host name of the attached instance. Dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-). +* `img_id` - (Optional) The valid image id, format of img-xxx. * `instance_charge_type_prepaid_period` - (Optional, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired. diff --git a/website/docs/r/kubernetes_scale_worker.html.markdown b/website/docs/r/kubernetes_scale_worker.html.markdown index 22d6725dd9..ab4341b199 100644 --- a/website/docs/r/kubernetes_scale_worker.html.markdown +++ b/website/docs/r/kubernetes_scale_worker.html.markdown @@ -151,6 +151,7 @@ The `worker_config` object supports the following: * `enhanced_monitor_service` - (Optional, ForceNew) To specify whether to enable cloud monitor service. Default is TRUE. * `enhanced_security_service` - (Optional, ForceNew) To specify whether to enable cloud security service. Default is TRUE. * `hostname` - (Optional, ForceNew) The host name of the attached instance. Dot (.) and dash (-) cannot be used as the first and last characters of HostName and cannot be used consecutively. Windows example: The length of the name character is [2, 15], letters (capitalization is not restricted), numbers and dashes (-) are allowed, dots (.) are not supported, and not all numbers are allowed. Examples of other types (Linux, etc.): The character length is [2, 60], and multiple dots are allowed. There is a segment between the dots. Each segment allows letters (with no limitation on capitalization), numbers and dashes (-). +* `img_id` - (Optional) The valid image id, format of img-xxx. * `instance_charge_type_prepaid_period` - (Optional, ForceNew) The tenancy (time unit is month) of the prepaid instance. NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`. * `instance_charge_type_prepaid_renew_flag` - (Optional, ForceNew) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`. * `instance_charge_type` - (Optional, ForceNew) The charge type of instance. Valid values are `PREPAID` and `POSTPAID_BY_HOUR`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR`, `PREPAID` instance will not terminated after cluster deleted, and may not allow to delete before expired.