-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(elb): import elb 10sp2 resource, unit teset and docs (#1056)
- Loading branch information
1 parent
51799d6
commit 1cee08c
Showing
8 changed files
with
393 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
subcategory: "Elastic Load Balance (ELB)" | ||
--- | ||
|
||
# flexibleengine_lb_listeners_v2 | ||
|
||
Use this data source to query the list of ELB listeners. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "protocol" {} | ||
data "flexibleengine_lb_listeners_v2" "test" { | ||
protocol = var.protocol | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the data source. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `name` - (Optional, String) The listener name. | ||
|
||
* `protocol` - (Optional, String) The listener protocol. | ||
The valid values are **TCP**, **UDP**, **HTTP** and **TERMINATED_HTTPS**. | ||
|
||
* `protocol_port` - (Optional, String) The front-end listening port of the listener. | ||
The valid value is range from `1` to `65535`. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The resource ID. | ||
|
||
* `listeners` - Listener list. | ||
The [listeners](#listeners_listeners) structure is documented below. | ||
|
||
<a name="listeners_listeners"></a> | ||
The `listeners` block supports: | ||
|
||
* `id` - The ELB listener ID. | ||
|
||
* `name` - The listener name. | ||
|
||
* `protocol` - The listener protocol. | ||
|
||
* `protocol_port` - The front-end listening port of the listener. | ||
|
||
* `default_pool_id` - The ID of the default pool with which the ELB listener is associated. | ||
|
||
* `description` - The description of the ELB listener. | ||
|
||
* `connection_limit` - The maximum number of connections allowed for the listener. | ||
|
||
* `http2_enable` - Whether the ELB listener uses HTTP/2. | ||
|
||
* `default_tls_container_ref` - The ID of the server certificate used by the listener. | ||
|
||
* `sni_container_refs` - List of the SNI certificate (server certificates with a domain name) IDs used by the listener. | ||
|
||
* `loadbalancers` - Listener list. | ||
The [loadbalancers](#listeners_loadbalancers) structure is documented below. | ||
|
||
<a name="listeners_loadbalancers"></a> | ||
The `loadbalancers` block supports: | ||
|
||
* `id` - The ELB loadbalancer ID. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
subcategory: "Dedicated Load Balance (Dedicated ELB)" | ||
--- | ||
|
||
# flexibleengine_lb_logtank_v3 | ||
|
||
Manage an LB logtank resource within FlexibleEngine. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "loadbalancer_id" {} | ||
variable "group_id" {} | ||
variable "topic_id" {} | ||
resource "flexibleengine_lb_logtank_v3" "test" { | ||
loadbalancer_id = var.loadbalancer_id | ||
log_group_id = var.group_id | ||
log_topic_id = var.topic_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String, ForceNew) The region in which to create the logtank resource. | ||
If omitted, the provider-level region will be used. Changing this creates a new logtank. | ||
|
||
* `loadbalancer_id` - (Required, String, ForceNew) Specifies the ID of a loadbalancer. Changing this | ||
creates a new logtank. | ||
|
||
* `log_group_id` - (Required, String) Specifies the ID of a log group. It is provided by other service. | ||
|
||
* `log_topic_id` - (Required, String) Specifies the ID of the subscribe topic. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The logtank ID. | ||
|
||
## Import | ||
|
||
LB logtank can be imported using the logtank ID, e.g. | ||
|
||
```bash | ||
terraform import flexibleengine_lb_logtank_v3.test 2f148a75-acd3-4ce7-8f63-d5c9fadab3a0 | ||
``` |
139 changes: 139 additions & 0 deletions
139
flexibleengine/acceptance/data_source_flexibleengine_lb_listeners_v2_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDatasourceListeners_basic(t *testing.T) { | ||
var ( | ||
rName = acceptance.RandomAccResourceNameWithDash() | ||
dcByName = acceptance.InitDataSourceCheck("data.flexibleengine_lb_listeners_v2.by_name") | ||
dcByProtocol = acceptance.InitDataSourceCheck("data.flexibleengine_lb_listeners_v2.by_protocol") | ||
dcByProtocolPort = acceptance.InitDataSourceCheck("data.flexibleengine_lb_listeners_v2.by_protocol_port") | ||
) | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDatasourceListeners_basic(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
dcByName.CheckResourceExists(), | ||
resource.TestCheckOutput("name_query_result_validation", "true"), | ||
resource.TestCheckResourceAttrSet("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.name"), | ||
resource.TestCheckResourceAttrSet("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.protocol"), | ||
resource.TestCheckResourceAttrSet("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.protocol_port"), | ||
resource.TestCheckResourceAttrSet("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.connection_limit"), | ||
resource.TestCheckResourceAttrSet("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.http2_enable"), | ||
resource.TestCheckResourceAttr("data.flexibleengine_lb_listeners_v2.by_name", | ||
"listeners.0.loadbalancers.#", "1"), | ||
dcByProtocol.CheckResourceExists(), | ||
resource.TestCheckOutput("protocol_query_result_validation", "true"), | ||
dcByProtocolPort.CheckResourceExists(), | ||
resource.TestCheckOutput("protocol_port_query_result_validation", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDatasourceListeners_base(rName string) string { | ||
rCidr := acceptance.RandomCidr() | ||
return fmt.Sprintf(` | ||
variable "listener_configuration" { | ||
type = list(object({ | ||
protocol_port = number | ||
protocol = string | ||
})) | ||
default = [ | ||
{protocol_port = 306, protocol = "TCP"}, | ||
{protocol_port = 406, protocol = "UDP"}, | ||
{protocol_port = 506, protocol = "HTTP"}, | ||
] | ||
} | ||
resource "flexibleengine_vpc_v1" "test" { | ||
name = "%[1]s" | ||
cidr = "%[2]s" | ||
} | ||
resource "flexibleengine_vpc_subnet_v1" "test" { | ||
vpc_id = flexibleengine_vpc_v1.test.id | ||
name = "%[1]s" | ||
cidr = cidrsubnet(flexibleengine_vpc_v1.test.cidr, 4, 1) | ||
gateway_ip = cidrhost(cidrsubnet(flexibleengine_vpc_v1.test.cidr, 4, 1), 1) | ||
} | ||
resource "flexibleengine_lb_loadbalancer_v2" "test" { | ||
name = "%[1]s" | ||
vip_subnet_id = flexibleengine_vpc_subnet_v1.test.ipv4_subnet_id | ||
} | ||
resource "flexibleengine_lb_listener_v2" "test" { | ||
count = length(var.listener_configuration) | ||
loadbalancer_id = flexibleengine_lb_loadbalancer_v2.test.id | ||
name = "%[1]s-${count.index}" | ||
protocol = var.listener_configuration[count.index]["protocol"] | ||
protocol_port = var.listener_configuration[count.index]["protocol_port"] | ||
} | ||
`, rName, rCidr) | ||
} | ||
|
||
func testAccDatasourceListeners_basic(rName string) string { | ||
return fmt.Sprintf(` | ||
%s | ||
data "flexibleengine_lb_listeners_v2" "by_name" { | ||
depends_on = [flexibleengine_lb_listener_v2.test] | ||
name = flexibleengine_lb_listener_v2.test[0].name | ||
} | ||
data "flexibleengine_lb_listeners_v2" "by_protocol" { | ||
depends_on = [flexibleengine_lb_listener_v2.test] | ||
protocol = flexibleengine_lb_listener_v2.test[1].protocol | ||
} | ||
data "flexibleengine_lb_listeners_v2" "by_protocol_port" { | ||
depends_on = [flexibleengine_lb_listener_v2.test] | ||
protocol_port = flexibleengine_lb_listener_v2.test[2].protocol_port | ||
} | ||
output "name_query_result_validation" { | ||
value = contains(data.flexibleengine_lb_listeners_v2.by_name.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[0].id) && !contains(data.flexibleengine_lb_listeners_v2.by_name.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[1].id) && !contains(data.flexibleengine_lb_listeners_v2.by_name.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[2].id) | ||
} | ||
output "protocol_query_result_validation" { | ||
value = contains(data.flexibleengine_lb_listeners_v2.by_protocol.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[1].id) && !contains(data.flexibleengine_lb_listeners_v2.by_protocol.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[0].id) && !contains(data.flexibleengine_lb_listeners_v2.by_protocol.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[2].id) | ||
} | ||
output "protocol_port_query_result_validation" { | ||
value = contains(data.flexibleengine_lb_listeners_v2.by_protocol_port.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[2].id) && !contains(data.flexibleengine_lb_listeners_v2.by_protocol_port.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[0].id) && !contains(data.flexibleengine_lb_listeners_v2.by_protocol_port.listeners[*].id, | ||
flexibleengine_lb_listener_v2.test[1].id) | ||
} | ||
`, testAccDatasourceListeners_base(rName)) | ||
} |
Oops, something went wrong.