diff --git a/.changelog/3460.txt b/.changelog/3460.txt deleted file mode 100644 index 3a3b395607..0000000000 --- a/.changelog/3460.txt +++ /dev/null @@ -1,3 +0,0 @@ -```release-note:enhancement -resource/tencentcloud_dnspod_record: fix weight set zero -``` \ No newline at end of file diff --git a/schema/metadata.yaml b/schema/metadata.yaml index 1a64fbf6a9..d2036a8c9e 100644 --- a/schema/metadata.yaml +++ b/schema/metadata.yaml @@ -1,7 +1,6 @@ provider_meta: metadata: display_name: 腾讯云资源 - icon_url: tencentcloud attr_orders: - name: domain - name: profile diff --git a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go index 42bf68fc74..c7076f1b81 100644 --- a/tencentcloud/services/dnspod/resource_tc_dnspod_record.go +++ b/tencentcloud/services/dnspod/resource_tc_dnspod_record.go @@ -69,7 +69,8 @@ func ResourceTencentCloudDnspodRecord() *schema.Resource { "weight": { Type: schema.TypeInt, Optional: true, - Description: "Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set.", + Default: 0, + Description: "Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set. Default is 0.", }, "status": { Type: schema.TypeString, @@ -117,7 +118,7 @@ func resourceTencentCloudDnspodRecordCreate(d *schema.ResourceData, meta interfa request.MX = helper.IntUint64(v.(int)) } request.TTL = helper.IntUint64(ttl) - if v, ok := d.GetOkExists("weight"); ok { + if v, ok := d.GetOk("weight"); ok { request.Weight = helper.IntUint64(v.(int)) } request.Status = &status @@ -268,7 +269,7 @@ func resourceTencentCloudDnspodRecordUpdate(d *schema.ResourceData, meta interfa ttl := v.(int) request.TTL = helper.IntUint64(ttl) } - if v, ok := d.GetOkExists("weight"); ok { + if v, ok := d.GetOk("weight"); ok { weight := v.(int) request.Weight = helper.IntUint64(weight) } diff --git a/tencentcloud/services/dnspod/resource_tc_dnspod_record_test.go b/tencentcloud/services/dnspod/resource_tc_dnspod_record_test.go index 51c9a680a4..764d2563b4 100644 --- a/tencentcloud/services/dnspod/resource_tc_dnspod_record_test.go +++ b/tencentcloud/services/dnspod/resource_tc_dnspod_record_test.go @@ -136,90 +136,6 @@ func TestAccTencentCloudDnspodRecordResource_MX(t *testing.T) { }) } -func TestAccTencentCloudDnspodRecordResource_WeightZero(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { tcacctest.AccPreCheck(t) }, - Providers: tcacctest.AccProviders, - CheckDestroy: testAccCheckDnspodRecordDestroy, - Steps: []resource.TestStep{ - { - Config: testAccTencentCloudDnspodRecordWeightZero, - Check: resource.ComposeTestCheckFunc( - testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "domain", "tencentcloud-terraform-provider.cn"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_type", "A"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_line", "默认"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "value", "1.2.3.10"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "sub_domain", "weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "remark", "terraform-test"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "weight", "0"), - ), - }, - { - Config: testAccTencentCloudDnspodRecordWeight, - Check: resource.ComposeTestCheckFunc( - testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "domain", "tencentcloud-terraform-provider.cn"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_type", "A"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_line", "默认"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "value", "1.2.3.10"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "sub_domain", "weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "remark", "terraform-test"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "weight", "10"), - ), - }, - { - ResourceName: "tencentcloud_dnspod_record.weight", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -func TestAccTencentCloudDnspodRecordResource_Weight(t *testing.T) { - t.Parallel() - resource.Test(t, resource.TestCase{ - PreCheck: func() { tcacctest.AccPreCheck(t) }, - Providers: tcacctest.AccProviders, - CheckDestroy: testAccCheckDnspodRecordDestroy, - Steps: []resource.TestStep{ - { - Config: testAccTencentCloudDnspodRecordWeight, - Check: resource.ComposeTestCheckFunc( - testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "domain", "tencentcloud-terraform-provider.cn"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_type", "A"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_line", "默认"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "value", "1.2.3.10"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "sub_domain", "weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "remark", "terraform-test"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "weight", "10"), - ), - }, - { - Config: testAccTencentCloudDnspodRecordWeightZero, - Check: resource.ComposeTestCheckFunc( - testAccCheckDnspodRecordExists("tencentcloud_dnspod_record.weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "domain", "tencentcloud-terraform-provider.cn"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_type", "A"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "record_line", "默认"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "value", "1.2.3.10"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "sub_domain", "weight"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "remark", "terraform-test"), - resource.TestCheckResourceAttr("tencentcloud_dnspod_record.weight", "weight", "0"), - ), - }, - { - ResourceName: "tencentcloud_dnspod_record.weight", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - func testAccCheckDnspodRecordExists(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -371,26 +287,3 @@ resource "tencentcloud_dnspod_record" "demo" { remark = "terraform-test" } ` - -const testAccTencentCloudDnspodRecordWeightZero = ` -resource "tencentcloud_dnspod_record" "weight" { - domain="tencentcloud-terraform-provider.cn" - record_type="A" - record_line="默认" - value="1.2.3.10" - sub_domain="weight" - remark="terraform-test" - weight=0 -} -` -const testAccTencentCloudDnspodRecordWeight = ` -resource "tencentcloud_dnspod_record" "weight" { - domain="tencentcloud-terraform-provider.cn" - record_type="A" - record_line="默认" - value="1.2.3.10" - sub_domain="weight" - remark="terraform-test" - weight=10 -} -` diff --git a/website/docs/r/dnspod_record.html.markdown b/website/docs/r/dnspod_record.html.markdown index d708a13465..87a9154a0b 100644 --- a/website/docs/r/dnspod_record.html.markdown +++ b/website/docs/r/dnspod_record.html.markdown @@ -38,7 +38,7 @@ The following arguments are supported: * `status` - (Optional, String) Records the initial state, with values ranging from ENABLE and DISABLE. The default is ENABLE, and if DISABLE is passed in, resolution will not take effect and the limits of load balancing will not be verified. * `sub_domain` - (Optional, String) The host records, default value is `@`. * `ttl` - (Optional, Int) TTL, the range is 1-604800, and the minimum value of different levels of domain names is different. Default is 600. -* `weight` - (Optional, Int) Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set. +* `weight` - (Optional, Int) Weight information. An integer from 0 to 100. Only enterprise VIP domain names are available, 0 means off, does not pass this parameter, means that the weight information is not set. Default is 0. ## Attributes Reference