Skip to content

Commit 35a3d25

Browse files
committed
fix: update unit
1 parent cd6b7b4 commit 35a3d25

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Example Usage
55
66
```hcl
77
resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_attachment" {
8-
resource_ids = "lb-dv1ai6ma"
8+
resource_id = "lb-dv1ai6ma"
99
bandwidth_package_id = "bwp-atmf0p9g"
1010
network_type = "BGP"
1111
resource_type = "LoadBalance"
@@ -15,7 +15,7 @@ resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_atta
1515
```
1616
Import
1717
18-
vpc bandwidth_package_attachment can be imported using the id, e.g.
18+
vpc bandwidth_package_attachment can be imported using the bandwidthPackageId#resource_id, e.g.
1919
```
2020
$ terraform import tencentcloud_vpc_bandwidth_package_attachment.bandwidth_package_attachment bandwidthPackageAttachment_id
2121
```
@@ -46,30 +46,35 @@ func resourceTencentCloudVpcBandwidthPackageAttachment() *schema.Resource {
4646
"resource_id": {
4747
Type: schema.TypeString,
4848
Required: true,
49+
ForceNew: true,
4950
Description: "The unique ID of the resource, currently supports EIP resources and LB resources, such as `eip-xxxx`, `lb-xxxx`.",
5051
},
5152

5253
"bandwidth_package_id": {
5354
Type: schema.TypeString,
54-
Optional: true,
55+
Required: true,
56+
ForceNew: true,
5557
Description: "Bandwidth package unique ID, in the form of `bwp-xxxx`.",
5658
},
5759

5860
"network_type": {
5961
Type: schema.TypeString,
6062
Optional: true,
63+
ForceNew: true,
6164
Description: "Bandwidth packet type, currently supports `BGP` type, indicating that the internal resource is BGP IP.",
6265
},
6366

6467
"resource_type": {
6568
Type: schema.TypeString,
6669
Optional: true,
70+
ForceNew: true,
6771
Description: "Resource types, including `Address`, `LoadBalance`.",
6872
},
6973

7074
"protocol": {
7175
Type: schema.TypeString,
7276
Optional: true,
77+
ForceNew: true,
7378
Description: "Bandwidth packet protocol type. Currently `ipv4` and `ipv6` protocol types are supported.",
7479
},
7580
},
@@ -84,7 +89,6 @@ func resourceTencentCloudVpcBandwidthPackageAttachmentCreate(d *schema.ResourceD
8489

8590
var (
8691
request = vpc.NewAddBandwidthPackageResourcesRequest()
87-
response *vpc.AddBandwidthPackageResourcesResponse
8892
bandwidthPackageId string
8993
resourceId string
9094
)
@@ -100,17 +104,14 @@ func resourceTencentCloudVpcBandwidthPackageAttachmentCreate(d *schema.ResourceD
100104
}
101105

102106
if v, ok := d.GetOk("network_type"); ok {
103-
104107
request.NetworkType = helper.String(v.(string))
105108
}
106109

107110
if v, ok := d.GetOk("resource_type"); ok {
108-
109111
request.ResourceType = helper.String(v.(string))
110112
}
111113

112114
if v, ok := d.GetOk("protocol"); ok {
113-
114115
request.Protocol = helper.String(v.(string))
115116
}
116117

@@ -122,7 +123,6 @@ func resourceTencentCloudVpcBandwidthPackageAttachmentCreate(d *schema.ResourceD
122123
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
123124
logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
124125
}
125-
response = result
126126
return nil
127127
})
128128

tencentcloud/resource_tc_vpc_bandwidth_package_attachment_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ func TestAccTencentCloudVpcBandwidthPackageAttachment_basic(t *testing.T) {
2525
Config: testAccVpcBandwidthPackageAttachment,
2626
Check: resource.ComposeTestCheckFunc(
2727
testAccCheckBandwidthPackageAttachmentExists("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment"),
28-
resource.TestCheckResourceAttr("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment", "resource_ids", "lb-5dnrkgry"),
28+
resource.TestCheckResourceAttr("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment", "resource_id", "eip-r2l240dq"),
2929
resource.TestCheckResourceAttr("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment", "network_type", "BGP"),
30-
resource.TestCheckResourceAttr("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment", "resource_type", "LoadBalance"),
30+
resource.TestCheckResourceAttr("tencentcloud_vpc_bandwidth_package_attachment.bandwidthPackageAttachment", "resource_type", "Address"),
3131
),
3232
},
3333
},
@@ -112,11 +112,11 @@ resource "tencentcloud_vpc_bandwidth_package" "bandwidth_package" {
112112
}
113113
}
114114
115-
resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_attachment" {
116-
resource_ids = "lb-5dnrkgry"
115+
resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidthPackageAttachment" {
116+
resource_id = "eip-r2l240dq"
117117
bandwidth_package_id = tencentcloud_vpc_bandwidth_package.bandwidth_package.id
118118
network_type = "BGP"
119-
resource_type = "LoadBalance"
119+
resource_type = "Address"
120120
}
121121
122122
`

tencentcloud/service_tencentcloud_vpc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5285,6 +5285,12 @@ func (me *VpcService) DeleteVpcBandwidthPackageAttachmentById(ctx context.Contex
52855285

52865286
request := vpc.NewRemoveBandwidthPackageResourcesRequest()
52875287

5288+
if strings.HasPrefix(resourceId, "eip") {
5289+
request.ResourceType = helper.String("Address")
5290+
} else {
5291+
request.ResourceType = helper.String("LoadBalance")
5292+
}
5293+
52885294
request.BandwidthPackageId = &bandwidthPackageId
52895295
request.ResourceIds = []*string{&resourceId}
52905296

website/docs/r/vpc_bandwidth_package_attachment.html.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Provides a resource to create a vpc bandwidth_package_attachment
1515

1616
```hcl
1717
resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_attachment" {
18-
resource_ids = "lb-dv1ai6ma"
18+
resource_id = "lb-dv1ai6ma"
1919
bandwidth_package_id = "bwp-atmf0p9g"
2020
network_type = "BGP"
2121
resource_type = "LoadBalance"
@@ -27,11 +27,11 @@ resource "tencentcloud_vpc_bandwidth_package_attachment" "bandwidth_package_atta
2727

2828
The following arguments are supported:
2929

30-
* `resource_id` - (Required, String) The unique ID of the resource, currently supports EIP resources and LB resources, such as `eip-xxxx`, `lb-xxxx`.
31-
* `bandwidth_package_id` - (Optional, String) Bandwidth package unique ID, in the form of `bwp-xxxx`.
32-
* `network_type` - (Optional, String) Bandwidth packet type, currently supports `BGP` type, indicating that the internal resource is BGP IP.
33-
* `protocol` - (Optional, String) Bandwidth packet protocol type. Currently `ipv4` and `ipv6` protocol types are supported.
34-
* `resource_type` - (Optional, String) Resource types, including `Address`, `LoadBalance`.
30+
* `bandwidth_package_id` - (Required, String, ForceNew) Bandwidth package unique ID, in the form of `bwp-xxxx`.
31+
* `resource_id` - (Required, String, ForceNew) The unique ID of the resource, currently supports EIP resources and LB resources, such as `eip-xxxx`, `lb-xxxx`.
32+
* `network_type` - (Optional, String, ForceNew) Bandwidth packet type, currently supports `BGP` type, indicating that the internal resource is BGP IP.
33+
* `protocol` - (Optional, String, ForceNew) Bandwidth packet protocol type. Currently `ipv4` and `ipv6` protocol types are supported.
34+
* `resource_type` - (Optional, String, ForceNew) Resource types, including `Address`, `LoadBalance`.
3535

3636
## Attributes Reference
3737

@@ -43,7 +43,7 @@ In addition to all arguments above, the following attributes are exported:
4343

4444
## Import
4545

46-
vpc bandwidth_package_attachment can be imported using the id, e.g.
46+
vpc bandwidth_package_attachment can be imported using the bandwidthPackageId#resource_id, e.g.
4747
```
4848
$ terraform import tencentcloud_vpc_bandwidth_package_attachment.bandwidth_package_attachment bandwidthPackageAttachment_id
4949
```

0 commit comments

Comments
 (0)