Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tencentcloud/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,6 @@ const (

const (
defaultMeshClusterId = "cls-9ae9qo9k"
defaultMeshId = "mesh-rofjmux7"
defaultMeshVpcId = "vpc-pyyv5k3v"
defaultMeshSubnetId = "subnet-06i8auk6"
)
Expand Down
2 changes: 2 additions & 0 deletions tencentcloud/resource_tc_ci_bucket_pic_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"fmt"
"log"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
Expand Down Expand Up @@ -99,6 +100,7 @@ func resourceTencentCloudCiBucketPicStyleCreate(d *schema.ResourceData, meta int
StyleBody: styleBody,
})
if e != nil {
time.Sleep(5 * time.Second)
return retryError(e)
} else {
log.Printf("[DEBUG]%s api[%s] success, response status [%s]\n", logId, "AddStyle", result.Status)
Expand Down
50 changes: 42 additions & 8 deletions tencentcloud/resource_tc_tcm_access_log_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAccTencentCloudTcmAccessLogConfigResource_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccCheckTcmAccessLogConfigExists("tencentcloud_tcm_access_log_config.access_log_config"),
resource.TestCheckResourceAttrSet("tencentcloud_tcm_access_log_config.access_log_config", "id"),
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "mesh_name", defaultMeshId),
resource.TestCheckResourceAttrSet("tencentcloud_tcm_access_log_config.access_log_config", "mesh_name"),
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "address", "10.0.0.1"),
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "enable", "true"),
resource.TestCheckResourceAttr("tencentcloud_tcm_access_log_config.access_log_config", "enable_server", "true"),
Expand Down Expand Up @@ -68,13 +68,47 @@ func testAccCheckTcmAccessLogConfigExists(r string) resource.TestCheckFunc {
}
}

const testAccTcmAccessLogConfigVar = `
variable "mesh_id" {
default = "` + defaultMeshId + `"
}
`
const testAccTcmAccessLogConfig = `

const testAccTcmAccessLogConfig = testAccTcmAccessLogConfigVar + `
resource "tencentcloud_tcm_mesh" "basic" {
display_name = "test_mesh"
mesh_version = "1.12.5"
type = "HOSTED"
config {
istio {
outbound_traffic_policy = "ALLOW_ANY"
disable_policy_checks = true
enable_pilot_http = true
disable_http_retry = true
smart_dns {
istio_meta_dns_capture = true
istio_meta_dns_auto_allocate = true
}
}
tracing {
enable = true
sampling = 1
apm {
enable = false
}
zipkin {
address = "10.0.0.1:1000"
}
}
prometheus {
custom_prom {
url = "https://10.0.0.1:1000"
auth_type = "none"
vpc_id = "vpc-j9yhbzpn"
}
}
}
tag_list {
key = "key"
value = "value"
passthrough = false
}
}

resource "tencentcloud_tcm_access_log_config" "access_log_config" {
address = "10.0.0.1"
Expand All @@ -83,7 +117,7 @@ resource "tencentcloud_tcm_access_log_config" "access_log_config" {
enable_stdout = true
encoding = "JSON"
format = "{\n\t\"authority\": \"%REQ(:AUTHORITY)%\",\n\t\"bytes_received\": \"%BYTES_RECEIVED%\",\n\t\"bytes_sent\": \"%BYTES_SENT%\",\n\t\"downstream_local_address\": \"%DOWNSTREAM_LOCAL_ADDRESS%\",\n\t\"downstream_remote_address\": \"%DOWNSTREAM_REMOTE_ADDRESS%\",\n\t\"duration\": \"%DURATION%\",\n\t\"istio_policy_status\": \"%DYNAMIC_METADATA(istio.mixer:status)%\",\n\t\"method\": \"%REQ(:METHOD)%\",\n\t\"path\": \"%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%\",\n\t\"protocol\": \"%PROTOCOL%\",\n\t\"request_id\": \"%REQ(X-REQUEST-ID)%\",\n\t\"requested_server_name\": \"%REQUESTED_SERVER_NAME%\",\n\t\"response_code\": \"%RESPONSE_CODE%\",\n\t\"response_flags\": \"%RESPONSE_FLAGS%\",\n\t\"route_name\": \"%ROUTE_NAME%\",\n\t\"start_time\": \"%START_TIME%\",\n\t\"upstream_cluster\": \"%UPSTREAM_CLUSTER%\",\n\t\"upstream_host\": \"%UPSTREAM_HOST%\",\n\t\"upstream_local_address\": \"%UPSTREAM_LOCAL_ADDRESS%\",\n\t\"upstream_service_time\": \"%RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)%\",\n\t\"upstream_transport_failure_reason\": \"%UPSTREAM_TRANSPORT_FAILURE_REASON%\",\n\t\"user_agent\": \"%REQ(USER-AGENT)%\",\n\t\"x_forwarded_for\": \"%REQ(X-FORWARDED-FOR)%\"\n}\n"
mesh_name = var.mesh_id
mesh_name = tencentcloud_tcm_mesh.basic.id
template = "istio"

cls {
Expand Down
2 changes: 2 additions & 0 deletions tencentcloud/resource_tc_tcm_cluster_attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func resourceTencentCloudTcmClusterAttachment() *schema.Resource {
"cluster_list": {
Type: schema.TypeList,
Optional: true,
Computed: true,
ForceNew: true,
Description: "Cluster list.",
Elem: &schema.Resource{
Expand Down Expand Up @@ -84,6 +85,7 @@ func resourceTencentCloudTcmClusterAttachment() *schema.Resource {
"subnet_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为什么会加上computed属性?自动化测试跑出了问题?

Description: "Subnet id, only needed if it's standalone mesh.",
},
"type": {
Expand Down
54 changes: 48 additions & 6 deletions tencentcloud/resource_tc_tcm_cluster_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/terraform"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)
Expand All @@ -23,8 +24,14 @@ func TestAccTencentCloudTcmClusterAttachment_basic(t *testing.T) {
Config: testAccTcmClusterAttachment,
Check: resource.ComposeTestCheckFunc(
testAccCheckClusterAttachmentExists("tencentcloud_tcm_cluster_attachment.basic"),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "mesh_id", defaultMeshId),
// resource.TestCheckResourceAttrSet("tencentcloud_tcm_cluster_attachment.basic", "mesh_id"),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.#", "1"),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.cluster_id", defaultMeshClusterId),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.region", "ap-guangzhou"),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.role", "REMOTE"),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.vpc_id", defaultMeshVpcId),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.subnet_id", defaultMeshSubnetId),
resource.TestCheckResourceAttr("tencentcloud_tcm_cluster_attachment.basic", "cluster_list.0.type", "EKS"),
),
},
{
Expand Down Expand Up @@ -56,6 +63,11 @@ func testAccCheckClusterAttachmentDestroy(s *terraform.State) error {

mesh, err := service.DescribeTcmMesh(ctx, meshId)
if err != nil {
if sdkErr, ok := err.(*errors.TencentCloudSDKError); ok {
if sdkErr.Code == "ResourceNotFound" {
return nil
}
}
return err
}

Expand Down Expand Up @@ -118,9 +130,6 @@ const testAccTcmClusterAttachmentVar = `
variable "cluster_id" {
default = "` + defaultMeshClusterId + `"
}
variable "mesh_id" {
default = "` + defaultMeshId + `"
}
variable "vpc_id" {
default = "` + defaultMeshVpcId + `"
}
Expand All @@ -131,15 +140,48 @@ variable "subnet_id" {

const testAccTcmClusterAttachment = testAccTcmClusterAttachmentVar + `

resource "tencentcloud_tcm_mesh" "basic" {
display_name = "test_mesh"
mesh_version = "1.12.5"
type = "HOSTED"
config {
istio {
outbound_traffic_policy = "ALLOW_ANY"
disable_policy_checks = true
enable_pilot_http = true
disable_http_retry = true
smart_dns {
istio_meta_dns_capture = true
istio_meta_dns_auto_allocate = true
}
}
tracing {
enable = true
sampling = 1
apm {
enable = false
}
zipkin {
address = "10.0.0.1:1000"
}
}
}
tag_list {
key = "key"
value = "value"
passthrough = false
}
}

resource "tencentcloud_tcm_cluster_attachment" "basic" {
mesh_id = var.mesh_id
mesh_id = tencentcloud_tcm_mesh.basic.id
cluster_list {
cluster_id = var.cluster_id
region = "ap-guangzhou"
role = "REMOTE"
vpc_id = var.vpc_id
subnet_id = var.subnet_id
type = "TKE"
type = "EKS"
}
}

Expand Down
20 changes: 19 additions & 1 deletion tencentcloud/resource_tc_tcm_mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,34 +94,40 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Description: "Tracing config.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enable": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Whether enable tracing.",
},
"apm": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Description: "APM config.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enable": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Whether enable APM.",
},
"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Region.",
},
"instance_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Instance id of the APM.",
},
},
Expand All @@ -130,12 +136,14 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
"sampling": {
Type: schema.TypeFloat,
Optional: true,
Computed: true,
Description: "Tracing sampling, 0.0-1.0.",
},
"zipkin": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Description: "Third party zipkin config.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand All @@ -154,44 +162,52 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Description: "Prometheus configuration.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"vpc_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Vpc id.",
},
"subnet_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Subnet id.",
},
"region": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Region.",
},
"instance_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Instance id.",
},
"custom_prom": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Computed: true,
Description: "Custom prometheus.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"is_public_addr": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Whether it is public address, default false.",
},
"vpc_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Vpc id.",
},
"url": {
Expand All @@ -207,11 +223,13 @@ func resourceTencentCloudTcmMesh() *schema.Resource {
"username": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Username of the prometheus, used in basic authentication type.",
},
"password": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "Password of the prometheus, used in basic authentication type.",
},
},
Expand Down Expand Up @@ -470,7 +488,7 @@ func resourceTencentCloudTcmMeshCreate(d *schema.ResourceData, meta interface{})
if errRet != nil {
return retryError(errRet, InternalError)
}
if *mesh.Mesh.State == "PENDING" || *mesh.Mesh.State == "CREATING" {
if *mesh.Mesh.State == "PENDING" || *mesh.Mesh.State == "CREATING" || *mesh.Mesh.State != "RUNNING" {
return resource.RetryableError(fmt.Errorf("mesh status is %v, retry...", *mesh.Mesh.State))
}
return nil
Expand Down
Loading