Skip to content

Commit cdc2ba2

Browse files
authored
add (#3202)
1 parent 1811fd6 commit cdc2ba2

File tree

3 files changed

+140
-0
lines changed

3 files changed

+140
-0
lines changed

tencentcloud/provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ tencentcloud_as_limits
173173
tencentcloud_as_last_activity
174174

175175
Resource
176+
tencentcloud_as_load_balancer
176177
tencentcloud_as_scaling_config
177178
tencentcloud_as_scaling_group
178179
tencentcloud_as_scaling_group_status
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
subcategory: "Auto Scaling(AS)"
3+
layout: "tencentcloud"
4+
page_title: "TencentCloud: tencentcloud_as_load_balancer"
5+
sidebar_current: "docs-tencentcloud-resource-as_load_balancer"
6+
description: |-
7+
Provides a resource to create a as load balancer
8+
---
9+
10+
# tencentcloud_as_load_balancer
11+
12+
Provides a resource to create a as load balancer
13+
14+
~> **NOTE:** This resource must exclusive in one auto scaling group, do not declare additional rule resources of this auto scaling group elsewhere.
15+
16+
~> **NOTE:** If the `auto_scaling_group_id` field of this resource comes from the `tencentcloud_as_scaling_group` resource, then the `forward_balancer_ids` field of the `tencentcloud_as_scaling_group` resource cannot be set simultaneously with this resource, which may result in conflicts
17+
18+
~> **NOTE:** `forward_load_balancers` List of application type load balancers, with a maximum of 100 bound application type load balancers for each scaling group.
19+
20+
## Example Usage
21+
22+
```hcl
23+
variable "availability_zone" {
24+
default = "ap-guangzhou-6"
25+
}
26+
27+
// create vpc
28+
resource "tencentcloud_vpc" "vpc" {
29+
cidr_block = "10.0.0.0/16"
30+
name = "vpc"
31+
}
32+
33+
// create subnet
34+
resource "tencentcloud_subnet" "subnet" {
35+
vpc_id = tencentcloud_vpc.vpc.id
36+
availability_zone = var.availability_zone
37+
name = "subnet"
38+
cidr_block = "10.0.1.0/24"
39+
is_multicast = false
40+
}
41+
42+
43+
resource "tencentcloud_as_scaling_config" "example" {
44+
configuration_name = "tf-example"
45+
image_id = "img-eb30mz89"
46+
instance_types = ["S6.MEDIUM4"]
47+
instance_name_settings {
48+
instance_name = "demo-ins-name"
49+
}
50+
}
51+
52+
resource "tencentcloud_as_scaling_group" "example" {
53+
scaling_group_name = "tf-example"
54+
configuration_id = tencentcloud_as_scaling_config.example.id
55+
max_size = 1
56+
min_size = 0
57+
vpc_id = tencentcloud_vpc.vpc.id
58+
subnet_ids = [tencentcloud_subnet.subnet.id]
59+
}
60+
61+
resource "tencentcloud_clb_instance" "example" {
62+
network_type = "INTERNAL"
63+
clb_name = "tf-example"
64+
vpc_id = tencentcloud_vpc.vpc.id
65+
subnet_id = tencentcloud_subnet.subnet.id
66+
tags = {
67+
createBy = "Terraform"
68+
}
69+
}
70+
71+
resource "tencentcloud_clb_listener" "example" {
72+
clb_id = tencentcloud_clb_instance.example.id
73+
listener_name = "tf-example"
74+
port = 80
75+
protocol = "HTTP"
76+
}
77+
78+
resource "tencentcloud_clb_listener_rule" "example" {
79+
listener_id = tencentcloud_clb_listener.example.listener_id
80+
clb_id = tencentcloud_clb_instance.example.id
81+
domain = "foo.net"
82+
url = "/bar"
83+
}
84+
85+
resource "tencentcloud_as_load_balancer" "example" {
86+
auto_scaling_group_id = tencentcloud_as_scaling_group.example.id
87+
88+
forward_load_balancers {
89+
load_balancer_id = tencentcloud_clb_instance.example.id
90+
listener_id = tencentcloud_clb_listener.example.listener_id
91+
location_id = tencentcloud_clb_listener_rule.example.rule_id
92+
93+
target_attributes {
94+
port = 8080
95+
weight = 20
96+
}
97+
}
98+
}
99+
```
100+
101+
## Argument Reference
102+
103+
The following arguments are supported:
104+
105+
* `auto_scaling_group_id` - (Required, String) ID of a scaling group.
106+
* `forward_load_balancers` - (Optional, List) List of application load balancers. The maximum number of application-type load balancers bound to each scaling group is 100.
107+
108+
The `forward_load_balancers` object supports the following:
109+
110+
* `listener_id` - (Required, String) Application load balancer listener ID.
111+
* `load_balancer_id` - (Required, String) Application load balancer instance ID.
112+
* `target_attributes` - (Required, List) List of TargetAttribute.
113+
* `location_id` - (Optional, String) Application load balancer location ID.
114+
* `region` - (Optional, String) Load balancer instance region. Default value is the region of current auto scaling group. The format is the same as the public parameter Region, for example: ap-guangzhou.
115+
116+
The `target_attributes` object of `forward_load_balancers` supports the following:
117+
118+
* `port` - (Required, Int) Target port.
119+
* `weight` - (Required, Int) Target weight.
120+
121+
## Attributes Reference
122+
123+
In addition to all arguments above, the following attributes are exported:
124+
125+
* `id` - ID of the resource.
126+
127+
128+
129+
## Import
130+
131+
as load balancer can be imported using the id, e.g.
132+
133+
```
134+
terraform import tencentcloud_as_load_balancer.example asg-bpp4uol2
135+
```
136+

website/tencentcloud.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@
385385
<li>
386386
<a href="/docs/providers/tencentcloud/r/as_lifecycle_hook.html">tencentcloud_as_lifecycle_hook</a>
387387
</li>
388+
<li>
389+
<a href="/docs/providers/tencentcloud/r/as_load_balancer.html">tencentcloud_as_load_balancer</a>
390+
</li>
388391
<li>
389392
<a href="/docs/providers/tencentcloud/r/as_notification.html">tencentcloud_as_notification</a>
390393
</li>

0 commit comments

Comments
 (0)