@@ -23,7 +23,7 @@ func TestAccTencentCloudDataPostgresqlInstances(t *testing.T) {
2323 resource .TestCheckResourceAttrSet (testDataPostgresqlInstancesName , "instance_list.0.id" ),
2424 resource .TestCheckResourceAttrSet (testDataPostgresqlInstancesName , "instance_list.0.create_time" ),
2525 resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.charge_type" , "POSTPAID_BY_HOUR" ),
26- resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.engine_version" , "9.3.5 " ),
26+ resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.engine_version" , "10.4 " ),
2727 resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.project_id" , "0" ),
2828 resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.memory" , "2" ),
2929 resource .TestCheckResourceAttr (testDataPostgresqlInstancesName , "instance_list.0.storage" , "10" ),
@@ -39,27 +39,48 @@ func TestAccTencentCloudDataPostgresqlInstances(t *testing.T) {
3939}
4040
4141const testAccTencentCloudDataPostgresqlInstanceBasic = `
42- variable "availability_zone" {
43- default = "ap-guangzhou-2 "
42+ data "tencentcloud_availability_zones_by_product" "pg" {
43+ product = "postgres "
4444}
4545
46+ resource "tencentcloud_vpc" "vpc" {
47+ cidr_block = "10.0.0.0/24"
48+ name = "test-pg-vpc"
49+ }
50+
51+ resource "tencentcloud_subnet" "subnet" {
52+ availability_zone = local.az
53+ cidr_block = "10.0.0.0/24"
54+ name = "sub1"
55+ vpc_id = tencentcloud_vpc.vpc.id
56+ }
57+
58+ locals {
59+ az = data.tencentcloud_availability_zones_by_product.pg.zones.0.name
60+ vpc_id = tencentcloud_vpc.vpc.id
61+ subnet_id = tencentcloud_subnet.subnet.id
62+ }
63+
64+
4665resource "tencentcloud_postgresql_instance" "test" {
47- name = "tf_postsql_instance"
48- availability_zone = var.availability_zone
49- charge_type = "POSTPAID_BY_HOUR"
50- engine_version = "9.3.5"
51- root_password = "1qaA2k1wgvfa3ZZZ"
52- charset = "UTF8"
53- project_id = 0
54- memory = 2
55- storage = 10
66+ name = "tf_postsql_instance"
67+ availability_zone = local.az
68+ charge_type = "POSTPAID_BY_HOUR"
69+ engine_version = "10.4"
70+ root_password = "1qaA2k1wgvfa!_3ZZZ"
71+ charset = "UTF8"
72+ project_id = 0
73+ memory = 2
74+ storage = 10
75+ vpc_id = local.vpc_id
76+ subnet_id = local.subnet_id
5677
57- tags = {
58- tf = "test"
59- }
78+ tags = {
79+ tf = "test"
80+ }
6081}
6182
6283data "tencentcloud_postgresql_instances" "id_test"{
63- id = tencentcloud_postgresql_instance.test.id
84+ id = tencentcloud_postgresql_instance.test.id
6485}
6586`
0 commit comments