|
| 1 | +provider "tencentcloud" { |
| 2 | + region = "ap-guangzhou" |
| 3 | +} |
| 4 | + |
1 | 5 | resource "tencentcloud_security_group" "foo" { |
2 | 6 | name = "example" |
3 | 7 | } |
4 | 8 |
|
5 | 9 | resource "tencentcloud_vpc" "foo" { |
6 | | - name = "example" |
| 10 | + name = "ci-test-eni-vpc" |
7 | 11 | cidr_block = "10.0.0.0/16" |
8 | 12 | } |
9 | 13 |
|
10 | 14 | resource "tencentcloud_subnet" "foo" { |
11 | | - name = "example" |
12 | 15 | availability_zone = var.availability_zone |
| 16 | + name = "ci-test-eni-subnet" |
13 | 17 | vpc_id = tencentcloud_vpc.foo.id |
14 | | - cidr_block = "10.0.0.0/24" |
| 18 | + cidr_block = "10.0.0.0/16" |
15 | 19 | is_multicast = false |
16 | 20 | } |
17 | 21 |
|
@@ -72,7 +76,7 @@ resource "tencentcloud_clb_listener" "listener_https" { |
72 | 76 | port = 443 |
73 | 77 | protocol = "HTTPS" |
74 | 78 | certificate_ssl_mode = "UNIDIRECTIONAL" |
75 | | - certificate_id = "VfqO4zkB" |
| 79 | + certificate_id = "f8k7ke6a" |
76 | 80 | } |
77 | 81 |
|
78 | 82 | resource "tencentcloud_clb_listener_rule" "rule_https" { |
@@ -132,8 +136,8 @@ resource "tencentcloud_clb_redirection" "redirection_http" { |
132 | 136 | clb_id = tencentcloud_clb_instance.example.id |
133 | 137 | source_listener_id = tencentcloud_clb_listener.listener_http_src.listener_id |
134 | 138 | target_listener_id = tencentcloud_clb_listener.listener_http_dst.listener_id |
135 | | - source_rule_id = tencentcloud_clb_listener_rule.rule_http_src.listener_id |
136 | | - target_rule_id = tencentcloud_clb_listener_rule.rule_http_dst.listener_id |
| 139 | + source_rule_id = tencentcloud_clb_listener_rule.rule_http_src.rule_id |
| 140 | + target_rule_id = tencentcloud_clb_listener_rule.rule_http_dst.rule_id |
137 | 141 | } |
138 | 142 |
|
139 | 143 | resource "tencentcloud_clb_instance" "clb_basic" { |
@@ -162,18 +166,74 @@ resource "tencentcloud_clb_target_group" "test"{ |
162 | 166 | target_group_name = "test-target-keep-1" |
163 | 167 | } |
164 | 168 |
|
165 | | -resource "tencentcloud_clb_target_group_instance_attachment" "test"{ |
166 | | - target_group_id = tencentcloud_clb_target_group.test.id |
167 | | - bind_ip = "172.16.48.18" |
168 | | - port = 222 |
169 | | - weight = 3 |
| 169 | +data "tencentcloud_images" "my_favorite_image" { |
| 170 | + image_type = ["PUBLIC_IMAGE"] |
| 171 | + os_name = "centos" |
170 | 172 | } |
171 | 173 |
|
172 | | -resource "tencentcloud_clb_target_group_attachment" "group" { |
173 | | - clb_id = tencentcloud_clb_instance.clb_basic.id |
174 | | - listener_id = tencentcloud_clb_listener.listener_basic.listener_id |
175 | | - rule_id = tencentcloud_clb_listener_rule.rule_basic.rule_id |
176 | | - targrt_group_id = tencentcloud_clb_target_group.test.id |
| 174 | +data "tencentcloud_instance_types" "my_favorite_instance_types" { |
| 175 | + filter { |
| 176 | + name = "instance-family" |
| 177 | + values = ["S3"] |
| 178 | + } |
| 179 | + |
| 180 | + cpu_core_count = 1 |
| 181 | + memory_size = 1 |
| 182 | +} |
| 183 | + |
| 184 | +data "tencentcloud_availability_zones" "default" { |
| 185 | +} |
| 186 | + |
| 187 | +resource "tencentcloud_vpc" "app" { |
| 188 | + cidr_block = "10.0.0.0/16" |
| 189 | + name = "awesome_app_vpc" |
| 190 | +} |
| 191 | + |
| 192 | +resource "tencentcloud_subnet" "app" { |
| 193 | + vpc_id = tencentcloud_vpc.app.id |
| 194 | + availability_zone = data.tencentcloud_availability_zones.default.zones.0.name |
| 195 | + name = "awesome_app_subnet" |
| 196 | + cidr_block = "10.0.1.0/24" |
| 197 | +} |
| 198 | + |
| 199 | +resource "tencentcloud_instance" "my_awesome_app" { |
| 200 | + instance_name = "awesome_app" |
| 201 | + availability_zone = data.tencentcloud_availability_zones.default.zones.0.name |
| 202 | + image_id = data.tencentcloud_images.my_favorite_image.images.0.image_id |
| 203 | + instance_type = data.tencentcloud_instance_types.my_favorite_instance_types.instance_types.0.instance_type |
| 204 | + system_disk_type = "CLOUD_PREMIUM" |
| 205 | + system_disk_size = 50 |
| 206 | + hostname = "user" |
| 207 | + project_id = 0 |
| 208 | + vpc_id = tencentcloud_vpc.app.id |
| 209 | + subnet_id = tencentcloud_subnet.app.id |
| 210 | + internet_max_bandwidth_out = 20 |
| 211 | + |
| 212 | + data_disks { |
| 213 | + data_disk_type = "CLOUD_PREMIUM" |
| 214 | + data_disk_size = 50 |
| 215 | + encrypt = false |
| 216 | + } |
| 217 | + |
| 218 | + tags = { |
| 219 | + tagKey = "tagValue" |
| 220 | + } |
| 221 | +} |
| 222 | + |
| 223 | +data "tencentcloud_instances" "foo" { |
| 224 | + instance_id = tencentcloud_instance.my_awesome_app.id |
| 225 | +} |
| 226 | + |
| 227 | +resource "tencentcloud_clb_target_group" "test_instance_attachment"{ |
| 228 | + target_group_name = "test" |
| 229 | + vpc_id = tencentcloud_vpc.app.id |
| 230 | +} |
| 231 | + |
| 232 | +resource "tencentcloud_clb_target_group_instance_attachment" "test"{ |
| 233 | + target_group_id = tencentcloud_clb_target_group.test_instance_attachment.id |
| 234 | + bind_ip = data.tencentcloud_instances.foo.instance_list[0].private_ip |
| 235 | + port = 88 |
| 236 | + weight = 3 |
177 | 237 | } |
178 | 238 |
|
179 | 239 | data "tencentcloud_clb_target_groups" "target_group_info_id" { |
|
0 commit comments