Skip to content

Commit 6143f93

Browse files
authored
Merge pull request #1504 from tencentcloudstack/fix/fix_bgp_attach_nil
fix when bgp attachment is nil
2 parents 9e2dacb + 502096f commit 6143f93

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

.changelog/1504.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_vpc_bandwidth_package_attachment: catch the error when bgp attach is nil
3+
```

tencentcloud/resource_tc_vpc_bandwidth_package.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,10 @@ func resourceTencentCloudVpcBandwidthPackageRead(d *schema.ResourceData, meta in
176176

177177
if bandwidthPackage == nil {
178178
d.SetId("")
179-
return fmt.Errorf("resource `bandwidthPackage` %s does not exist", bandwidthPackageId)
179+
log.Printf("[WARN]%s resource `tencentcloud_vpc_bandwidth_package` [%s] not found, please check if it has been deleted.",
180+
logId, bandwidthPackageId,
181+
)
182+
return nil
180183
}
181184

182185
if bandwidthPackage.NetworkType != nil {

tencentcloud/resource_tc_vpc_bandwidth_package_attachment.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ func resourceTencentCloudVpcBandwidthPackageAttachmentRead(d *schema.ResourceDat
153153

154154
if bandwidthPackageAttachment == nil {
155155
d.SetId("")
156-
return fmt.Errorf("resource `bandwidthPackageAttachment` %s does not exist", bandwidthPackageId)
156+
log.Printf("[WARN]%s resource `tencentcloud_vpc_bandwidth_package_attachment` [%s] not found, please check if it has been deleted.",
157+
logId, bandwidthPackageId,
158+
)
159+
return nil
157160
}
158161

159162
_ = d.Set("bandwidth_package_id", bandwidthPackageId)

tencentcloud/service_tencentcloud_vpc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5374,6 +5374,9 @@ func (me *VpcService) DescribeVpcBandwidthPackageAttachment(ctx context.Context,
53745374
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
53755375
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
53765376

5377+
if len(response.Response.ResourceSet) < 1 {
5378+
return
5379+
}
53775380
bandwidthPackageResources = response.Response.ResourceSet[0]
53785381

53795382
return

0 commit comments

Comments
 (0)