Skip to content

Commit ca52094

Browse files
committed
add
1 parent 8486489 commit ca52094

File tree

3 files changed

+77
-45
lines changed

3 files changed

+77
-45
lines changed

tencentcloud/services/tmp/resource_tc_monitor_tmp_instance.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ resource "tencentcloud_subnet" "subnet" {
1919
cidr_block = "10.0.1.0/24"
2020
}
2121
22-
resource "tencentcloud_monitor_tmp_instance" "foo" {
22+
resource "tencentcloud_monitor_tmp_instance" "example" {
2323
instance_name = "tf-tmp-instance"
2424
vpc_id = tencentcloud_vpc.vpc.id
2525
subnet_id = tencentcloud_subnet.subnet.id
@@ -29,11 +29,10 @@ resource "tencentcloud_monitor_tmp_instance" "foo" {
2929
"createdBy" = "terraform"
3030
}
3131
}
32-
3332
```
3433
Import
3534

3635
monitor tmpInstance can be imported using the id, e.g.
3736
```
38-
$ terraform import tencentcloud_monitor_tmp_instance.tmpInstance tmpInstance_id
39-
```
37+
$ terraform import tencentcloud_monitor_tmp_instance.example prom-1uvo0tjm
38+
```

tencentcloud/services/tmp/resource_tc_monitor_tmp_instance_test.go

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
1616
)
1717

18+
// go test -i; go test -test.run TestAccTencentCloudMonitorInstance_basic -v
1819
func TestAccTencentCloudMonitorInstance_basic(t *testing.T) {
1920
t.Parallel()
2021
resource.Test(t, resource.TestCase{
@@ -25,24 +26,30 @@ func TestAccTencentCloudMonitorInstance_basic(t *testing.T) {
2526
{
2627
Config: testInstance_basic,
2728
Check: resource.ComposeTestCheckFunc(
28-
testAccCheckInstanceExists("tencentcloud_monitor_tmp_instance.basic"),
29-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.basic", "instance_name", "demo-test"),
30-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.basic", "data_retention_time", "30"),
29+
testAccCheckInstanceExists("tencentcloud_monitor_tmp_instance.example"),
30+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.example", "instance_name", "tf-tmp-instance"),
31+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "vpc_id"),
32+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "subnet_id"),
33+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.example", "data_retention_time", "30"),
34+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "zone"),
3135
),
3236
},
3337
{
3438
Config: testInstance_update,
3539
Check: resource.ComposeTestCheckFunc(
36-
testAccCheckInstanceExists("tencentcloud_monitor_tmp_instance.update"),
37-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.update", "instance_name", "demo-test-update"),
38-
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.update", "data_retention_time", "30"),
40+
testAccCheckInstanceExists("tencentcloud_monitor_tmp_instance.example"),
41+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.example", "instance_name", "tf-tmp-instance-update"),
42+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "vpc_id"),
43+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "subnet_id"),
44+
resource.TestCheckResourceAttr("tencentcloud_monitor_tmp_instance.example", "data_retention_time", "90"),
45+
resource.TestCheckResourceAttrSet("tencentcloud_monitor_tmp_instance.example", "zone"),
3946
),
4047
},
41-
//{
42-
// ResourceName: "tencentcloud_monitor_tmp_instance.basic",
43-
// ImportState: true,
44-
// ImportStateVerify: true,
45-
//},
48+
{
49+
ResourceName: "tencentcloud_monitor_tmp_instance.example",
50+
ImportState: true,
51+
ImportStateVerify: true,
52+
},
4653
},
4754
})
4855
}
@@ -103,34 +110,60 @@ func testAccCheckInstanceExists(r string) resource.TestCheckFunc {
103110
}
104111
}
105112

106-
const testInstanceVar = tcacctest.DefaultAzVariable + `
107-
variable "vpc_id" {
108-
default = "` + tcacctest.DefaultTmpVpcId + `"
113+
const testInstance_basic = `
114+
variable "availability_zone" {
115+
default = "ap-guangzhou-4"
116+
}
117+
118+
resource "tencentcloud_vpc" "vpc" {
119+
cidr_block = "10.0.0.0/16"
120+
name = "tf_monitor_vpc"
121+
}
122+
123+
resource "tencentcloud_subnet" "subnet" {
124+
vpc_id = tencentcloud_vpc.vpc.id
125+
availability_zone = var.availability_zone
126+
name = "tf_monitor_subnet"
127+
cidr_block = "10.0.1.0/24"
128+
}
129+
130+
resource "tencentcloud_monitor_tmp_instance" "example" {
131+
instance_name = "tf-tmp-instance"
132+
vpc_id = tencentcloud_vpc.vpc.id
133+
subnet_id = tencentcloud_subnet.subnet.id
134+
data_retention_time = 30
135+
zone = var.availability_zone
136+
tags = {
137+
"createdBy" = "terraform"
138+
}
109139
}
110-
variable "subnet_id" {
111-
default = "` + tcacctest.DefaultTmpSubnetId + `"
140+
`
141+
142+
const testInstance_update = `
143+
variable "availability_zone" {
144+
default = "ap-guangzhou-4"
145+
}
146+
147+
resource "tencentcloud_vpc" "vpc" {
148+
cidr_block = "10.0.0.0/16"
149+
name = "tf_monitor_vpc"
150+
}
151+
152+
resource "tencentcloud_subnet" "subnet" {
153+
vpc_id = tencentcloud_vpc.vpc.id
154+
availability_zone = var.availability_zone
155+
name = "tf_monitor_subnet"
156+
cidr_block = "10.0.1.0/24"
157+
}
158+
159+
resource "tencentcloud_monitor_tmp_instance" "example" {
160+
instance_name = "tf-tmp-instance-update"
161+
vpc_id = tencentcloud_vpc.vpc.id
162+
subnet_id = tencentcloud_subnet.subnet.id
163+
data_retention_time = 90
164+
zone = var.availability_zone
165+
tags = {
166+
"createdBy" = "terraformUpdate"
167+
}
112168
}
113169
`
114-
const testInstance_basic = testInstanceVar + `
115-
resource "tencentcloud_monitor_tmp_instance" "basic" {
116-
instance_name = "demo-test"
117-
vpc_id = var.vpc_id
118-
subnet_id = var.subnet_id
119-
data_retention_time = 30
120-
zone = var.default_az
121-
tags = {
122-
"createdBy" = "terraform"
123-
}
124-
}`
125-
126-
const testInstance_update = testInstanceVar + `
127-
resource "tencentcloud_monitor_tmp_instance" "update" {
128-
instance_name = "demo-test-update"
129-
vpc_id = var.vpc_id
130-
subnet_id = var.subnet_id
131-
data_retention_time = 30
132-
zone = var.default_az
133-
tags = {
134-
"createdBy" = "terraform"
135-
}
136-
}`

website/docs/r/monitor_tmp_instance.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ resource "tencentcloud_subnet" "subnet" {
3030
cidr_block = "10.0.1.0/24"
3131
}
3232
33-
resource "tencentcloud_monitor_tmp_instance" "foo" {
33+
resource "tencentcloud_monitor_tmp_instance" "example" {
3434
instance_name = "tf-tmp-instance"
3535
vpc_id = tencentcloud_vpc.vpc.id
3636
subnet_id = tencentcloud_subnet.subnet.id
@@ -68,6 +68,6 @@ In addition to all arguments above, the following attributes are exported:
6868

6969
monitor tmpInstance can be imported using the id, e.g.
7070
```
71-
$ terraform import tencentcloud_monitor_tmp_instance.tmpInstance tmpInstance_id
71+
$ terraform import tencentcloud_monitor_tmp_instance.example prom-1uvo0tjm
7272
```
7373

0 commit comments

Comments
 (0)