From 1f696887eb27f2eb9b747b238e4f402fac27d18c Mon Sep 17 00:00:00 2001 From: zhukun <2019229048@tju.edu.cn> Date: Mon, 20 Nov 2023 17:37:19 +0800 Subject: [PATCH] feat(apig_signature): import apig_signature resource, unit teset and docs --- docs/data-sources/lb_certificate.md | 46 ++++++ docs/data-sources/lb_listeners.md | 72 +++++++++ docs/resources/elb_logtank.md | 50 +++++++ ...urce_flexibleengine_lb_certificate_test.go | 104 +++++++++++++ ...source_flexibleengine_lb_listeners_test.go | 139 ++++++++++++++++++ ...ource_flexibleengine_lb_logtank_v3_test.go | 129 ++++++++++++++++ flexibleengine/provider.go | 16 +- 7 files changed, 549 insertions(+), 7 deletions(-) create mode 100644 docs/data-sources/lb_certificate.md create mode 100644 docs/data-sources/lb_listeners.md create mode 100644 docs/resources/elb_logtank.md create mode 100644 flexibleengine/acceptance/data_source_flexibleengine_lb_certificate_test.go create mode 100644 flexibleengine/acceptance/data_source_flexibleengine_lb_listeners_test.go create mode 100644 flexibleengine/acceptance/resource_flexibleengine_lb_logtank_v3_test.go diff --git a/docs/data-sources/lb_certificate.md b/docs/data-sources/lb_certificate.md new file mode 100644 index 00000000..0fd1ab16 --- /dev/null +++ b/docs/data-sources/lb_certificate.md @@ -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. diff --git a/docs/data-sources/lb_listeners.md b/docs/data-sources/lb_listeners.md new file mode 100644 index 00000000..fbdc48ab --- /dev/null +++ b/docs/data-sources/lb_listeners.md @@ -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 + +```hcl +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 [listeners](#listeners_listeners) structure is documented below. + + +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. + + +The `loadbalancers` block supports: + +* `id` - The ELB loadbalancer ID. diff --git a/docs/resources/elb_logtank.md b/docs/resources/elb_logtank.md new file mode 100644 index 00000000..f67f4d68 --- /dev/null +++ b/docs/resources/elb_logtank.md @@ -0,0 +1,50 @@ +--- +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. + +```bash +$ terraform import flexibleengine_elb_logtank.test +2f148a75-acd3-4ce7-8f63-d5c9fadab3a0 +``` diff --git a/flexibleengine/acceptance/data_source_flexibleengine_lb_certificate_test.go b/flexibleengine/acceptance/data_source_flexibleengine_lb_certificate_test.go new file mode 100644 index 00000000..8df150a8 --- /dev/null +++ b/flexibleengine/acceptance/data_source_flexibleengine_lb_certificate_test.go @@ -0,0 +1,104 @@ +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 = <