@@ -703,17 +703,18 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
703
703
}
704
704
705
705
instanceId := ""
706
+
706
707
err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
707
708
ratelimit .Check ("create" )
708
709
response , err := meta .(* TencentCloudClient ).apiV3Conn .UseCvmClient ().RunInstances (request )
709
710
if err != nil {
710
711
log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
711
712
logId , request .GetAction (), request .ToJsonString (), err .Error ())
712
713
e , ok := err .(* sdkErrors.TencentCloudSDKError )
713
- if ok && e .Code == CVM_CLOUD_DISK_SOLD_OUT_ERROR {
714
- return resource .NonRetryableError ( e )
714
+ if ok && IsContains ( CVM_RETRYABLE_ERROR , e .Code ) {
715
+ return resource .RetryableError ( fmt . Errorf ( "cvm create error: %s, retrying" , e . Error ()) )
715
716
}
716
- return retryError (err )
717
+ return resource . NonRetryableError (err )
717
718
}
718
719
log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
719
720
logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
@@ -852,7 +853,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
852
853
if err != nil {
853
854
return err
854
855
}
855
- if instance == nil || * instance . InstanceState == CVM_STATUS_LAUNCH_FAILED {
856
+ if instance == nil {
856
857
d .SetId ("" )
857
858
return nil
858
859
}
@@ -909,9 +910,14 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
909
910
_ = d .Set ("allocate_public_ip" , len (instance .PublicIpAddresses ) > 0 )
910
911
}
911
912
913
+ tagService := TagService {client }
914
+
915
+ tags , err := tagService .DescribeResourceTags (ctx , "cvm" , "instance" , client .Region , d .Id ())
916
+ if err != nil {
917
+ return err
918
+ }
912
919
// as attachment add tencentcloud:autoscaling:auto-scaling-group-id tag automatically
913
920
// we should remove this tag, otherwise it will cause terraform state change
914
- tags := flattenCvmTagsMapping (instance .Tags )
915
921
delete (tags , "tencentcloud:autoscaling:auto-scaling-group-id" )
916
922
_ = d .Set ("tags" , tags )
917
923
0 commit comments