@@ -703,17 +703,18 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
703703 }
704704
705705 instanceId := ""
706+
706707 err := resource .Retry (writeRetryTimeout , func () * resource.RetryError {
707708 ratelimit .Check ("create" )
708709 response , err := meta .(* TencentCloudClient ).apiV3Conn .UseCvmClient ().RunInstances (request )
709710 if err != nil {
710711 log .Printf ("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n " ,
711712 logId , request .GetAction (), request .ToJsonString (), err .Error ())
712713 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 ()) )
715716 }
716- return retryError (err )
717+ return resource . NonRetryableError (err )
717718 }
718719 log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " ,
719720 logId , request .GetAction (), request .ToJsonString (), response .ToJsonString ())
@@ -852,7 +853,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
852853 if err != nil {
853854 return err
854855 }
855- if instance == nil || * instance . InstanceState == CVM_STATUS_LAUNCH_FAILED {
856+ if instance == nil {
856857 d .SetId ("" )
857858 return nil
858859 }
@@ -909,9 +910,14 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
909910 _ = d .Set ("allocate_public_ip" , len (instance .PublicIpAddresses ) > 0 )
910911 }
911912
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+ }
912919 // as attachment add tencentcloud:autoscaling:auto-scaling-group-id tag automatically
913920 // we should remove this tag, otherwise it will cause terraform state change
914- tags := flattenCvmTagsMapping (instance .Tags )
915921 delete (tags , "tencentcloud:autoscaling:auto-scaling-group-id" )
916922 _ = d .Set ("tags" , tags )
917923
0 commit comments