Skip to content

fix(ccn): [123456789] ccn attachment #2913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/2913.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_ccn_attachment: fix attachment with ccn_uin
```
41 changes: 22 additions & 19 deletions tencentcloud/services/ccn/resource_tc_ccn_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,33 +174,36 @@ func resourceTencentCloudCcnAttachmentRead(d *schema.ResourceData, meta interfac
instanceType = d.Get("instance_type").(string)
instanceRegion = d.Get("instance_region").(string)
instanceId = d.Get("instance_id").(string)
onlineHas = true
)

err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
_, has, e := service.DescribeCcn(ctx, ccnId)
if e != nil {
return tccommon.RetryError(e)
}
if _, ok := d.GetOk("ccn_uin"); !ok {
onlineHas := true

if has == 0 {
d.SetId("")
onlineHas = false
return nil
}
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
_, has, e := service.DescribeCcn(ctx, ccnId)
if e != nil {
return tccommon.RetryError(e)
}

return nil
})
if has == 0 {
d.SetId("")
onlineHas = false
return nil
}

if err != nil {
return err
}
return nil
})

if !onlineHas {
return nil
if err != nil {
return err
}

if !onlineHas {
return nil
}
}

err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
info, has, e := service.DescribeCcnAttachedInstance(ctx, ccnId, instanceRegion, instanceType, instanceId)
if e != nil {
return tccommon.RetryError(e)
Expand Down
Loading