Skip to content

Commit 6062495

Browse files
tongyimingmikatong
and
mikatong
authored
fix(ccn): [123456789] ccn attachment (#2913)
* fix ccn attachment * add changelog --------- Co-authored-by: mikatong <[email protected]>
1 parent 66d4b47 commit 6062495

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

.changelog/2913.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_ccn_attachment: fix attachment with ccn_uin
3+
```

tencentcloud/services/ccn/resource_tc_ccn_attachment.go

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -174,33 +174,36 @@ func resourceTencentCloudCcnAttachmentRead(d *schema.ResourceData, meta interfac
174174
instanceType = d.Get("instance_type").(string)
175175
instanceRegion = d.Get("instance_region").(string)
176176
instanceId = d.Get("instance_id").(string)
177-
onlineHas = true
178177
)
179178

180-
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
181-
_, has, e := service.DescribeCcn(ctx, ccnId)
182-
if e != nil {
183-
return tccommon.RetryError(e)
184-
}
179+
if _, ok := d.GetOk("ccn_uin"); !ok {
180+
onlineHas := true
185181

186-
if has == 0 {
187-
d.SetId("")
188-
onlineHas = false
189-
return nil
190-
}
182+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
183+
_, has, e := service.DescribeCcn(ctx, ccnId)
184+
if e != nil {
185+
return tccommon.RetryError(e)
186+
}
191187

192-
return nil
193-
})
188+
if has == 0 {
189+
d.SetId("")
190+
onlineHas = false
191+
return nil
192+
}
194193

195-
if err != nil {
196-
return err
197-
}
194+
return nil
195+
})
198196

199-
if !onlineHas {
200-
return nil
197+
if err != nil {
198+
return err
199+
}
200+
201+
if !onlineHas {
202+
return nil
203+
}
201204
}
202205

203-
err = resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
206+
err := resource.Retry(tccommon.ReadRetryTimeout, func() *resource.RetryError {
204207
info, has, e := service.DescribeCcnAttachedInstance(ctx, ccnId, instanceRegion, instanceType, instanceId)
205208
if e != nil {
206209
return tccommon.RetryError(e)

0 commit comments

Comments
 (0)