diff --git a/.changelog/3434.txt b/.changelog/3434.txt new file mode 100644 index 0000000000..6dd0f92141 --- /dev/null +++ b/.changelog/3434.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_clb_attachment: optmize `targets` code +``` diff --git a/tencentcloud/services/clb/resource_tc_clb_attachment.go b/tencentcloud/services/clb/resource_tc_clb_attachment.go index a64b59d9da..1aa87fed93 100644 --- a/tencentcloud/services/clb/resource_tc_clb_attachment.go +++ b/tencentcloud/services/clb/resource_tc_clb_attachment.go @@ -295,8 +295,7 @@ func resourceTencentCloudClbServerAttachmentRead(d *schema.ResourceData, meta in } targets = append(targets, target) - } else if *onlineTarget.Type == CLB_BACKEND_TYPE_ENI || *onlineTarget.Type == CLB_BACKEND_TYPE_NAT || - *onlineTarget.Type == CLB_BACKEND_TYPE_CCN || *onlineTarget.Type == CLB_BACKEND_TYPE_SRV { + } else { target := map[string]interface{}{ "weight": int(*onlineTarget.Weight), "port": int(*onlineTarget.Port), diff --git a/tencentcloud/services/clb/resource_tc_clb_attachment.md b/tencentcloud/services/clb/resource_tc_clb_attachment.md index d4983fc3c4..e4c633eb44 100644 --- a/tencentcloud/services/clb/resource_tc_clb_attachment.md +++ b/tencentcloud/services/clb/resource_tc_clb_attachment.md @@ -4,7 +4,7 @@ Provides a resource to create a CLB attachment. Example Usage -Bind a Cvm instance by using `rule_id` +Bind a Cvm instance by using rule_id ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -20,7 +20,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` -Bind a Cvm instance by using `domian` and `url` +Bind a Cvm instance by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -37,7 +37,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` -Bind multiple Cvm instances by using `rule_id` +Bind multiple Cvm instances by using rule_id ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -59,7 +59,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` -Bind multiple Cvm instances by using `domian` and `url` +Bind multiple Cvm instances by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -82,7 +82,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` -Bind backend target is ENI by using `rule_id` +Bind backend target is ENI by using rule_id ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -98,7 +98,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` -Bind backend target is ENI by using `domian` and `url` +Bind backend target is ENI by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -121,8 +121,10 @@ CLB attachment can be imported using the id, e.g. ``` $ terraform import tencentcloud_clb_attachment.example loc-4xxr2cy7#lbl-hh141sn9#lb-7a0t6zqb +``` Or +``` $ terraform import tencentcloud_clb_attachment.example test.com,/#lbl-hh141sn9#lb-7a0t6zqb ``` diff --git a/website/docs/r/clb_attachment.html.markdown b/website/docs/r/clb_attachment.html.markdown index 15a03fd6bd..b80b0a89a6 100644 --- a/website/docs/r/clb_attachment.html.markdown +++ b/website/docs/r/clb_attachment.html.markdown @@ -15,6 +15,8 @@ Provides a resource to create a CLB attachment. ## Example Usage +### Bind a Cvm instance by using rule_id + ```hcl resource "tencentcloud_clb_attachment" "example" { clb_id = "lb-k2zjp9lv" @@ -29,7 +31,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` - +### Bind a Cvm instance by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -46,7 +48,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` - +### Bind multiple Cvm instances by using rule_id ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -68,7 +70,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` - +### Bind multiple Cvm instances by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -91,7 +93,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` - +### Bind backend target is ENI by using rule_id ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -107,7 +109,7 @@ resource "tencentcloud_clb_attachment" "example" { } ``` - +### Bind backend target is ENI by using domian and url ```hcl resource "tencentcloud_clb_attachment" "example" { @@ -156,9 +158,11 @@ CLB attachment can be imported using the id, e.g. ``` $ terraform import tencentcloud_clb_attachment.example loc-4xxr2cy7#lbl-hh141sn9#lb-7a0t6zqb +``` Or +``` $ terraform import tencentcloud_clb_attachment.example test.com,/#lbl-hh141sn9#lb-7a0t6zqb ```