-
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 resource and add unit test and docs
- Loading branch information
1 parent
02543dd
commit 0566a1e
Showing
7 changed files
with
546 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
subcategory: "Elastic Load Balance (ELB)" | ||
--- | ||
|
||
# flexibleengine_lb_certificate | ||
|
||
Use this data source to get the certificates in FlexibleEngine Elastic Load Balance (ELB). | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "certificate_name" {} | ||
data "flexibleengine_lb_certificate" "test" { | ||
name = var.certificate_name | ||
type = "server" | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) The region in which to obtain the ELB certificate. If omitted, the provider-level region | ||
will be used. | ||
|
||
* `type` - (Optional, String) Specifies the certificate type. The default value is `server`. The value can be one of the | ||
following: | ||
+ `server`: indicates the server certificate. | ||
+ `client`: indicates the CA certificate. | ||
|
||
* `name` - (Required, String) The name of certificate. The value is case sensitive and does not supports fuzzy matching. | ||
|
||
-> **NOTE:** The certificate name is not unique. Only returns the last created one when matched multiple certificates. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The certificate ID in UUID format. | ||
|
||
* `domain` - The domain of the Certificate. This parameter is valid only when `type` is "server". | ||
|
||
* `description` - Human-readable description for the Certificate. | ||
|
||
* `expiration` - Indicates the time when the certificate expires. |
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 | ||
|
||
Use this data source to query the list of ELB listeners. | ||
|
||
## Example Usage | ||
|
||
``` | ||
variable "protocol" {} | ||
data "flexibleengine_lb_listeners" "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 [object](#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 [object](#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_elb_logtank | ||
|
||
Manage an ELB logtank resource within FlexibleEngine. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "loadbalancer_id" {} | ||
variable "group_id" {} | ||
variable "topic_id" {} | ||
resource "flexibleengine_elb_logtank" "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 | ||
|
||
ELB logtank can be imported using the logtank ID, e.g. | ||
|
||
``` | ||
$ terraform import flexibleengine_elb_logtank.test 2f148a75-acd3-4ce7-8f63-d5c9fadab3a0 | ||
``` |
108 changes: 108 additions & 0 deletions
108
flexibleengine/acceptance/data_source_flexibleengine_lb_certificate_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,108 @@ | ||
/* | ||
Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. | ||
*/ | ||
|
||
package acceptance | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
func TestAccDataSourceLBCertificateV2_basic(t *testing.T) { | ||
name := fmt.Sprintf("cert-%s", acctest.RandString(6)) | ||
dataSourceName := "data.flexibleengine_lb_certificate_v2.cert_1" | ||
dc := acceptance.InitDataSourceCheck(dataSourceName) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
ProviderFactories: TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccLBCertificateSourceV2_conf(name), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestCheckResourceAttr(dataSourceName, "name", name), | ||
resource.TestCheckResourceAttr(dataSourceName, "type", "server"), | ||
resource.TestCheckResourceAttrSet(dataSourceName, "domain"), | ||
resource.TestCheckResourceAttrSet(dataSourceName, "description"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccLBCertificateSourceV2_conf(name string) string { | ||
return fmt.Sprintf(` | ||
data "flexibleengine_lb_certificate_v2" "cert_1" { | ||
name = flexibleengine_elb_certificate.certificate_1.name | ||
depends_on = [flexibleengine_elb_certificate.certificate_1] | ||
} | ||
resource "flexibleengine_elb_certificate" "certificate_1" { | ||
name = "%s" | ||
description = "terraform test certificate" | ||
domain = "www.elb.com" | ||
type = "server" | ||
private_key = <<EOT | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEowIBAAKCAQEAwZ5UJULAjWr7p6FVwGRQRjFN2s8tZ/6LC3X82fajpVsYqF1x | ||
qEuUDndDXVD09E4u83MS6HO6a3bIVQDp6/klnYldiE6Vp8HH5BSKaCWKVg8lGWg1 | ||
UM9wZFnlryi14KgmpIFmcu9nA8yV/6MZAe6RSDmb3iyNBmiZ8aZhGw2pI1YwR+15 | ||
MV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g8lGWg1UM9wZFnlryi14KgmpIFmcu9nA8yV/6MZAe6RSDmb | ||
3iyNBmiZ8aZhGw2pI1YwR+15MVqFFGB+7ExkziROi7L8CFCyCezK2/oOOvQsH1dz | ||
Q8z1JXWdg8/9Zx7Ktvgwu5PQM3cJtSHX6iBPOkMU8Z8TugLlTqQXKZOEgwajwvQ5 | ||
mf2DPkVgM08XAgaLJcLigwD513koAdtJd5v+9irw+5LAuO3JclqwTvwy7u/YwwID | ||
AQABo1AwTjAdBgNVHQ4EFgQUo5A2tIu+bcUfvGTD7wmEkhXKFjcwHwYDVR0jBBgw | ||
FoAUo5A2tIu+bcUfvGTD7wmEkhXKFjcwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B | ||
AQsFAAOCAQEAWJ2rS6Mvlqk3GfEpboezx2J3X7l1z8Sxoqg6ntwB+rezvK3mc9H0 | ||
83qcVeUcoH+0A0lSHyFN4FvRQL6X1hEheHarYwJK4agb231vb5erasuGO463eYEG | ||
r4SfTuOm7SyiV2xxbaBKrXJtpBp4WLL/s+LF+nklKjaOxkmxUX0sM4CTA7uFJypY | ||
c8Tdr8lDDNqoUtMD8BrUCJi+7lmMXRcC3Qi3oZJW76ja+kZA5mKVFPd1ATih8TbA | ||
i34R7EQDtFeiSvBdeKRsPp8c0KT8H1B4lXNkkCQs2WX5p4lm99+ZtLD4glw8x6Ic | ||
i1YhgnQbn5E0hz55OLu5jvOkKQjPCW+8Kg== | ||
-----END CERTIFICATE----- | ||
EOT | ||
} | ||
`, name) | ||
} |
Oops, something went wrong.