Skip to content

Commit dbe45cc

Browse files
committed
fix keep_image_login force new CVM when updating version
1 parent e46ab99 commit dbe45cc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tencentcloud/resource_tc_instance.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,16 @@ func resourceTencentCloudInstance() *schema.Resource {
339339
Description: "Password for the instance. In order for the new password to take effect, the instance will be restarted after the password change.",
340340
},
341341
"keep_image_login": {
342-
Type: schema.TypeBool,
343-
Optional: true,
344-
Default: false,
342+
Type: schema.TypeBool,
343+
Optional: true,
344+
Default: false,
345+
DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
346+
if new == "false" && old == "" || old == "false" && new == "false" {
347+
return true
348+
} else {
349+
return old == new
350+
}
351+
},
345352
ForceNew: true,
346353
ConflictsWith: []string{"key_name", "password"},
347354
Description: "Whether to keep image login or not, default is `false`. When the image type is private or shared or imported, this parameter can be set `true`.",
@@ -795,6 +802,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
795802
if instance.LoginSettings.KeepImageLogin != nil {
796803
_ = d.Set("keep_image_login", *instance.LoginSettings.KeepImageLogin == CVM_IMAGE_LOGIN)
797804
}
805+
798806
if *instance.InstanceState == CVM_STATUS_STOPPED {
799807
_ = d.Set("running_flag", false)
800808
} else {

0 commit comments

Comments
 (0)