Up-to-date reference of API arguments for API Gateway VPC Channel service you can get at documentation portal
opentelekomcloud_apigw_vpc_channel_v2¶
Manages a channel resource within OpenTelekomCloud.
-> After creating a channel of type server, you can configure it for an API of an HTTP/HTTPS backend service.
Example Usage¶
Create a channel of type server and use the default group to manage servers¶
variable "gateway_id" {}
variable "channel_name" {}
variable "backend_servers" {
type = list(object({
group_name = string
id = string
weight = number
}))
}
resource "opentelekomcloud_apigw_vpc_channel_v2" "test" {
gateway_id = var.gateway_id
name = var.channel_name
port = 8080
dynamic "member" {
for_each = var.backend_servers
content {
id = member.value["id"]
weight = member.value["weight"]
}
}
}
Create a channel of type server and use the custom group to manage servers¶
variable "gateway_id" {}
variable "channel_name" {}
variable "backend_server_groups" {
type = list(object({
name = string
description = string
weight = number
}))
}
variable "backend_servers" {
type = list(object({
group_name = string
id = string
weight = number
}))
}
resource "opentelekomcloud_apigw_vpc_channel_v2" "test" {
gateway_id = var.gateway_id
name = var.channel_name
port = 8080
# The length of group list cannot be 0 if you want to use dynamic syntax
dynamic "member_group" {
for_each = var.backend_server_groups
content {
name = member.value["name"]
description = member.value["description"]
weight = member.value["weight"]
}
}
dynamic "member" {
for_each = var.backend_servers
content {
group_name = member.value["group_name"]
id = member.value["id"]
weight = member.value["weight"]
}
}
}
Create a channel of type microservice¶
variable "gateway_id" {}
variable "channel_name" {}
variable "cluster_id" {}
variable "stateless_workload_name" {}
variable "member_groups_config" {
type = list(object({
name = string
weight = number
microservice_port = number
microservice_tags = map(string)
}))
}
resource "opentelekomcloud_apigw_vpc_channel_v2" "test" {
gateway_id = var.gateway_id
name = var.channel_name
port = 80
lb_algorithm = 1
member_type = "ip"
type = 3
dynamic "member_group" {
for_each = var.member_groups_config
content {
name = member_group.value["name"]
weight = member_group.value["weight"]
microservice_port = member_group.value["microservice_port"]
microservice_tags = member_group.value["microservice_tags"]
}
}
health_check {
protocol = "TCP"
threshold_normal = 2
threshold_abnormal = 2
interval = 5
timeout = 2
port = 65530
path = "/"
method = "GET"
http_codes = "200,201,208-209"
enable_client_ssl = false
status = 1
}
microservice {
cce_config {
cluster_id = var.cluster_id
namespace = "default"
workload_type = "deployment"
label_key = "app"
label_value = var.stateless_workload_name
}
}
}
Argument Reference¶
The following arguments are supported:
gateway_id
- (Required, String, ForceNew) Specifies the ID of the dedicated API gateway to which the channel belongs. Changing this will create a new resource.name
- (Required, String) Specifies the channel name. The valid length is limited from3
to64
, only chinese and english letters, digits, hyphens-
, underscores_
and dots (.) are allowed. The name must start with a Chinese or English letter.port
- (Required, Int) Specifies the default port for health check in channel. The valid value ranges from1
to65,535
.lb_algorithm
- (Required, Int) Specifies the distribution algorithm. The valid values are as follows:1
: Weighted round robin (WRR).2
: Weighted least connections (WLC).3
: Source hashing.4
: URI hashing.
member_type
- (Optional, String) Specifies the member type of the channel. The valid values are as follows:ip
.ecs
.
type
- (Optional, Int) Specifies the type of the channel. The valid values are as follows:2
: Server type.3
: Microservice type.
Defaults to
2
(server type).member_group
- (Optional, List) Specifies the backend (server) groups of the channel. The object structure is documented below.member
- (Optional, List) Specifies the backend servers of the channel. This parameter is required and only available if thetype
is2
. The object structure is documented below.health_check
- (Optional, List) Specifies the health configuration of cloud servers associated with the load balance channel for APIG regularly check. The object structure is documented below.microservice
- (Optional, List) Specifies the configuration of the microservice. The object structure is documented below.
The member_group
block supports:
name
- (Required, String) Specifies the name of the member group. The valid length is limited from3
to64
, only chinese and english letters, digits, hyphens (-), underscores (_) and dots (.) are allowed. The name must start with a Chinese or English letter.description
- (Optional, String) Specifies the description of the member group.weight
- (Optional, String) Specifies the weight of the current member group.microservice_version
- (Optional, String) Specifies the microservice version of the backend server group.microservice_port
- (Optional, Int) Specifies the microservice port of the backend server group. The valid value ranges from0
to65,535
.microservice_tags
- (Optional, Map) Specifies the microservice tags of the backend server group.
host
- (Optional, String) Specifies the IP address each backend servers.id
- (Optional, String) Specifies the ECS ID for each backend servers.-> One of the parameter
member.host
andmember.id
must be set ifmember_type
is ecs. The parametermember.host
andmember.id
are alternative.name
- (Optional, String) Specifies the name of the backend server. Required if the parametermember.id
is set.weight
- (Optional, Int) Specifies the weight of current backend server. The valid value ranges from0
to10,000
, defaults to0
.is_backup
- (Optional, Bool) Specifies whether this member is the backup member. Defaults tofalse
.group_name
- (Optional, String) Specifies the IP address each backend servers. If omitted, means that all backend servers are both in one group.status
- (Optional, Int) Specifies the status of the backend server. The valid values are as follows:1
: Normal.2
: Abnormal.
Defaults to
1
(normal).port
- (Optional, Int) Specifies the port of the backend server. The valid value ranges from0
to65,535
. If omitted, the default port of channel will be used.
The health_check
block supports:
protocol
- (Required, String) Specifies the microservice for performing health check on backend servers. The valid values areTCP
,HTTP
andHTTPS
, defaults toTCP
.threshold_normal
- (Required, Int) Specifies the healthy threshold, which refers to the number of consecutive successful checks required for a backend server to be considered healthy. The valid value ranges from1
to10
.threshold_abnormal
- (Required, Int) Specifies the unhealthy threshold, which refers to the number of consecutive failed checks required for a backend server to be considered unhealthy. The valid value ranges from1
to10
.interval
- (Required, Int) Specifies the interval between consecutive checks, in second. The valid value ranges from1
to300
.timeout
- (Required, Int) Specifies the timeout for determining whether a health check fails, in second. The value must be less than the value of the timeinterval
. The valid value ranges from1
to30
.path
- (Optional, String) Specifies the destination path for health checks. Required if theprotocol
isHTTP
orHTTPS
.method
- (Optional, String) Specifies the request method for health check. The valid values areGET
andHEAD
.port
- (Optional, Int) Specifies the destination host port for health check. The valid value ranges from0
to65,535
.http_codes
- (Optional, String) Specifies the response codes for determining a successful HTTP response. The valid value ranges from100
to599
and the valid formats are as follows:The multiple values, for example,
200,201,202
.The range, for example,
200-299
.Both multiple values and ranges, for example,
201,202,210-299
.
enable_client_ssl
- (Optional, Bool) Specifies whether to enable two-way authentication. Defaults tofalse
.status
- (Optional, Int) Specifies the status of health check. The valid values are as follows:1
: Normal.2
: Abnormal.
Defaults to
1
(normal).
The microservice
block supports:
cce_config
- (Optional, List) Specifies the CCE microservice details. The object structure is documented below.
The cce_config
block supports:
cluster_id
- (Required, String) Specifies the CCE cluster ID.namespace
- (Required, String) Specifies the namespace, such as the default namespace for CCE cluster:default
.workload_type
- (Required, String) Specifies the workload type.deployment
: Stateless load.statefulset
: Stateful load.daemonset
: Daemons set.
label_key
- (Required, String) Specifies the service label key.label_value
- (Required, String) Specifies the service label value.
Attribute Reference¶
In addition to all arguments above, the following attributes are exported:
id
- The ID of the channel.created_at
- The time when the channel was created.region
- The region where the channel is located.status
- The current status of the channel.1
: Normal.2
: Abnormal.
Import¶
Channels can be imported using their id
and the ID of the related API gateway instance, separated by a slash, e.g.
$ terraform import opentelekomcloud_apigw_vpc_channel_v2.test <gateway_id>/<id>