@@ -783,30 +783,57 @@ func testAccCheckInstanceDestroy(s *terraform.State) error {
783
783
}
784
784
785
785
const testAccTencentCloudInstanceBasic = tcacctest .DefaultInstanceVariable + `
786
+ resource "tencentcloud_vpc" "vpc" {
787
+ name = "cvm-basic-vpc"
788
+ cidr_block = "10.0.0.0/16"
789
+ }
790
+
791
+ resource "tencentcloud_subnet" "subnet" {
792
+ vpc_id = tencentcloud_vpc.vpc.id
793
+ name = "cvm-basic-subnet"
794
+ cidr_block = "10.0.0.0/16"
795
+ availability_zone = var.availability_cvm_zone
796
+ }
797
+
786
798
resource "tencentcloud_instance" "cvm_basic" {
787
799
instance_name = var.instance_name
788
800
availability_zone = var.availability_cvm_zone
789
801
image_id = data.tencentcloud_images.default.images.0.image_id
790
802
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
791
- vpc_id = var.cvm_vpc_id
792
- subnet_id = var.cvm_subnet_id
803
+ vpc_id = tencentcloud_vpc.vpc.id
804
+ subnet_id = tencentcloud_subnet.subnet.id
793
805
system_disk_type = "CLOUD_PREMIUM"
794
806
project_id = 0
795
807
796
808
tags = {
797
809
hostname = "tci"
798
810
}
811
+ lifecycle {
812
+ ignore_changes = [instance_type]
813
+ }
799
814
}
800
815
`
801
816
802
817
const testAccTencentCloudInstancePrepaidBasic = tcacctest .DefaultInstanceVariable + `
818
+ resource "tencentcloud_vpc" "vpc" {
819
+ name = "cvm-prepaid-basic-vpc"
820
+ cidr_block = "10.0.0.0/16"
821
+ }
822
+
823
+ resource "tencentcloud_subnet" "subnet" {
824
+ vpc_id = tencentcloud_vpc.vpc.id
825
+ name = "cvm-prepaid-basic-subnet"
826
+ cidr_block = "10.0.0.0/16"
827
+ availability_zone = var.availability_cvm_zone
828
+ }
829
+
803
830
resource "tencentcloud_instance" "cvm_prepaid_basic" {
804
831
instance_name = var.instance_name
805
832
availability_zone = var.availability_cvm_zone
806
833
image_id = data.tencentcloud_images.default.images.0.image_id
807
834
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
808
- vpc_id = var.cvm_vpc_id
809
- subnet_id = var.cvm_subnet_id
835
+ vpc_id = tencentcloud_vpc.vpc.id
836
+ subnet_id = tencentcloud_subnet.subnet.id
810
837
system_disk_type = "CLOUD_PREMIUM"
811
838
project_id = 0
812
839
instance_charge_type = "PREPAID"
@@ -820,13 +847,25 @@ resource "tencentcloud_instance" "cvm_prepaid_basic" {
820
847
`
821
848
822
849
const testAccTencentCloudInstanceWithDataDiskOrder = tcacctest .DefaultInstanceVariable + `
850
+ resource "tencentcloud_vpc" "vpc" {
851
+ name = "cvm-with-cbs-order-vpc"
852
+ cidr_block = "10.0.0.0/16"
853
+ }
854
+
855
+ resource "tencentcloud_subnet" "subnet" {
856
+ vpc_id = tencentcloud_vpc.vpc.id
857
+ name = "cvm-with-cbs-order-subnet"
858
+ cidr_block = "10.0.0.0/16"
859
+ availability_zone = var.availability_cvm_zone
860
+ }
861
+
823
862
resource "tencentcloud_instance" "foo" {
824
863
instance_name = var.instance_name
825
864
availability_zone = var.availability_cvm_zone
826
865
image_id = data.tencentcloud_images.default.images.0.image_id
827
866
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
828
- vpc_id = var.cvm_vpc_id
829
- subnet_id = var.cvm_subnet_id
867
+ vpc_id = tencentcloud_vpc.vpc.id
868
+ subnet_id = tencentcloud_subnet.subnet.id
830
869
system_disk_type = "CLOUD_PREMIUM"
831
870
project_id = 0
832
871
@@ -849,13 +888,25 @@ resource "tencentcloud_instance" "foo" {
849
888
`
850
889
851
890
const testAccTencentCloudInstanceAddDataDiskByCbs = tcacctest .DefaultInstanceVariable + `
891
+ resource "tencentcloud_vpc" "vpc" {
892
+ name = "cvm-attach-cbs-vpc"
893
+ cidr_block = "10.0.0.0/16"
894
+ }
895
+
896
+ resource "tencentcloud_subnet" "subnet" {
897
+ vpc_id = tencentcloud_vpc.vpc.id
898
+ name = "cvm-attach-cbs-subnet"
899
+ cidr_block = "10.0.0.0/16"
900
+ availability_zone = var.availability_cvm_zone
901
+ }
902
+
852
903
resource "tencentcloud_instance" "cvm_add_data_disk_by_cbs" {
853
904
instance_name = "cvm-add-data-disk-by-cbs"
854
905
availability_zone = var.availability_cvm_zone
855
906
image_id = data.tencentcloud_images.default.images.0.image_id
856
907
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
857
- vpc_id = var.cvm_vpc_id
858
- subnet_id = var.cvm_subnet_id
908
+ vpc_id = tencentcloud_vpc.vpc.id
909
+ subnet_id = tencentcloud_subnet.subnet.id
859
910
system_disk_type = "CLOUD_PREMIUM"
860
911
project_id = 0
861
912
}
@@ -904,6 +955,9 @@ resource "tencentcloud_instance" "foo" {
904
955
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
905
956
system_disk_type = "CLOUD_PREMIUM"
906
957
force_delete = true
958
+ lifecycle {
959
+ ignore_changes = [instance_type]
960
+ }
907
961
}
908
962
`
909
963
@@ -928,6 +982,9 @@ resource "tencentcloud_instance" "foo" {
928
982
instance_charge_type_prepaid_period = 1
929
983
instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
930
984
force_delete = true
985
+ lifecycle {
986
+ ignore_changes = [instance_type]
987
+ }
931
988
}
932
989
`
933
990
@@ -939,19 +996,34 @@ data "tencentcloud_instance_types" "new_type" {
939
996
memory_size = 2
940
997
}
941
998
999
+ resource "tencentcloud_vpc" "vpc" {
1000
+ name = "cvm-basic-vpc"
1001
+ cidr_block = "10.0.0.0/16"
1002
+ }
1003
+
1004
+ resource "tencentcloud_subnet" "subnet" {
1005
+ vpc_id = tencentcloud_vpc.vpc.id
1006
+ name = "cvm-basic-subnet"
1007
+ cidr_block = "10.0.0.0/16"
1008
+ availability_zone = var.availability_cvm_zone
1009
+ }
1010
+
942
1011
resource "tencentcloud_instance" "cvm_basic" {
943
1012
instance_name = var.instance_name
944
1013
availability_zone = var.availability_cvm_zone
945
1014
image_id = data.tencentcloud_images.default.images.0.image_id
946
1015
instance_type = data.tencentcloud_instance_types.new_type.instance_types.0.instance_type
947
- vpc_id = var.cvm_vpc_id
948
- subnet_id = var.cvm_subnet_id
1016
+ vpc_id = tencentcloud_vpc.vpc.id
1017
+ subnet_id = tencentcloud_subnet.subnet.id
949
1018
system_disk_type = "CLOUD_PREMIUM"
950
1019
project_id = 0
951
1020
952
1021
tags = {
953
1022
hostname = "tci"
954
1023
}
1024
+ lifecycle {
1025
+ ignore_changes = [instance_type]
1026
+ }
955
1027
}
956
1028
`
957
1029
@@ -981,6 +1053,9 @@ resource "tencentcloud_instance" "foo" {
981
1053
982
1054
disable_security_service = true
983
1055
disable_monitor_service = true
1056
+ lifecycle {
1057
+ ignore_changes = [instance_type]
1058
+ }
984
1059
}
985
1060
`
986
1061
@@ -1078,6 +1153,9 @@ resource "tencentcloud_instance" "foo" {
1078
1153
1079
1154
disable_security_service = true
1080
1155
disable_monitor_service = true
1156
+ lifecycle {
1157
+ ignore_changes = [instance_type]
1158
+ }
1081
1159
}
1082
1160
`
1083
1161
@@ -1091,6 +1169,9 @@ resource "tencentcloud_instance" "foo" {
1091
1169
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1092
1170
allocate_public_ip = %s
1093
1171
system_disk_type = "CLOUD_PREMIUM"
1172
+ lifecycle {
1173
+ ignore_changes = [instance_type]
1174
+ }
1094
1175
}
1095
1176
` ,
1096
1177
hasPublicIp ,
@@ -1108,21 +1189,36 @@ resource "tencentcloud_instance" "foo" {
1108
1189
internet_max_bandwidth_out = %d
1109
1190
allocate_public_ip = %s
1110
1191
system_disk_type = "CLOUD_PREMIUM"
1192
+ lifecycle {
1193
+ ignore_changes = [instance_type]
1194
+ }
1111
1195
}
1112
1196
` ,
1113
1197
maxBandWidthOut , hasPublicIp ,
1114
1198
)
1115
1199
}
1116
1200
1117
1201
const testAccTencentCloudInstanceWithPrivateIP = tcacctest .DefaultInstanceVariable + `
1202
+ resource "tencentcloud_vpc" "vpc" {
1203
+ name = "cvm-with-privateip-vpc"
1204
+ cidr_block = "10.0.0.0/16"
1205
+ }
1206
+
1207
+ resource "tencentcloud_subnet" "subnet" {
1208
+ vpc_id = tencentcloud_vpc.vpc.id
1209
+ name = "cvm-with-privateip-subnet"
1210
+ cidr_block = "10.0.0.0/16"
1211
+ availability_zone = var.availability_cvm_zone
1212
+ }
1213
+
1118
1214
resource "tencentcloud_instance" "foo" {
1119
1215
instance_name = var.instance_name
1120
1216
availability_zone = var.availability_cvm_zone
1121
1217
image_id = data.tencentcloud_images.default.images.0.image_id
1122
1218
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1123
1219
system_disk_type = "CLOUD_PREMIUM"
1124
- vpc_id = var.cvm_vpc_id
1125
- subnet_id = var.cvm_subnet_id
1220
+ vpc_id = tencentcloud_vpc.vpc.id
1221
+ subnet_id = tencentcloud_subnet.subnet.id
1126
1222
private_ip = "10.0.0.123"
1127
1223
}
1128
1224
`
@@ -1134,6 +1230,9 @@ resource "tencentcloud_instance" "foo" {
1134
1230
image_id = data.tencentcloud_images.default.images.0.image_id
1135
1231
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1136
1232
system_disk_type = "CLOUD_PREMIUM"
1233
+ lifecycle {
1234
+ ignore_changes = [instance_type]
1235
+ }
1137
1236
}
1138
1237
`
1139
1238
@@ -1163,6 +1262,9 @@ resource "tencentcloud_instance" "foo" {
1163
1262
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1164
1263
key_ids = %s
1165
1264
system_disk_type = "CLOUD_PREMIUM"
1265
+ lifecycle {
1266
+ ignore_changes = [instance_type]
1267
+ }
1166
1268
}
1167
1269
` ,
1168
1270
keyIds ,
@@ -1179,6 +1281,9 @@ resource "tencentcloud_instance" "foo" {
1179
1281
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1180
1282
password = "%s"
1181
1283
system_disk_type = "CLOUD_PREMIUM"
1284
+ lifecycle {
1285
+ ignore_changes = [instance_type]
1286
+ }
1182
1287
}
1183
1288
` ,
1184
1289
password ,
@@ -1209,6 +1314,9 @@ resource "tencentcloud_instance" "foo" {
1209
1314
image_id = data.tencentcloud_images.default.images.0.image_id
1210
1315
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1211
1316
system_disk_type = "CLOUD_PREMIUM"
1317
+ lifecycle {
1318
+ ignore_changes = [instance_type]
1319
+ }
1212
1320
}
1213
1321
` ,
1214
1322
instanceName ,
@@ -1264,6 +1372,9 @@ resource "tencentcloud_instance" "foo" {
1264
1372
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1265
1373
system_disk_type = "CLOUD_PREMIUM"
1266
1374
security_groups = %s
1375
+ lifecycle {
1376
+ ignore_changes = [instance_type]
1377
+ }
1267
1378
}
1268
1379
` ,
1269
1380
ids ,
@@ -1284,6 +1395,9 @@ resource "tencentcloud_instance" "foo" {
1284
1395
data_disk_size = 150
1285
1396
delete_with_instance = true
1286
1397
}
1398
+ lifecycle {
1399
+ ignore_changes = [instance_type]
1400
+ }
1287
1401
tags = %s
1288
1402
}
1289
1403
` ,
@@ -1340,6 +1454,9 @@ resource "tencentcloud_instance" "cvm_with_orderly_sg" {
1340
1454
instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
1341
1455
system_disk_type = "CLOUD_PREMIUM"
1342
1456
orderly_security_groups = %s
1457
+ lifecycle {
1458
+ ignore_changes = [instance_type]
1459
+ }
1343
1460
}
1344
1461
` , sgs )
1345
1462
}
0 commit comments