Skip to content

Commit 8373884

Browse files
authored
fix: cvm - process launch failed and empty read result (#1270)
1 parent cc7b3a2 commit 8373884

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tencentcloud/resource_tc_instance.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -762,8 +762,11 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
762762
if errRet != nil {
763763
return retryError(errRet, InternalError)
764764
}
765-
if instance != nil && (*instance.InstanceState == CVM_STATUS_RUNNING ||
766-
*instance.InstanceState == CVM_STATUS_LAUNCH_FAILED) {
765+
if instance != nil && *instance.InstanceState == CVM_STATUS_LAUNCH_FAILED {
766+
//LatestOperationCodeMode
767+
return resource.NonRetryableError(fmt.Errorf("cvm instance %s launch failed, this resource will not be stored to tfstate and will auto removed\n.", *instance.InstanceId))
768+
}
769+
if instance != nil && *instance.InstanceState == CVM_STATUS_RUNNING {
767770
//get system disk ID
768771
if instance.SystemDisk != nil && instance.SystemDisk.DiskId != nil {
769772
systemDiskId = *instance.SystemDisk.DiskId
@@ -875,9 +878,9 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
875878
if err != nil {
876879
return err
877880
}
878-
if instance == nil {
881+
if instance == nil || *instance.InstanceState == CVM_STATUS_LAUNCH_FAILED {
879882
d.SetId("")
880-
return nil
883+
return fmt.Errorf("instance %s not exist or launch failed", instanceId)
881884
}
882885

883886
var cvmImages []string

0 commit comments

Comments
 (0)