77 "testing"
88
99 "github.com/hashicorp/terraform-plugin-sdk/terraform"
10+ "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
1011
1112 "github.com/hashicorp/terraform-plugin-sdk/helper/resource"
1213)
@@ -23,8 +24,14 @@ func TestAccTencentCloudTcmClusterAttachment_basic(t *testing.T) {
2324 Config : testAccTcmClusterAttachment ,
2425 Check : resource .ComposeTestCheckFunc (
2526 testAccCheckClusterAttachmentExists ("tencentcloud_tcm_cluster_attachment.basic" ),
26- resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "mesh_id" , defaultMeshId ),
27+ // resource.TestCheckResourceAttrSet ("tencentcloud_tcm_cluster_attachment.basic", "mesh_id"),
2728 resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.#" , "1" ),
29+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.cluster_id" , defaultMeshClusterId ),
30+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.region" , "ap-guangzhou" ),
31+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.role" , "REMOTE" ),
32+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.vpc_id" , defaultMeshVpcId ),
33+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.subnet_id" , defaultMeshSubnetId ),
34+ resource .TestCheckResourceAttr ("tencentcloud_tcm_cluster_attachment.basic" , "cluster_list.0.type" , "EKS" ),
2835 ),
2936 },
3037 {
@@ -56,6 +63,11 @@ func testAccCheckClusterAttachmentDestroy(s *terraform.State) error {
5663
5764 mesh , err := service .DescribeTcmMesh (ctx , meshId )
5865 if err != nil {
66+ if sdkErr , ok := err .(* errors.TencentCloudSDKError ); ok {
67+ if sdkErr .Code == "ResourceNotFound" {
68+ return nil
69+ }
70+ }
5971 return err
6072 }
6173
@@ -118,9 +130,6 @@ const testAccTcmClusterAttachmentVar = `
118130variable "cluster_id" {
119131 default = "` + defaultMeshClusterId + `"
120132}
121- variable "mesh_id" {
122- default = "` + defaultMeshId + `"
123- }
124133variable "vpc_id" {
125134 default = "` + defaultMeshVpcId + `"
126135}
@@ -131,15 +140,48 @@ variable "subnet_id" {
131140
132141const testAccTcmClusterAttachment = testAccTcmClusterAttachmentVar + `
133142
143+ resource "tencentcloud_tcm_mesh" "basic" {
144+ display_name = "test_mesh"
145+ mesh_version = "1.12.5"
146+ type = "HOSTED"
147+ config {
148+ istio {
149+ outbound_traffic_policy = "ALLOW_ANY"
150+ disable_policy_checks = true
151+ enable_pilot_http = true
152+ disable_http_retry = true
153+ smart_dns {
154+ istio_meta_dns_capture = true
155+ istio_meta_dns_auto_allocate = true
156+ }
157+ }
158+ tracing {
159+ enable = true
160+ sampling = 1
161+ apm {
162+ enable = false
163+ }
164+ zipkin {
165+ address = "10.0.0.1:1000"
166+ }
167+ }
168+ }
169+ tag_list {
170+ key = "key"
171+ value = "value"
172+ passthrough = false
173+ }
174+ }
175+
134176resource "tencentcloud_tcm_cluster_attachment" "basic" {
135- mesh_id = var.mesh_id
177+ mesh_id = tencentcloud_tcm_mesh.basic.id
136178 cluster_list {
137179 cluster_id = var.cluster_id
138180 region = "ap-guangzhou"
139181 role = "REMOTE"
140182 vpc_id = var.vpc_id
141183 subnet_id = var.subnet_id
142- type = "TKE "
184+ type = "EKS "
143185 }
144186}
145187
0 commit comments