From a9513eb08bd0c7102692a5dcc7dac859a79f4058 Mon Sep 17 00:00:00 2001
From: HORIUCHI Akihiko <12ff5b8@gmail.com>
Date: Fri, 24 May 2024 16:18:36 +0900
Subject: [PATCH] Support Managed Load Balancer as Resources (#122)
* Update documents for data source (ecl_mlb_*_v1)
* Add mocked tests for data source (ecl_mlb_*_v1)
* Fix data sources (ecl_mlb_*_v1)
* Add documents for resource (ecl_mlb_*_v1)
* Remove unnecessary comments (ecl_mlb_*_v1)
* Support Managed Load Balancer as Resources
* Add examples for Managed Load Balancer
* Fix links in website/docs/r/mlb_* / Update eclcloud
* Fix dependencies in examples for Managed Load Balancer
* Add ecl_mlb_load_balancer_action_v1 to examples/managed-load-balancer/resources as comments
* Update eclcloud to v2.8.0
---
ecl/data_source_ecl_mlb_certificate_v1.go | 43 +-
...source_ecl_mlb_certificate_v1_mock_test.go | 117 +-
ecl/data_source_ecl_mlb_health_monitor_v1.go | 9 +-
...rce_ecl_mlb_health_monitor_v1_mock_test.go | 737 ++++++++++-
ecl/data_source_ecl_mlb_listener_v1.go | 9 +-
...ta_source_ecl_mlb_listener_v1_mock_test.go | 429 ++++++-
ecl/data_source_ecl_mlb_load_balancer_v1.go | 35 +-
...urce_ecl_mlb_load_balancer_v1_mock_test.go | 965 ++++++++++++++-
ecl/data_source_ecl_mlb_operation_v1.go | 21 +-
...a_source_ecl_mlb_operation_v1_mock_test.go | 172 ++-
ecl/data_source_ecl_mlb_plan_v1.go | 9 +-
ecl/data_source_ecl_mlb_plan_v1_mock_test.go | 772 +++++++++++-
ecl/data_source_ecl_mlb_policy_v1.go | 9 +-
...data_source_ecl_mlb_policy_v1_mock_test.go | 1020 +++++++++++++++-
ecl/data_source_ecl_mlb_route_v1.go | 9 +-
ecl/data_source_ecl_mlb_route_v1_mock_test.go | 362 +++++-
ecl/data_source_ecl_mlb_rule_v1.go | 18 +-
ecl/data_source_ecl_mlb_rule_v1_mock_test.go | 477 +++++++-
ecl/data_source_ecl_mlb_system_update_v1.go | 13 +-
...urce_ecl_mlb_system_update_v1_mock_test.go | 240 +++-
ecl/data_source_ecl_mlb_target_group_v1.go | 9 +-
...ource_ecl_mlb_target_group_v1_mock_test.go | 290 ++++-
ecl/data_source_ecl_mlb_tls_policy_v1.go | 9 +-
..._source_ecl_mlb_tls_policy_v1_mock_test.go | 131 +-
...import_ecl_mlb_certificate_v1_mock_test.go | 44 +
...ort_ecl_mlb_health_monitor_v1_mock_test.go | 40 +
ecl/import_ecl_mlb_listener_v1_mock_test.go | 40 +
...port_ecl_mlb_load_balancer_v1_mock_test.go | 49 +
ecl/import_ecl_mlb_policy_v1_mock_test.go | 40 +
ecl/import_ecl_mlb_route_v1_mock_test.go | 40 +
ecl/import_ecl_mlb_rule_v1_mock_test.go | 40 +
...mport_ecl_mlb_target_group_v1_mock_test.go | 40 +
ecl/provider.go | 9 +
ecl/resource_ecl_mlb_certificate_v1.go | 193 +++
...source_ecl_mlb_certificate_v1_mock_test.go | 276 +++++
ecl/resource_ecl_mlb_health_monitor_v1.go | 377 ++++++
...rce_ecl_mlb_health_monitor_v1_mock_test.go | 565 +++++++++
ecl/resource_ecl_mlb_listener_v1.go | 301 +++++
ecl/resource_ecl_mlb_listener_v1_mock_test.go | 473 ++++++++
...esource_ecl_mlb_load_balancer_action_v1.go | 355 ++++++
...l_mlb_load_balancer_action_v1_mock_test.go | 511 ++++++++
ecl/resource_ecl_mlb_load_balancer_v1.go | 522 ++++++++
...urce_ecl_mlb_load_balancer_v1_mock_test.go | 1077 +++++++++++++++++
ecl/resource_ecl_mlb_policy_v1.go | 432 +++++++
ecl/resource_ecl_mlb_policy_v1_mock_test.go | 634 ++++++++++
ecl/resource_ecl_mlb_route_v1.go | 268 ++++
ecl/resource_ecl_mlb_route_v1_mock_test.go | 442 +++++++
ecl/resource_ecl_mlb_rule_v1.go | 346 ++++++
ecl/resource_ecl_mlb_rule_v1_mock_test.go | 516 ++++++++
ecl/resource_ecl_mlb_target_group_v1.go | 329 +++++
...ource_ecl_mlb_target_group_v1_mock_test.go | 570 +++++++++
ecl/testhelper/mock/mock.go | 11 +-
ecl/util.go | 8 +
examples/managed-load-balancer/README.md | 29 +
examples/managed-load-balancer/action/main.tf | 19 +
examples/managed-load-balancer/openrc.sample | 7 +
.../resources/certificate/ca_dummy.pem | 3 +
.../resources/certificate/server_dummy.crt | 3 +
.../resources/certificate/server_dummy.key | 3 +
.../managed-load-balancer/resources/main.tf | 142 +++
go.mod | 2 +-
go.sum | 8 +-
.../v1/certificates/doc.go | 2 -
.../v1/certificates/requests.go | 3 -
.../v1/certificates/results.go | 3 -
.../v1/certificates/urls.go | 3 -
.../v1/health_monitors/doc.go | 2 -
.../v1/health_monitors/requests.go | 3 -
.../v1/health_monitors/results.go | 3 -
.../v1/health_monitors/urls.go | 3 -
.../managed_load_balancer/v1/listeners/doc.go | 2 -
.../v1/listeners/requests.go | 3 -
.../v1/listeners/results.go | 3 -
.../v1/listeners/urls.go | 3 -
.../v1/load_balancers/doc.go | 31 +-
.../v1/load_balancers/requests.go | 60 +-
.../v1/load_balancers/results.go | 3 -
.../v1/load_balancers/urls.go | 3 -
.../v1/operations/doc.go | 2 -
.../v1/operations/requests.go | 3 -
.../v1/operations/results.go | 3 -
.../v1/operations/urls.go | 3 -
.../ecl/managed_load_balancer/v1/plans/doc.go | 2 -
.../v1/plans/requests.go | 3 -
.../managed_load_balancer/v1/plans/results.go | 3 -
.../managed_load_balancer/v1/plans/urls.go | 3 -
.../managed_load_balancer/v1/policies/doc.go | 2 -
.../v1/policies/requests.go | 3 -
.../v1/policies/results.go | 3 -
.../managed_load_balancer/v1/policies/urls.go | 3 -
.../managed_load_balancer/v1/routes/doc.go | 2 -
.../v1/routes/requests.go | 3 -
.../v1/routes/results.go | 3 -
.../managed_load_balancer/v1/routes/urls.go | 3 -
.../ecl/managed_load_balancer/v1/rules/doc.go | 2 -
.../v1/rules/requests.go | 3 -
.../managed_load_balancer/v1/rules/results.go | 3 -
.../managed_load_balancer/v1/rules/urls.go | 3 -
.../v1/system_updates/doc.go | 2 -
.../v1/system_updates/requests.go | 3 -
.../v1/system_updates/results.go | 3 -
.../v1/system_updates/urls.go | 3 -
.../v1/target_groups/doc.go | 2 -
.../v1/target_groups/requests.go | 3 -
.../v1/target_groups/results.go | 3 -
.../v1/target_groups/urls.go | 3 -
.../v1/tls_policies/doc.go | 2 -
.../v1/tls_policies/requests.go | 3 -
.../v1/tls_policies/results.go | 3 -
.../v1/tls_policies/urls.go | 3 -
vendor/modules.txt | 2 +-
.../docs/d/mlb_certificate_v1.html.markdown | 21 +-
.../d/mlb_health_monitor_v1.html.markdown | 11 +-
website/docs/d/mlb_listener_v1.html.markdown | 9 +-
.../docs/d/mlb_load_balancer_v1.html.markdown | 11 +-
website/docs/d/mlb_operation_v1.html.markdown | 22 +-
website/docs/d/mlb_plan_v1.html.markdown | 11 +-
website/docs/d/mlb_policy_v1.html.markdown | 9 +-
website/docs/d/mlb_route_v1.html.markdown | 9 +-
website/docs/d/mlb_rule_v1.html.markdown | 9 +-
.../docs/d/mlb_system_update_v1.html.markdown | 12 +-
.../docs/d/mlb_target_group_v1.html.markdown | 11 +-
.../docs/d/mlb_tls_policy_v1.html.markdown | 13 +-
.../docs/r/mlb_certificate_v1.html.markdown | 105 ++
.../r/mlb_health_monitor_v1.html.markdown | 97 ++
website/docs/r/mlb_listener_v1.html.markdown | 73 ++
.../mlb_load_balancer_action_v1.html.markdown | 66 +
.../docs/r/mlb_load_balancer_v1.html.markdown | 159 +++
website/docs/r/mlb_policy_v1.html.markdown | 153 +++
website/docs/r/mlb_route_v1.html.markdown | 78 ++
website/docs/r/mlb_rule_v1.html.markdown | 88 ++
.../docs/r/mlb_target_group_v1.html.markdown | 84 ++
132 files changed, 15485 insertions(+), 455 deletions(-)
create mode 100644 ecl/import_ecl_mlb_certificate_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_health_monitor_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_listener_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_load_balancer_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_policy_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_route_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_rule_v1_mock_test.go
create mode 100644 ecl/import_ecl_mlb_target_group_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_certificate_v1.go
create mode 100644 ecl/resource_ecl_mlb_certificate_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_health_monitor_v1.go
create mode 100644 ecl/resource_ecl_mlb_health_monitor_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_listener_v1.go
create mode 100644 ecl/resource_ecl_mlb_listener_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_load_balancer_action_v1.go
create mode 100644 ecl/resource_ecl_mlb_load_balancer_action_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_load_balancer_v1.go
create mode 100644 ecl/resource_ecl_mlb_load_balancer_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_policy_v1.go
create mode 100644 ecl/resource_ecl_mlb_policy_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_route_v1.go
create mode 100644 ecl/resource_ecl_mlb_route_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_rule_v1.go
create mode 100644 ecl/resource_ecl_mlb_rule_v1_mock_test.go
create mode 100644 ecl/resource_ecl_mlb_target_group_v1.go
create mode 100644 ecl/resource_ecl_mlb_target_group_v1_mock_test.go
create mode 100644 examples/managed-load-balancer/README.md
create mode 100644 examples/managed-load-balancer/action/main.tf
create mode 100644 examples/managed-load-balancer/openrc.sample
create mode 100644 examples/managed-load-balancer/resources/certificate/ca_dummy.pem
create mode 100644 examples/managed-load-balancer/resources/certificate/server_dummy.crt
create mode 100644 examples/managed-load-balancer/resources/certificate/server_dummy.key
create mode 100644 examples/managed-load-balancer/resources/main.tf
create mode 100644 website/docs/r/mlb_certificate_v1.html.markdown
create mode 100644 website/docs/r/mlb_health_monitor_v1.html.markdown
create mode 100644 website/docs/r/mlb_listener_v1.html.markdown
create mode 100644 website/docs/r/mlb_load_balancer_action_v1.html.markdown
create mode 100644 website/docs/r/mlb_load_balancer_v1.html.markdown
create mode 100644 website/docs/r/mlb_policy_v1.html.markdown
create mode 100644 website/docs/r/mlb_route_v1.html.markdown
create mode 100644 website/docs/r/mlb_rule_v1.html.markdown
create mode 100644 website/docs/r/mlb_target_group_v1.html.markdown
diff --git a/ecl/data_source_ecl_mlb_certificate_v1.go b/ecl/data_source_ecl_mlb_certificate_v1.go
index f059e596..902b11e9 100644
--- a/ecl/data_source_ecl_mlb_certificate_v1.go
+++ b/ecl/data_source_ecl_mlb_certificate_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -14,11 +11,9 @@ import (
func certificateFileSchemaForDataSource() *schema.Schema {
return &schema.Schema{
- Type: schema.TypeList,
+ Type: schema.TypeMap,
Optional: true,
Computed: true,
- MinItems: 1,
- MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"status": &schema.Schema{
@@ -86,23 +81,13 @@ func dataSourceMLBCertificateV1Read(d *schema.ResourceData, meta interface{}) er
listOpts.TenantID = v.(string)
}
- if v, ok := d.GetOk("ca_cert_status"); ok {
- listOpts.CACertStatus = v.(string)
- }
-
- if v, ok := d.GetOk("ssl_cert_status"); ok {
- listOpts.SSLCertStatus = v.(string)
- }
-
- if v, ok := d.GetOk("ssl_key_status"); ok {
- listOpts.SSLKeyStatus = v.(string)
- }
-
managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer certificates with options %+v", listOpts)
+
pages, err := certificates.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -110,7 +95,7 @@ func dataSourceMLBCertificateV1Read(d *schema.ResourceData, meta interface{}) er
allCertificates, err := certificates.ExtractCertificates(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve certificates: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer certificates with options %+v: %s", listOpts, err)
}
if len(allCertificates) < 1 {
@@ -125,24 +110,18 @@ func dataSourceMLBCertificateV1Read(d *schema.ResourceData, meta interface{}) er
certificate := allCertificates[0]
- log.Printf("[DEBUG] Retrieved certificate %s: %+v", d.Id(), certificate)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer certificate: %+v", certificate)
d.SetId(certificate.ID)
- sslKey := make([]interface{}, 1)
- sslKeyResult := make(map[string]interface{})
- sslKeyResult["status"] = certificate.SSLKey.Status
- sslKey[0] = sslKeyResult
+ sslKey := make(map[string]interface{})
+ sslKey["status"] = certificate.SSLKey.Status
- sslCert := make([]interface{}, 1)
- sslCertResult := make(map[string]interface{})
- sslCertResult["status"] = certificate.SSLCert.Status
- sslCert[0] = sslCertResult
+ sslCert := make(map[string]interface{})
+ sslCert["status"] = certificate.SSLCert.Status
- caCert := make([]interface{}, 1)
- caCertResult := make(map[string]interface{})
- caCertResult["status"] = certificate.CACert.Status
- caCert[0] = caCertResult
+ caCert := make(map[string]interface{})
+ caCert["status"] = certificate.CACert.Status
d.Set("name", certificate.Name)
d.Set("description", certificate.Description)
diff --git a/ecl/data_source_ecl_mlb_certificate_v1_mock_test.go b/ecl/data_source_ecl_mlb_certificate_v1_mock_test.go
index ffa03347..c2beb798 100644
--- a/ecl/data_source_ecl_mlb_certificate_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_certificate_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,8 @@ func TestMockedAccMLBV1CertificateDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesListNameQuery)
+ mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesListDescriptionQuery)
+ mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesListTenantIDQuery)
mc.StartServer(t)
@@ -30,14 +29,40 @@ func TestMockedAccMLBV1CertificateDataSource(t *testing.T) {
{
Config: testAccMLBV1CertificateDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_certificate_v1.certificate_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "name", "certificate"),
resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tags.key", "value"),
resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
- resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ca_cert.0.status", "NOT_UPLOADED"),
- resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_cert.0.status", "NOT_UPLOADED"),
- resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_key.0.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ca_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_key.status", "NOT_UPLOADED"),
+ ),
+ },
+ {
+ Config: testAccMLBV1CertificateDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "name", "certificate"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ca_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_key.status", "NOT_UPLOADED"),
+ ),
+ },
+ {
+ Config: testAccMLBV1CertificateDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "name", "certificate"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ca_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_cert.status", "NOT_UPLOADED"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_certificate_v1.certificate_1", "ssl_key.status", "NOT_UPLOADED"),
),
},
},
@@ -82,3 +107,81 @@ response:
]
}
`)
+
+var testAccMLBV1CertificateDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_certificate_v1" "certificate_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1CertificatesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "certificates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_key": {
+ "status": "NOT_UPLOADED"
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1CertificateDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_certificate_v1" "certificate_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1CertificatesListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "certificates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_key": {
+ "status": "NOT_UPLOADED"
+ }
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_health_monitor_v1.go b/ecl/data_source_ecl_mlb_health_monitor_v1.go
index 3b919997..fa9d01e6 100644
--- a/ecl/data_source_ecl_mlb_health_monitor_v1.go
+++ b/ecl/data_source_ecl_mlb_health_monitor_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -159,6 +156,8 @@ func dataSourceMLBHealthMonitorV1Read(d *schema.ResourceData, meta interface{})
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer health monitors with options %+v", listOpts)
+
pages, err := health_monitors.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -166,7 +165,7 @@ func dataSourceMLBHealthMonitorV1Read(d *schema.ResourceData, meta interface{})
allHealthMonitors, err := health_monitors.ExtractHealthMonitors(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve health monitors: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer health monitors with options %+v: %s", listOpts, err)
}
if len(allHealthMonitors) < 1 {
@@ -181,7 +180,7 @@ func dataSourceMLBHealthMonitorV1Read(d *schema.ResourceData, meta interface{})
healthMonitor := allHealthMonitors[0]
- log.Printf("[DEBUG] Retrieved health monitor %s: %+v", d.Id(), healthMonitor)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer health monitor: %+v", healthMonitor)
d.SetId(healthMonitor.ID)
diff --git a/ecl/data_source_ecl_mlb_health_monitor_v1_mock_test.go b/ecl/data_source_ecl_mlb_health_monitor_v1_mock_test.go
index 720c72cf..2bea92b0 100644
--- a/ecl/data_source_ecl_mlb_health_monitor_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_health_monitor_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,18 @@ func TestMockedAccMLBV1HealthMonitorDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListNameQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListDescriptionQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListConfigurationStatusQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListOperationStatusQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListPortQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListProtocolQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListIntervalQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListRetryQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListTimeoutQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListPathQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListHttpStatusCodeQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListLoadBalancerIDQuery)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +39,247 @@ func TestMockedAccMLBV1HealthMonitorDataSource(t *testing.T) {
{
Config: testAccMLBV1HealthMonitorDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryPort,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryProtocol,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryInterval,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryRetry,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryTimeout,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryPath,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryHttpStatusCode,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "protocol", "http"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "interval", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "retry", "3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "timeout", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "path", "/health"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "http_status_code", "200-299"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "name", "health_monitor"),
resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_health_monitor_v1.health_monitor_1", "tags.key", "value"),
@@ -90,3 +339,483 @@ response:
]
}
`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryPort = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ port = "80"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListPortQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ port:
+ - 80
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryProtocol = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ protocol = "http"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListProtocolQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ protocol:
+ - http
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryInterval = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ interval = "5"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListIntervalQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ interval:
+ - 5
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryRetry = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ retry = "3"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListRetryQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ retry:
+ - 3
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryTimeout = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ timeout = "5"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListTimeoutQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ timeout:
+ - 5
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryPath = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ path = "/health"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListPathQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ path:
+ - /health
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryHttpStatusCode = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ http_status_code = "200-299"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListHttpStatusCodeQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ http_status_code:
+ - 200-299
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1HealthMonitorDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_health_monitor_v1" "health_monitor_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1HealthMonitorsListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_listener_v1.go b/ecl/data_source_ecl_mlb_listener_v1.go
index 3dcf5aa3..24ed30a3 100644
--- a/ecl/data_source_ecl_mlb_listener_v1.go
+++ b/ecl/data_source_ecl_mlb_listener_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -123,6 +120,8 @@ func dataSourceMLBListenerV1Read(d *schema.ResourceData, meta interface{}) error
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer listeners with options %+v", listOpts)
+
pages, err := listeners.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -130,7 +129,7 @@ func dataSourceMLBListenerV1Read(d *schema.ResourceData, meta interface{}) error
allListeners, err := listeners.ExtractListeners(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve listeners: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer listeners with options %+v: %s", listOpts, err)
}
if len(allListeners) < 1 {
@@ -145,7 +144,7 @@ func dataSourceMLBListenerV1Read(d *schema.ResourceData, meta interface{}) error
listener := allListeners[0]
- log.Printf("[DEBUG] Retrieved listener %s: %+v", d.Id(), listener)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer listener: %+v", listener)
d.SetId(listener.ID)
diff --git a/ecl/data_source_ecl_mlb_listener_v1_mock_test.go b/ecl/data_source_ecl_mlb_listener_v1_mock_test.go
index b72c037e..05c5d28a 100644
--- a/ecl/data_source_ecl_mlb_listener_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_listener_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,14 @@ func TestMockedAccMLBV1ListenerDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListNameQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListDescriptionQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListConfigurationStatusQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListOperationStatusQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListIPAddressQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListPortQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListProtocolQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListLoadBalancerIDQuery)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +35,135 @@ func TestMockedAccMLBV1ListenerDataSource(t *testing.T) {
{
Config: testAccMLBV1ListenerDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_listener_v1.listener_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryIPAddress,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryPort,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryProtocol,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "port", "443"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "protocol", "https"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "name", "listener"),
resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_listener_v1.listener_1", "tags.key", "value"),
@@ -82,3 +215,291 @@ response:
]
}
`)
+
+var testAccMLBV1ListenerDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1ListenersListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1ListenersListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1ListenersListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryIPAddress = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ ip_address = "10.0.0.1"
+}
+`)
+
+var testMockMLBV1ListenersListIPAddressQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ ip_address:
+ - 10.0.0.1
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryPort = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ port = "443"
+}
+`)
+
+var testMockMLBV1ListenersListPortQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ port:
+ - 443
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryProtocol = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ protocol = "https"
+}
+`)
+
+var testMockMLBV1ListenersListProtocolQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ protocol:
+ - https
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1ListenersListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1ListenerDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_listener_v1" "listener_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1ListenersListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "listeners": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_load_balancer_v1.go b/ecl/data_source_ecl_mlb_load_balancer_v1.go
index b70efa42..264985b1 100644
--- a/ecl/data_source_ecl_mlb_load_balancer_v1.go
+++ b/ecl/data_source_ecl_mlb_load_balancer_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -220,6 +217,8 @@ func dataSourceMLBLoadBalancerV1Read(d *schema.ResourceData, meta interface{}) e
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer load balancers with options %+v", listOpts)
+
pages, err := load_balancers.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -227,7 +226,7 @@ func dataSourceMLBLoadBalancerV1Read(d *schema.ResourceData, meta interface{}) e
allLoadBalancers, err := load_balancers.ExtractLoadBalancers(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve load balancers: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer load balancers with options %+v: %s", listOpts, err)
}
if len(allLoadBalancers) < 1 {
@@ -242,7 +241,7 @@ func dataSourceMLBLoadBalancerV1Read(d *schema.ResourceData, meta interface{}) e
loadBalancer := allLoadBalancers[0]
- log.Printf("[DEBUG] Retrieved load balancer %s: %+v", d.Id(), loadBalancer)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer load balancer: %+v", loadBalancer)
d.SetId(loadBalancer.ID)
@@ -250,29 +249,29 @@ func dataSourceMLBLoadBalancerV1Read(d *schema.ResourceData, meta interface{}) e
for i, interfaceV := range loadBalancer.Interfaces {
results := make([]interface{}, len(interfaceV.ReservedFixedIPs))
for j, reservedFixedIP := range interfaceV.ReservedFixedIPs {
- result := make(map[string]interface{})
- result["ip_address"] = reservedFixedIP.IPAddress
- results[j] = result
+ results[j] = map[string]interface{}{
+ "ip_address": reservedFixedIP.IPAddress,
+ }
}
reservedFixedIPs[i] = results
}
interfaces := make([]interface{}, len(loadBalancer.Interfaces))
for i, interfaceV := range loadBalancer.Interfaces {
- result := make(map[string]interface{})
- result["network_id"] = interfaceV.NetworkID
- result["virtual_ip_address"] = interfaceV.VirtualIPAddress
- result["reserved_fixed_ips"] = reservedFixedIPs[i]
- interfaces[i] = result
+ interfaces[i] = map[string]interface{}{
+ "network_id": interfaceV.NetworkID,
+ "virtual_ip_address": interfaceV.VirtualIPAddress,
+ "reserved_fixed_ips": reservedFixedIPs[i],
+ }
}
syslogServers := make([]interface{}, len(loadBalancer.SyslogServers))
for i, syslogServer := range loadBalancer.SyslogServers {
- result := make(map[string]interface{})
- result["ip_address"] = syslogServer.IPAddress
- result["port"] = syslogServer.Port
- result["protocol"] = syslogServer.Protocol
- syslogServers[i] = result
+ syslogServers[i] = map[string]interface{}{
+ "ip_address": syslogServer.IPAddress,
+ "port": syslogServer.Port,
+ "protocol": syslogServer.Protocol,
+ }
}
d.Set("name", loadBalancer.Name)
diff --git a/ecl/data_source_ecl_mlb_load_balancer_v1_mock_test.go b/ecl/data_source_ecl_mlb_load_balancer_v1_mock_test.go
index 02f41ad8..74767975 100644
--- a/ecl/data_source_ecl_mlb_load_balancer_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_load_balancer_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,16 @@ func TestMockedAccMLBV1LoadBalancerDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListNameQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListDescriptionQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListConfigurationStatusQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListMonitoringStatusQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListOperationStatusQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListPrimaryAvailabilityZoneQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListSecondaryAvailabilityZoneQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListActiveAvailabilityZoneQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListRevisionQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListPlanIDQuery)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +37,287 @@ func TestMockedAccMLBV1LoadBalancerDataSource(t *testing.T) {
{
Config: testAccMLBV1LoadBalancerDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryMonitoringStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryPrimaryAvailabilityZone,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQuerySecondaryAvailabilityZone,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryActiveAvailabilityZone,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryRevision,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryPlanID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "monitoring_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "primary_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "secondary_availability_zone", "zone1_groupb"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "active_availability_zone", "zone1_groupa"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "plan_name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "name", "load_balancer"),
resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_load_balancer_v1.load_balancer_1", "tags.key", "value"),
@@ -59,18 +346,678 @@ func TestMockedAccMLBV1LoadBalancerDataSource(t *testing.T) {
})
}
-var testAccMLBV1LoadBalancerDataSourceQueryName = fmt.Sprintf(`
+var testAccMLBV1LoadBalancerDataSourceQueryName = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ name = "load_balancer"
+}
+`)
+
+var testMockMLBV1LoadBalancersListNameQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ name:
+ - load_balancer
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1LoadBalancersListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1LoadBalancersListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryMonitoringStatus = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ monitoring_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1LoadBalancersListMonitoringStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ monitoring_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1LoadBalancersListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryPrimaryAvailabilityZone = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ primary_availability_zone = "zone1_groupa"
+}
+`)
+
+var testMockMLBV1LoadBalancersListPrimaryAvailabilityZoneQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ primary_availability_zone:
+ - zone1_groupa
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQuerySecondaryAvailabilityZone = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ secondary_availability_zone = "zone1_groupb"
+}
+`)
+
+var testMockMLBV1LoadBalancersListSecondaryAvailabilityZoneQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ secondary_availability_zone:
+ - zone1_groupb
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryActiveAvailabilityZone = fmt.Sprintf(`
data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
- name = "load_balancer"
+ active_availability_zone = "zone1_groupa"
}
`)
-var testMockMLBV1LoadBalancersListNameQuery = fmt.Sprintf(`
+var testMockMLBV1LoadBalancersListActiveAvailabilityZoneQuery = fmt.Sprintf(`
request:
method: GET
query:
- name:
- - load_balancer
+ active_availability_zone:
+ - zone1_groupa
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryRevision = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ revision = "1"
+}
+`)
+
+var testMockMLBV1LoadBalancersListRevisionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ revision:
+ - 1
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryPlanID = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ plan_id = "00713021-9aea-41da-9a88-87760c08fa72"
+}
+`)
+
+var testMockMLBV1LoadBalancersListPlanIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ plan_id:
+ - 00713021-9aea-41da-9a88-87760c08fa72
+response:
+ code: 200
+ body: >
+ {
+ "load_balancers": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1LoadBalancerDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_load_balancer_v1" "load_balancer_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1LoadBalancersListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
response:
code: 200
body: >
diff --git a/ecl/data_source_ecl_mlb_operation_v1.go b/ecl/data_source_ecl_mlb_operation_v1.go
index b567b557..86533238 100644
--- a/ecl/data_source_ecl_mlb_operation_v1.go
+++ b/ecl/data_source_ecl_mlb_operation_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -97,10 +94,6 @@ func dataSourceMLBOperationV1Read(d *schema.ResourceData, meta interface{}) erro
listOpts.RequestID = v.(string)
}
- if v, ok := d.GetOk("request_type"); ok {
- listOpts.RequestType = v.(string)
- }
-
if v, ok := d.GetOk("status"); ok {
listOpts.Status = v.(string)
}
@@ -109,19 +102,13 @@ func dataSourceMLBOperationV1Read(d *schema.ResourceData, meta interface{}) erro
listOpts.TenantID = v.(string)
}
- if v, ok := d.GetOk("no_deleted"); ok {
- listOpts.NoDeleted = v.(bool)
- }
-
- if v, ok := d.GetOk("latest"); ok {
- listOpts.Latest = v.(bool)
- }
-
managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer operations with options %+v", listOpts)
+
pages, err := operations.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -129,7 +116,7 @@ func dataSourceMLBOperationV1Read(d *schema.ResourceData, meta interface{}) erro
allOperations, err := operations.ExtractOperations(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve operations: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer operations with options %+v: %s", listOpts, err)
}
if len(allOperations) < 1 {
@@ -144,7 +131,7 @@ func dataSourceMLBOperationV1Read(d *schema.ResourceData, meta interface{}) erro
operation := allOperations[0]
- log.Printf("[DEBUG] Retrieved operation %s: %+v", d.Id(), operation)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer operation: %+v", operation)
d.SetId(operation.ID)
diff --git a/ecl/data_source_ecl_mlb_operation_v1_mock_test.go b/ecl/data_source_ecl_mlb_operation_v1_mock_test.go
index 48d2d67a..b4f3e44b 100644
--- a/ecl/data_source_ecl_mlb_operation_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_operation_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -19,7 +16,10 @@ func TestMockedAccMLBV1OperationDataSource(t *testing.T) {
postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
- mc.Register(t, "operations", "/v1.0/operations", testMockMLBV1OperationsListNameQuery)
+ mc.Register(t, "operations", "/v1.0/operations", testMockMLBV1OperationsListResourceIDQuery)
+ mc.Register(t, "operations", "/v1.0/operations", testMockMLBV1OperationsListResourceTypeQuery)
+ mc.Register(t, "operations", "/v1.0/operations", testMockMLBV1OperationsListStatusQuery)
+ mc.Register(t, "operations", "/v1.0/operations", testMockMLBV1OperationsListTenantIDQuery)
mc.StartServer(t)
@@ -28,9 +28,57 @@ func TestMockedAccMLBV1OperationDataSource(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
- Config: testAccMLBV1OperationDataSourceQueryName,
+ Config: testAccMLBV1OperationDataSourceQueryResourceID,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_operation_v1.operation_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_id", "4d5215ed-38bb-48ed-879a-fdb9ca58522f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_type", "ECL::ManagedLoadBalancer::LoadBalancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_id", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_types.0", "Action::apply-configurations"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "reception_datetime", "2019-08-24 14:15:22"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "commit_datetime", "2019-08-24 14:30:44"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "warning", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "error", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1OperationDataSourceQueryResourceType,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_id", "4d5215ed-38bb-48ed-879a-fdb9ca58522f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_type", "ECL::ManagedLoadBalancer::LoadBalancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_id", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_types.0", "Action::apply-configurations"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "reception_datetime", "2019-08-24 14:15:22"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "commit_datetime", "2019-08-24 14:30:44"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "warning", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "error", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1OperationDataSourceQueryStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_id", "4d5215ed-38bb-48ed-879a-fdb9ca58522f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_type", "ECL::ManagedLoadBalancer::LoadBalancer"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_id", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_types.0", "Action::apply-configurations"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "reception_datetime", "2019-08-24 14:15:22"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "commit_datetime", "2019-08-24 14:30:44"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "warning", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "error", ""),
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1OperationDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_id", "4d5215ed-38bb-48ed-879a-fdb9ca58522f"),
resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "resource_type", "ECL::ManagedLoadBalancer::LoadBalancer"),
resource.TestCheckResourceAttr("data.ecl_mlb_operation_v1.operation_1", "request_id", ""),
@@ -47,13 +95,13 @@ func TestMockedAccMLBV1OperationDataSource(t *testing.T) {
})
}
-var testAccMLBV1OperationDataSourceQueryName = fmt.Sprintf(`
+var testAccMLBV1OperationDataSourceQueryResourceID = fmt.Sprintf(`
data "ecl_mlb_operation_v1" "operation_1" {
resource_id = "4d5215ed-38bb-48ed-879a-fdb9ca58522f"
}
`)
-var testMockMLBV1OperationsListNameQuery = fmt.Sprintf(`
+var testMockMLBV1OperationsListResourceIDQuery = fmt.Sprintf(`
request:
method: GET
query:
@@ -82,3 +130,111 @@ response:
]
}
`)
+
+var testAccMLBV1OperationDataSourceQueryResourceType = fmt.Sprintf(`
+data "ecl_mlb_operation_v1" "operation_1" {
+ resource_type = "ECL::ManagedLoadBalancer::LoadBalancer"
+}
+`)
+
+var testMockMLBV1OperationsListResourceTypeQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ resource_type:
+ - ECL::ManagedLoadBalancer::LoadBalancer
+response:
+ code: 200
+ body: >
+ {
+ "operations": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
+ "resource_type": "ECL::ManagedLoadBalancer::LoadBalancer",
+ "request_id": "",
+ "request_types": [
+ "Action::apply-configurations"
+ ],
+ "status": "COMPLETE",
+ "reception_datetime": "2019-08-24 14:15:22",
+ "commit_datetime": "2019-08-24 14:30:44",
+ "warning": "",
+ "error": "",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1OperationDataSourceQueryStatus = fmt.Sprintf(`
+data "ecl_mlb_operation_v1" "operation_1" {
+ status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1OperationsListStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "operations": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
+ "resource_type": "ECL::ManagedLoadBalancer::LoadBalancer",
+ "request_id": "",
+ "request_types": [
+ "Action::apply-configurations"
+ ],
+ "status": "COMPLETE",
+ "reception_datetime": "2019-08-24 14:15:22",
+ "commit_datetime": "2019-08-24 14:30:44",
+ "warning": "",
+ "error": "",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1OperationDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_operation_v1" "operation_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1OperationsListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "operations": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "resource_id": "4d5215ed-38bb-48ed-879a-fdb9ca58522f",
+ "resource_type": "ECL::ManagedLoadBalancer::LoadBalancer",
+ "request_id": "",
+ "request_types": [
+ "Action::apply-configurations"
+ ],
+ "status": "COMPLETE",
+ "reception_datetime": "2019-08-24 14:15:22",
+ "commit_datetime": "2019-08-24 14:30:44",
+ "warning": "",
+ "error": "",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0"
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_plan_v1.go b/ecl/data_source_ecl_mlb_plan_v1.go
index e8827419..b869d69b 100644
--- a/ecl/data_source_ecl_mlb_plan_v1.go
+++ b/ecl/data_source_ecl_mlb_plan_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -163,6 +160,8 @@ func dataSourceMLBPlanV1Read(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer plans with options %+v", listOpts)
+
pages, err := plans.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -170,7 +169,7 @@ func dataSourceMLBPlanV1Read(d *schema.ResourceData, meta interface{}) error {
allPlans, err := plans.ExtractPlans(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve plans: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer plans with options %+v: %s", listOpts, err)
}
if len(allPlans) < 1 {
@@ -185,7 +184,7 @@ func dataSourceMLBPlanV1Read(d *schema.ResourceData, meta interface{}) error {
plan := allPlans[0]
- log.Printf("[DEBUG] Retrieved plan %s: %+v", d.Id(), plan)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer plan: %+v", plan)
d.SetId(plan.ID)
diff --git a/ecl/data_source_ecl_mlb_plan_v1_mock_test.go b/ecl/data_source_ecl_mlb_plan_v1_mock_test.go
index 4c3b23dd..2408f17e 100644
--- a/ecl/data_source_ecl_mlb_plan_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_plan_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,19 @@ func TestMockedAccMLBV1PlanDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListNameQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListDescriptionQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListBandwidthQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListRedundancyQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfInterfacesQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfHealthMonitorsQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfListenersQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfPoliciesQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfRoutesQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfTargetGroupsQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfMembersQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfRulesQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListMaxNumberOfConditionsQuery)
+ mc.Register(t, "plans", "/v1.0/plans", testMockMLBV1PlansListEnabledQuery)
mc.StartServer(t)
@@ -30,7 +40,267 @@ func TestMockedAccMLBV1PlanDataSource(t *testing.T) {
{
Config: testAccMLBV1PlanDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_plan_v1.plan_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryBandwidth,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryRedundancy,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfInterfaces,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfHealthMonitors,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfListeners,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfPolicies,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfRoutes,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfTargetGroups,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfMembers,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfRules,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryMaxNumberOfConditions,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "redundancy", "HA"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_interfaces", "4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_health_monitors", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_listeners", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_policies", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_routes", "25"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_target_groups", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_members", "100"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_rules", "50"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "max_number_of_conditions", "5"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "enabled", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PlanDataSourceQueryEnabled,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "name", "50M_HA_4IF"),
resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_plan_v1.plan_1", "bandwidth", "50M"),
@@ -88,3 +358,497 @@ response:
]
}
`)
+
+var testAccMLBV1PlanDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1PlansListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryBandwidth = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ bandwidth = "50M"
+}
+`)
+
+var testMockMLBV1PlansListBandwidthQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ bandwidth:
+ - 50M
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryRedundancy = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ redundancy = "HA"
+}
+`)
+
+var testMockMLBV1PlansListRedundancyQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ redundancy:
+ - HA
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfInterfaces = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_interfaces = "4"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfInterfacesQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_interfaces:
+ - 4
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfHealthMonitors = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_health_monitors = "50"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfHealthMonitorsQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_health_monitors:
+ - 50
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfListeners = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_listeners = "50"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfListenersQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_listeners:
+ - 50
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfPolicies = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_policies = "50"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfPoliciesQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_policies:
+ - 50
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfRoutes = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_routes = "25"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfRoutesQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_routes:
+ - 25
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfTargetGroups = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_target_groups = "50"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfTargetGroupsQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_target_groups:
+ - 50
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfMembers = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_members = "100"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfMembersQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_members:
+ - 100
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfRules = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_rules = "50"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfRulesQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_rules:
+ - 50
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryMaxNumberOfConditions = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ max_number_of_conditions = "5"
+}
+`)
+
+var testMockMLBV1PlansListMaxNumberOfConditionsQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ max_number_of_conditions:
+ - 5
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PlanDataSourceQueryEnabled = fmt.Sprintf(`
+data "ecl_mlb_plan_v1" "plan_1" {
+ enabled = "true"
+}
+`)
+
+var testMockMLBV1PlansListEnabledQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ enabled:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "plans": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "50M_HA_4IF",
+ "description": "description",
+ "bandwidth": "50M",
+ "redundancy": "HA",
+ "max_number_of_interfaces": 4,
+ "max_number_of_health_monitors": 50,
+ "max_number_of_listeners": 50,
+ "max_number_of_policies": 50,
+ "max_number_of_routes": 25,
+ "max_number_of_target_groups": 50,
+ "max_number_of_members": 100,
+ "max_number_of_rules": 50,
+ "max_number_of_conditions": 5,
+ "enabled": true
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_policy_v1.go b/ecl/data_source_ecl_mlb_policy_v1.go
index bd0d4ba5..f843fbc3 100644
--- a/ecl/data_source_ecl_mlb_policy_v1.go
+++ b/ecl/data_source_ecl_mlb_policy_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -186,6 +183,8 @@ func dataSourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer policies with options %+v", listOpts)
+
pages, err := policies.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -193,7 +192,7 @@ func dataSourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
allPolicies, err := policies.ExtractPolicies(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve policies: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer policies with options %+v: %s", listOpts, err)
}
if len(allPolicies) < 1 {
@@ -208,7 +207,7 @@ func dataSourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
policy := allPolicies[0]
- log.Printf("[DEBUG] Retrieved policy %s: %+v", d.Id(), policy)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer policy: %+v", policy)
d.SetId(policy.ID)
diff --git a/ecl/data_source_ecl_mlb_policy_v1_mock_test.go b/ecl/data_source_ecl_mlb_policy_v1_mock_test.go
index eb584348..a3106a3f 100644
--- a/ecl/data_source_ecl_mlb_policy_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_policy_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,21 @@ func TestMockedAccMLBV1PolicyDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListNameQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListDescriptionQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListConfigurationStatusQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListOperationStatusQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListAlgorithmQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListPersistenceQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListIdleTimeoutQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListSorryPageUrlQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListSourceNatQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListCertificateIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListHealthMonitorIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListListenerIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListDefaultTargetGroupIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListTLSPolicyIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListLoadBalancerIDQuery)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +42,352 @@ func TestMockedAccMLBV1PolicyDataSource(t *testing.T) {
{
Config: testAccMLBV1PolicyDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_policy_v1.policy_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryAlgorithm,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryPersistence,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryIdleTimeout,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQuerySorryPageUrl,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQuerySourceNat,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryCertificateID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryHealthMonitorID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryListenerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryDefaultTargetGroupID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryTLSPolicyID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "name", "policy"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_policy_v1.policy_1", "tags.key", "value"),
@@ -54,18 +411,663 @@ func TestMockedAccMLBV1PolicyDataSource(t *testing.T) {
})
}
-var testAccMLBV1PolicyDataSourceQueryName = fmt.Sprintf(`
+var testAccMLBV1PolicyDataSourceQueryName = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ name = "policy"
+}
+`)
+
+var testMockMLBV1PoliciesListNameQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ name:
+ - policy
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1PoliciesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1PoliciesListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1PoliciesListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryAlgorithm = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ algorithm = "round-robin"
+}
+`)
+
+var testMockMLBV1PoliciesListAlgorithmQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ algorithm:
+ - round-robin
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryPersistence = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ persistence = "cookie"
+}
+`)
+
+var testMockMLBV1PoliciesListPersistenceQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ persistence:
+ - cookie
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryIdleTimeout = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ idle_timeout = "600"
+}
+`)
+
+var testMockMLBV1PoliciesListIdleTimeoutQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ idle_timeout:
+ - 600
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQuerySorryPageUrl = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ sorry_page_url = "https://example.com/sorry"
+}
+`)
+
+var testMockMLBV1PoliciesListSorryPageUrlQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ sorry_page_url:
+ - https://example.com/sorry
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQuerySourceNat = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ source_nat = "enable"
+}
+`)
+
+var testMockMLBV1PoliciesListSourceNatQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ source_nat:
+ - enable
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryCertificateID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ certificate_id = "f57a98fe-d63e-4048-93a0-51fe163f30d7"
+}
+`)
+
+var testMockMLBV1PoliciesListCertificateIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ certificate_id:
+ - f57a98fe-d63e-4048-93a0-51fe163f30d7
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryHealthMonitorID = fmt.Sprintf(`
data "ecl_mlb_policy_v1" "policy_1" {
- name = "policy"
+ health_monitor_id = "dd7a96d6-4e66-4666-baca-a8555f0c472c"
}
`)
-var testMockMLBV1PoliciesListNameQuery = fmt.Sprintf(`
+var testMockMLBV1PoliciesListHealthMonitorIDQuery = fmt.Sprintf(`
request:
method: GET
query:
- name:
- - policy
+ health_monitor_id:
+ - dd7a96d6-4e66-4666-baca-a8555f0c472c
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryListenerID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ listener_id = "68633f4f-f52a-402f-8572-b8173418904f"
+}
+`)
+
+var testMockMLBV1PoliciesListListenerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ listener_id:
+ - 68633f4f-f52a-402f-8572-b8173418904f
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryDefaultTargetGroupID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ default_target_group_id = "a44c4072-ed90-4b50-a33a-6b38fb10c7db"
+}
+`)
+
+var testMockMLBV1PoliciesListDefaultTargetGroupIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ default_target_group_id:
+ - a44c4072-ed90-4b50-a33a-6b38fb10c7db
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryTLSPolicyID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ tls_policy_id = "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+}
+`)
+
+var testMockMLBV1PoliciesListTLSPolicyIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tls_policy_id:
+ - 4ba79662-f2a1-41a4-a3d9-595799bbcd86
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1PoliciesListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1PolicyDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_policy_v1" "policy_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1PoliciesListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
response:
code: 200
body: >
diff --git a/ecl/data_source_ecl_mlb_route_v1.go b/ecl/data_source_ecl_mlb_route_v1.go
index b1f7ec23..37349287 100644
--- a/ecl/data_source_ecl_mlb_route_v1.go
+++ b/ecl/data_source_ecl_mlb_route_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -114,6 +111,8 @@ func dataSourceMLBRouteV1Read(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer routes with options %+v", listOpts)
+
pages, err := routes.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -121,7 +120,7 @@ func dataSourceMLBRouteV1Read(d *schema.ResourceData, meta interface{}) error {
allRoutes, err := routes.ExtractRoutes(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve routes: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer routes with options %+v: %s", listOpts, err)
}
if len(allRoutes) < 1 {
@@ -136,7 +135,7 @@ func dataSourceMLBRouteV1Read(d *schema.ResourceData, meta interface{}) error {
route := allRoutes[0]
- log.Printf("[DEBUG] Retrieved route %s: %+v", d.Id(), route)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer route: %+v", route)
d.SetId(route.ID)
diff --git a/ecl/data_source_ecl_mlb_route_v1_mock_test.go b/ecl/data_source_ecl_mlb_route_v1_mock_test.go
index 33cfacfa..0dbe1b22 100644
--- a/ecl/data_source_ecl_mlb_route_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_route_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,13 @@ func TestMockedAccMLBV1RouteDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListNameQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListDescriptionQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListConfigurationStatusQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListOperationStatusQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListDestinationCidrQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListNextHopIPAddressQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListLoadBalancerIDQuery)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +34,112 @@ func TestMockedAccMLBV1RouteDataSource(t *testing.T) {
{
Config: testAccMLBV1RouteDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_route_v1.route_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryDestinationCidr,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryNextHopIPAddress,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "next_hop_ip_address", "192.168.0.254"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "name", "route"),
resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_route_v1.route_1", "tags.key", "value"),
@@ -80,3 +189,248 @@ response:
]
}
`)
+
+var testAccMLBV1RouteDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1RoutesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1RoutesListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1RoutesListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryDestinationCidr = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ destination_cidr = "172.16.0.0/24"
+}
+`)
+
+var testMockMLBV1RoutesListDestinationCidrQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ destination_cidr:
+ - 172.16.0.0/24
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryNextHopIPAddress = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ next_hop_ip_address = "192.168.0.254"
+}
+`)
+
+var testMockMLBV1RoutesListNextHopIPAddressQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ next_hop_ip_address:
+ - 192.168.0.254
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1RoutesListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RouteDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_route_v1" "route_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1RoutesListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "routes": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_rule_v1.go b/ecl/data_source_ecl_mlb_rule_v1.go
index 5cc28e58..18fca221 100644
--- a/ecl/data_source_ecl_mlb_rule_v1.go
+++ b/ecl/data_source_ecl_mlb_rule_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -146,6 +143,8 @@ func dataSourceMLBRuleV1Read(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer rules with options %+v", listOpts)
+
pages, err := rules.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -153,7 +152,7 @@ func dataSourceMLBRuleV1Read(d *schema.ResourceData, meta interface{}) error {
allRules, err := rules.ExtractRules(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve rules: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer rules with options %+v: %s", listOpts, err)
}
if len(allRules) < 1 {
@@ -168,15 +167,10 @@ func dataSourceMLBRuleV1Read(d *schema.ResourceData, meta interface{}) error {
rule := allRules[0]
- log.Printf("[DEBUG] Retrieved rule %s: %+v", d.Id(), rule)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer rule: %+v", rule)
d.SetId(rule.ID)
- conditions := make([]interface{}, 1)
- conditionsResult := make(map[string]interface{})
- conditionsResult["path_patterns"] = rule.Conditions.PathPatterns
- conditions[0] = conditionsResult
-
d.Set("name", rule.Name)
d.Set("description", rule.Description)
d.Set("tags", rule.Tags)
@@ -187,7 +181,9 @@ func dataSourceMLBRuleV1Read(d *schema.ResourceData, meta interface{}) error {
d.Set("tenant_id", rule.TenantID)
d.Set("priority", rule.Priority)
d.Set("target_group_id", rule.TargetGroupID)
- d.Set("conditions", conditions)
+ d.Set("conditions", []interface{}{map[string]interface{}{
+ "path_patterns": rule.Conditions.PathPatterns,
+ }})
return nil
}
diff --git a/ecl/data_source_ecl_mlb_rule_v1_mock_test.go b/ecl/data_source_ecl_mlb_rule_v1_mock_test.go
index 450736c3..2dccacd0 100644
--- a/ecl/data_source_ecl_mlb_rule_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_rule_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,14 @@ func TestMockedAccMLBV1RuleDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListNameQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListDescriptionQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListConfigurationStatusQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListOperationStatusQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListPriorityQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListTargetGroupIDQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListPolicyIDQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListLoadBalancerIDQuery)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +35,143 @@ func TestMockedAccMLBV1RuleDataSource(t *testing.T) {
{
Config: testAccMLBV1RuleDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_rule_v1.rule_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryPriority,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryTargetGroupID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryPolicyID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "priority", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "name", "rule"),
resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_rule_v1.rule_1", "tags.key", "value"),
@@ -88,3 +229,331 @@ response:
]
}
`)
+
+var testAccMLBV1RuleDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1RulesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1RulesListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1RulesListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryPriority = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ priority = "1"
+}
+`)
+
+var testMockMLBV1RulesListPriorityQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ priority:
+ - 1
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryTargetGroupID = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ target_group_id = "29527a3c-9e5d-48b7-868f-6442c7d21a95"
+}
+`)
+
+var testMockMLBV1RulesListTargetGroupIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ target_group_id:
+ - 29527a3c-9e5d-48b7-868f-6442c7d21a95
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryPolicyID = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ policy_id = "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"
+}
+`)
+
+var testMockMLBV1RulesListPolicyIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ policy_id:
+ - fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1RulesListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1RuleDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_rule_v1" "rule_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1RulesListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "rules": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": [
+ "^/statics/"
+ ]
+ }
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_system_update_v1.go b/ecl/data_source_ecl_mlb_system_update_v1.go
index 40922aa9..4422a372 100644
--- a/ecl/data_source_ecl_mlb_system_update_v1.go
+++ b/ecl/data_source_ecl_mlb_system_update_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -96,15 +93,13 @@ func dataSourceMLBSystemUpdateV1Read(d *schema.ResourceData, meta interface{}) e
listOpts.Applicable = v.(bool)
}
- if v, ok := d.GetOk("latest"); ok {
- listOpts.Latest = v.(bool)
- }
-
managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
if err != nil {
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer system updates with options %+v", listOpts)
+
pages, err := system_updates.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -112,7 +107,7 @@ func dataSourceMLBSystemUpdateV1Read(d *schema.ResourceData, meta interface{}) e
allSystemUpdates, err := system_updates.ExtractSystemUpdates(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve system updates: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer system updates with options %+v: %s", listOpts, err)
}
if len(allSystemUpdates) < 1 {
@@ -127,7 +122,7 @@ func dataSourceMLBSystemUpdateV1Read(d *schema.ResourceData, meta interface{}) e
systemUpdate := allSystemUpdates[0]
- log.Printf("[DEBUG] Retrieved system update %s: %+v", d.Id(), systemUpdate)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer system update: %+v", systemUpdate)
d.SetId(systemUpdate.ID)
diff --git a/ecl/data_source_ecl_mlb_system_update_v1_mock_test.go b/ecl/data_source_ecl_mlb_system_update_v1_mock_test.go
index 8c3d8d2a..ccb862b7 100644
--- a/ecl/data_source_ecl_mlb_system_update_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_system_update_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,11 @@ func TestMockedAccMLBV1SystemUpdateDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListNameQuery)
+ mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListDescriptionQuery)
+ mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListHrefQuery)
+ mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListCurrentRevisionQuery)
+ mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListNextRevisionQuery)
+ mc.Register(t, "system_updates", "/v1.0/system_updates", testMockMLBV1SystemUpdatesListApplicableQuery)
mc.StartServer(t)
@@ -30,7 +32,77 @@ func TestMockedAccMLBV1SystemUpdateDataSource(t *testing.T) {
{
Config: testAccMLBV1SystemUpdateDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_system_update_v1.system_update_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "publish_datetime", "2022-10-03 00:00:00"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "limit_datetime", "2022-10-11 12:59:59"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "current_revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "next_revision", "2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "applicable", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1SystemUpdateDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "publish_datetime", "2022-10-03 00:00:00"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "limit_datetime", "2022-10-11 12:59:59"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "current_revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "next_revision", "2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "applicable", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1SystemUpdateDataSourceQueryHref,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "publish_datetime", "2022-10-03 00:00:00"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "limit_datetime", "2022-10-11 12:59:59"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "current_revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "next_revision", "2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "applicable", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1SystemUpdateDataSourceQueryCurrentRevision,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "publish_datetime", "2022-10-03 00:00:00"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "limit_datetime", "2022-10-11 12:59:59"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "current_revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "next_revision", "2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "applicable", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1SystemUpdateDataSourceQueryNextRevision,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "publish_datetime", "2022-10-03 00:00:00"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "limit_datetime", "2022-10-11 12:59:59"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "current_revision", "1"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "next_revision", "2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "applicable", "true"),
+ ),
+ },
+ {
+ Config: testAccMLBV1SystemUpdateDataSourceQueryApplicable,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "name", "security_update_202210"),
resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_system_update_v1.system_update_1", "href", "https://sdpf.ntt.com/news/2022100301/"),
@@ -76,3 +148,163 @@ response:
]
}
`)
+
+var testAccMLBV1SystemUpdateDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_system_update_v1" "system_update_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1SystemUpdatesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "system_updates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1SystemUpdateDataSourceQueryHref = fmt.Sprintf(`
+data "ecl_mlb_system_update_v1" "system_update_1" {
+ href = "https://sdpf.ntt.com/news/2022100301/"
+}
+`)
+
+var testMockMLBV1SystemUpdatesListHrefQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ href:
+ - https://sdpf.ntt.com/news/2022100301/
+response:
+ code: 200
+ body: >
+ {
+ "system_updates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1SystemUpdateDataSourceQueryCurrentRevision = fmt.Sprintf(`
+data "ecl_mlb_system_update_v1" "system_update_1" {
+ current_revision = "1"
+}
+`)
+
+var testMockMLBV1SystemUpdatesListCurrentRevisionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ current_revision:
+ - 1
+response:
+ code: 200
+ body: >
+ {
+ "system_updates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1SystemUpdateDataSourceQueryNextRevision = fmt.Sprintf(`
+data "ecl_mlb_system_update_v1" "system_update_1" {
+ next_revision = "2"
+}
+`)
+
+var testMockMLBV1SystemUpdatesListNextRevisionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ next_revision:
+ - 2
+response:
+ code: 200
+ body: >
+ {
+ "system_updates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1SystemUpdateDataSourceQueryApplicable = fmt.Sprintf(`
+data "ecl_mlb_system_update_v1" "system_update_1" {
+ applicable = "true"
+}
+`)
+
+var testMockMLBV1SystemUpdatesListApplicableQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ applicable:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "system_updates": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_target_group_v1.go b/ecl/data_source_ecl_mlb_target_group_v1.go
index c22435cd..3014285f 100644
--- a/ecl/data_source_ecl_mlb_target_group_v1.go
+++ b/ecl/data_source_ecl_mlb_target_group_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -125,6 +122,8 @@ func dataSourceMLBTargetGroupV1Read(d *schema.ResourceData, meta interface{}) er
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer target groups with options %+v", listOpts)
+
pages, err := target_groups.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -132,7 +131,7 @@ func dataSourceMLBTargetGroupV1Read(d *schema.ResourceData, meta interface{}) er
allTargetGroups, err := target_groups.ExtractTargetGroups(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve target groups: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer target groups with options %+v: %s", listOpts, err)
}
if len(allTargetGroups) < 1 {
@@ -147,7 +146,7 @@ func dataSourceMLBTargetGroupV1Read(d *schema.ResourceData, meta interface{}) er
targetGroup := allTargetGroups[0]
- log.Printf("[DEBUG] Retrieved target group %s: %+v", d.Id(), targetGroup)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer target group: %+v", targetGroup)
d.SetId(targetGroup.ID)
diff --git a/ecl/data_source_ecl_mlb_target_group_v1_mock_test.go b/ecl/data_source_ecl_mlb_target_group_v1_mock_test.go
index 11a13bf6..ebdb347f 100644
--- a/ecl/data_source_ecl_mlb_target_group_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_target_group_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,11 @@ func TestMockedAccMLBV1TargetGroupDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListNameQuery)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListDescriptionQuery)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListConfigurationStatusQuery)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListOperationStatusQuery)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListLoadBalancerIDQuery)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListTenantIDQuery)
mc.StartServer(t)
@@ -30,7 +32,87 @@ func TestMockedAccMLBV1TargetGroupDataSource(t *testing.T) {
{
Config: testAccMLBV1TargetGroupDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_target_group_v1.target_group_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupDataSourceQueryConfigurationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupDataSourceQueryOperationStatus,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupDataSourceQueryLoadBalancerID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "configuration_status", "ACTIVE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "operation_status", "COMPLETE"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupDataSourceQueryTenantID,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "name", "target_group"),
resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_target_group_v1.target_group_1", "tags.key", "value"),
@@ -86,3 +168,203 @@ response:
]
}
`)
+
+var testAccMLBV1TargetGroupDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_target_group_v1" "target_group_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1TargetGroupsListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1TargetGroupDataSourceQueryConfigurationStatus = fmt.Sprintf(`
+data "ecl_mlb_target_group_v1" "target_group_1" {
+ configuration_status = "ACTIVE"
+}
+`)
+
+var testMockMLBV1TargetGroupsListConfigurationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ configuration_status:
+ - ACTIVE
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1TargetGroupDataSourceQueryOperationStatus = fmt.Sprintf(`
+data "ecl_mlb_target_group_v1" "target_group_1" {
+ operation_status = "COMPLETE"
+}
+`)
+
+var testMockMLBV1TargetGroupsListOperationStatusQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ operation_status:
+ - COMPLETE
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1TargetGroupDataSourceQueryLoadBalancerID = fmt.Sprintf(`
+data "ecl_mlb_target_group_v1" "target_group_1" {
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1TargetGroupsListLoadBalancerIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 67fea379-cff0-4191-9175-de7d6941a040
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1TargetGroupDataSourceQueryTenantID = fmt.Sprintf(`
+data "ecl_mlb_target_group_v1" "target_group_1" {
+ tenant_id = "34f5c98ef430457ba81292637d0c6fd0"
+}
+`)
+
+var testMockMLBV1TargetGroupsListTenantIDQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ tenant_id:
+ - 34f5c98ef430457ba81292637d0c6fd0
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ ]
+ }
+`)
diff --git a/ecl/data_source_ecl_mlb_tls_policy_v1.go b/ecl/data_source_ecl_mlb_tls_policy_v1.go
index d37bccf8..0d021f87 100644
--- a/ecl/data_source_ecl_mlb_tls_policy_v1.go
+++ b/ecl/data_source_ecl_mlb_tls_policy_v1.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -82,6 +79,8 @@ func dataSourceMLBTLSPolicyV1Read(d *schema.ResourceData, meta interface{}) erro
return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
}
+ log.Printf("[DEBUG] Retrieving ECL managed load balancer TLS policies with options %+v", listOpts)
+
pages, err := tls_policies.List(managedLoadBalancerClient, listOpts).AllPages()
if err != nil {
return err
@@ -89,7 +88,7 @@ func dataSourceMLBTLSPolicyV1Read(d *schema.ResourceData, meta interface{}) erro
allTLSPolicies, err := tls_policies.ExtractTLSPolicies(pages)
if err != nil {
- return fmt.Errorf("Unable to retrieve tls policies: %s", err)
+ return fmt.Errorf("Unable to retrieve ECL managed load balancer TLS policies with options %+v: %s", listOpts, err)
}
if len(allTLSPolicies) < 1 {
@@ -104,7 +103,7 @@ func dataSourceMLBTLSPolicyV1Read(d *schema.ResourceData, meta interface{}) erro
tLSPolicy := allTLSPolicies[0]
- log.Printf("[DEBUG] Retrieved tls policy %s: %+v", d.Id(), tLSPolicy)
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer TLS policy: %+v", tLSPolicy)
d.SetId(tLSPolicy.ID)
diff --git a/ecl/data_source_ecl_mlb_tls_policy_v1_mock_test.go b/ecl/data_source_ecl_mlb_tls_policy_v1_mock_test.go
index 7304c672..8d615d79 100644
--- a/ecl/data_source_ecl_mlb_tls_policy_v1_mock_test.go
+++ b/ecl/data_source_ecl_mlb_tls_policy_v1_mock_test.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-*/
package ecl
import (
@@ -20,6 +17,8 @@ func TestMockedAccMLBV1TLSPolicyDataSource(t *testing.T) {
mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
mc.Register(t, "tls_policies", "/v1.0/tls_policies", testMockMLBV1TLSPoliciesListNameQuery)
+ mc.Register(t, "tls_policies", "/v1.0/tls_policies", testMockMLBV1TLSPoliciesListDescriptionQuery)
+ mc.Register(t, "tls_policies", "/v1.0/tls_policies", testMockMLBV1TLSPoliciesListDefaultQuery)
mc.StartServer(t)
@@ -30,7 +29,47 @@ func TestMockedAccMLBV1TLSPolicyDataSource(t *testing.T) {
{
Config: testAccMLBV1TLSPolicyDataSourceQueryName,
Check: resource.ComposeTestCheckFunc(
- resource.TestCheckResourceAttrSet("data.ecl_mlb_tls_policy_v1.tls_policy_1", "id"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "name", "TLSv1.2_202210_01"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "default", "true"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_protocols.0", "TLSv1.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_protocols.1", "TLSv1.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.0", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.1", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.2", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.3", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.4", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.5", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.6", "TLS_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.7", "TLS_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.8", "TLS_AES_128_GCM_SHA256"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TLSPolicyDataSourceQueryDescription,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "name", "TLSv1.2_202210_01"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "description", "description"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "default", "true"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_protocols.0", "TLSv1.2"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_protocols.1", "TLSv1.3"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.0", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.1", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.2", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.3", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.4", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.5", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.6", "TLS_AES_256_GCM_SHA384"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.7", "TLS_CHACHA20_POLY1305_SHA256"),
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "tls_ciphers.8", "TLS_AES_128_GCM_SHA256"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TLSPolicyDataSourceQueryDefault,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "name", "TLSv1.2_202210_01"),
resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "description", "description"),
resource.TestCheckResourceAttr("data.ecl_mlb_tls_policy_v1.tls_policy_1", "default", "true"),
@@ -92,3 +131,87 @@ response:
]
}
`)
+
+var testAccMLBV1TLSPolicyDataSourceQueryDescription = fmt.Sprintf(`
+data "ecl_mlb_tls_policy_v1" "tls_policy_1" {
+ description = "description"
+}
+`)
+
+var testMockMLBV1TLSPoliciesListDescriptionQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ description:
+ - description
+response:
+ code: 200
+ body: >
+ {
+ "tls_policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "TLSv1.2_202210_01",
+ "description": "description",
+ "default": true,
+ "tls_protocols": [
+ "TLSv1.2",
+ "TLSv1.3"
+ ],
+ "tls_ciphers": [
+ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
+ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
+ "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
+ "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
+ "TLS_AES_256_GCM_SHA384",
+ "TLS_CHACHA20_POLY1305_SHA256",
+ "TLS_AES_128_GCM_SHA256"
+ ]
+ }
+ ]
+ }
+`)
+
+var testAccMLBV1TLSPolicyDataSourceQueryDefault = fmt.Sprintf(`
+data "ecl_mlb_tls_policy_v1" "tls_policy_1" {
+ default = "true"
+}
+`)
+
+var testMockMLBV1TLSPoliciesListDefaultQuery = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ default:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "tls_policies": [
+ {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "TLSv1.2_202210_01",
+ "description": "description",
+ "default": true,
+ "tls_protocols": [
+ "TLSv1.2",
+ "TLSv1.3"
+ ],
+ "tls_ciphers": [
+ "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
+ "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
+ "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
+ "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
+ "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256",
+ "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256",
+ "TLS_AES_256_GCM_SHA384",
+ "TLS_CHACHA20_POLY1305_SHA256",
+ "TLS_AES_128_GCM_SHA256"
+ ]
+ }
+ ]
+ }
+`)
diff --git a/ecl/import_ecl_mlb_certificate_v1_mock_test.go b/ecl/import_ecl_mlb_certificate_v1_mock_test.go
new file mode 100644
index 00000000..f81d9928
--- /dev/null
+++ b/ecl/import_ecl_mlb_certificate_v1_mock_test.go
@@ -0,0 +1,44 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1CertificateImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesCreate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileCaCert)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslCert)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslKey)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterCreate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesDelete)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Certificate,
+ },
+ {
+ ResourceName: "ecl_mlb_certificate_v1.certificate",
+ ImportState: true,
+ ImportStateVerify: true,
+ ImportStateVerifyIgnore: []string{"ca_cert", "ssl_cert", "ssl_key"},
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_health_monitor_v1_mock_test.go b/ecl/import_ecl_mlb_health_monitor_v1_mock_test.go
new file mode 100644
index 00000000..fa8981ef
--- /dev/null
+++ b/ecl/import_ecl_mlb_health_monitor_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1HealthMonitorImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsCreate)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterCreate)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsDelete)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1HealthMonitor,
+ },
+ {
+ ResourceName: "ecl_mlb_health_monitor_v1.health_monitor",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_listener_v1_mock_test.go b/ecl/import_ecl_mlb_listener_v1_mock_test.go
new file mode 100644
index 00000000..575214c9
--- /dev/null
+++ b/ecl/import_ecl_mlb_listener_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1ListenerImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersCreate)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterCreate)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersDelete)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Listener,
+ },
+ {
+ ResourceName: "ecl_mlb_listener_v1.listener",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_load_balancer_v1_mock_test.go b/ecl/import_ecl_mlb_load_balancer_v1_mock_test.go
new file mode 100644
index 00000000..b1dad000
--- /dev/null
+++ b/ecl/import_ecl_mlb_load_balancer_v1_mock_test.go
@@ -0,0 +1,49 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1LoadBalancerImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersCreate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterCreate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersDelete)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancer,
+ },
+ {
+ ResourceName: "ecl_mlb_load_balancer_v1.load_balancer",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
+
+var testMockMLBV1LoadBalancersShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 404
+expectedStatus:
+ - Deleted
+`)
diff --git a/ecl/import_ecl_mlb_policy_v1_mock_test.go b/ecl/import_ecl_mlb_policy_v1_mock_test.go
new file mode 100644
index 00000000..3ebe4889
--- /dev/null
+++ b/ecl/import_ecl_mlb_policy_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1PolicyImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesCreate)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterCreate)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesDelete)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Policy,
+ },
+ {
+ ResourceName: "ecl_mlb_policy_v1.policy",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_route_v1_mock_test.go b/ecl/import_ecl_mlb_route_v1_mock_test.go
new file mode 100644
index 00000000..37a576b5
--- /dev/null
+++ b/ecl/import_ecl_mlb_route_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1RouteImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesCreate)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterCreate)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesDelete)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Route,
+ },
+ {
+ ResourceName: "ecl_mlb_route_v1.route",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_rule_v1_mock_test.go b/ecl/import_ecl_mlb_rule_v1_mock_test.go
new file mode 100644
index 00000000..43e3ad06
--- /dev/null
+++ b/ecl/import_ecl_mlb_rule_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1RuleImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesCreate)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterCreate)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesDelete)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Rule,
+ },
+ {
+ ResourceName: "ecl_mlb_rule_v1.rule",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/import_ecl_mlb_target_group_v1_mock_test.go b/ecl/import_ecl_mlb_target_group_v1_mock_test.go
new file mode 100644
index 00000000..478d7410
--- /dev/null
+++ b/ecl/import_ecl_mlb_target_group_v1_mock_test.go
@@ -0,0 +1,40 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1TargetGroupImport(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsCreate)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterCreate)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsDelete)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1TargetGroup,
+ },
+ {
+ ResourceName: "ecl_mlb_target_group_v1.target_group",
+ ImportState: true,
+ ImportStateVerify: true,
+ },
+ },
+ })
+}
diff --git a/ecl/provider.go b/ecl/provider.go
index 6af46f9d..a54a69a3 100644
--- a/ecl/provider.go
+++ b/ecl/provider.go
@@ -232,6 +232,15 @@ func Provider() terraform.ResourceProvider {
"ecl_imagestorages_image_v2": resourceImageStoragesImageV2(),
"ecl_imagestorages_member_accepter_v2": resourceImageStoragesMemberAccepterV2(),
"ecl_imagestorages_member_v2": resourceImageStoragesMemberV2(),
+ "ecl_mlb_certificate_v1": resourceMLBCertificateV1(),
+ "ecl_mlb_health_monitor_v1": resourceMLBHealthMonitorV1(),
+ "ecl_mlb_listener_v1": resourceMLBListenerV1(),
+ "ecl_mlb_load_balancer_v1": resourceMLBLoadBalancerV1(),
+ "ecl_mlb_load_balancer_action_v1": resourceMLBLoadBalancerActionV1(),
+ "ecl_mlb_policy_v1": resourceMLBPolicyV1(),
+ "ecl_mlb_route_v1": resourceMLBRouteV1(),
+ "ecl_mlb_rule_v1": resourceMLBRuleV1(),
+ "ecl_mlb_target_group_v1": resourceMLBTargetGroupV1(),
"ecl_network_common_function_gateway_v2": resourceNetworkCommonFunctionGatewayV2(),
"ecl_network_gateway_interface_v2": resourceNetworkGatewayInterfaceV2(),
"ecl_network_internet_gateway_v2": resourceNetworkInternetGatewayV2(),
diff --git a/ecl/resource_ecl_mlb_certificate_v1.go b/ecl/resource_ecl_mlb_certificate_v1.go
new file mode 100644
index 00000000..00bd3340
--- /dev/null
+++ b/ecl/resource_ecl_mlb_certificate_v1.go
@@ -0,0 +1,193 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+ "strings"
+
+ "github.com/hashicorp/terraform/helper/schema"
+
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates"
+)
+
+func certificateFileSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeMap,
+ Required: true,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "content": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ },
+ },
+ }
+}
+
+func resourceMLBCertificateV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBCertificateV1Create,
+ Read: reourceMLBCertificateV1Read,
+ Update: resourceMLBCertificateV1Update,
+ Delete: resourceMLBCertificateV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ },
+ "ca_cert": certificateFileSchemaForResource(),
+ "ssl_cert": certificateFileSchemaForResource(),
+ "ssl_key": certificateFileSchemaForResource(),
+ },
+ }
+
+ return result
+}
+
+func resourceMLBCertificateV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := certificates.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ }
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer certificate with options %+v", createOpts)
+
+ certificate, err := certificates.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer certificate with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(certificate.ID)
+ log.Printf("[INFO] ECL managed load balancer certificate ID: %s", certificate.ID)
+
+ for _, fileType := range []string{"ca_cert", "ssl_cert", "ssl_key"} {
+ file := d.Get(fileType).(map[string]interface{})
+ uploadFileOpts := certificates.UploadFileOpts{
+ Type: strings.Replace(fileType, "_", "-", -1),
+ Content: file["content"].(string),
+ }
+
+ log.Printf("[DEBUG] Uploading ECL managed load balancer certificate file (%s) with options %+v", d.Id(), uploadFileOpts)
+
+ err = certificates.UploadFile(managedLoadBalancerClient, certificate.ID, uploadFileOpts).ExtractErr()
+ if err != nil {
+ return fmt.Errorf("Error uploading ECL managed load balancer certificate file (%s) with options %+v: %s", d.Id(), uploadFileOpts, err)
+ }
+ }
+
+ return reourceMLBCertificateV1Read(d, meta)
+}
+
+func reourceMLBCertificateV1Read(d *schema.ResourceData, meta interface{}) error {
+ var certificate certificates.Certificate
+
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ err = certificates.Show(managedLoadBalancerClient, d.Id()).ExtractInto(&certificate)
+ if err != nil {
+ return CheckDeleted(d, err, "certificate")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer certificate (%s): %+v", d.Id(), certificate)
+
+ d.Set("name", certificate.Name)
+ d.Set("description", certificate.Description)
+ d.Set("tags", certificate.Tags)
+ d.Set("tenant_id", certificate.TenantID)
+
+ return nil
+}
+
+func resourceMLBCertificateV1Update(d *schema.ResourceData, meta interface{}) error {
+ var isUpdated bool
+ var updateOpts certificates.UpdateOpts
+
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ if d.HasChange("name") {
+ isUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer certificate (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := certificates.Update(managedLoadBalancerClient, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer certificate (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return reourceMLBCertificateV1Read(d, meta)
+}
+
+func resourceMLBCertificateV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer certificate (%s)", d.Id())
+
+ err = certificates.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer certificate (%s)", d.Id())
+ return nil
+ }
+ return fmt.Errorf("Error deleting ECL managed load balancer certificate: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_certificate_v1_mock_test.go b/ecl/resource_ecl_mlb_certificate_v1_mock_test.go
new file mode 100644
index 00000000..ce051766
--- /dev/null
+++ b/ecl/resource_ecl_mlb_certificate_v1_mock_test.go
@@ -0,0 +1,276 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1CertificateResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "certificates", "/v1.0/certificates", testMockMLBV1CertificatesCreate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileCaCert)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslCert)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08/files", testMockMLBV1CertificatesUploadFileSslKey)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterCreate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesUpdate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterUpdate)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesDelete)
+ mc.Register(t, "certificates", "/v1.0/certificates/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1CertificatesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Certificate,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "name", "certificate"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ca_cert.content"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ssl_cert.content"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ssl_key.content"),
+ ),
+ },
+ {
+ Config: testAccMLBV1CertificateUpdate,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "name", "certificate-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_certificate_v1.certificate", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ca_cert.content"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ssl_cert.content"),
+ resource.TestCheckResourceAttrSet("ecl_mlb_certificate_v1.certificate", "ssl_key.content"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1Certificate = fmt.Sprintf(`
+resource "ecl_mlb_certificate_v1" "certificate" {
+ name = "certificate"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ ca_cert = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+ ssl_cert = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+ ssl_key = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+}
+`)
+
+var testAccMLBV1CertificateUpdate = fmt.Sprintf(`
+resource "ecl_mlb_certificate_v1" "certificate" {
+ name = "certificate-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ ca_cert = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+ ssl_cert = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+ ssl_key = {
+ content = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="
+ }
+}
+`)
+
+var testMockMLBV1CertificatesCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"certificate":{"description":"description","name":"certificate","tags":{"key":"value"}}}
+response:
+ code: 200
+ body: >
+ {
+ "certificate": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "NOT_UPLOADED"
+ },
+ "ssl_key": {
+ "status": "NOT_UPLOADED"
+ }
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1CertificatesShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "certificate": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_key": {
+ "status": "UPLOADED"
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1CertificatesShowAfterUpdate = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "certificate": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_key": {
+ "status": "UPLOADED"
+ }
+ }
+ }
+expectedStatus:
+ - Updated
+`)
+
+var testMockMLBV1CertificatesShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 404
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1CertificatesUpdate = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"certificate":{"description":"description-update","name":"certificate-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "certificate": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "certificate-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ca_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_cert": {
+ "status": "UPLOADED"
+ },
+ "ssl_key": {
+ "status": "UPLOADED"
+ }
+ }
+ }
+newStatus: Updated
+`)
+
+var testMockMLBV1CertificatesDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - Updated
+newStatus: Deleted
+`)
+
+var testMockMLBV1CertificatesUploadFileCaCert = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==","type":"ca-cert"}
+response:
+ code: 204
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1CertificatesUploadFileSslCert = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==","type":"ssl-cert"}
+response:
+ code: 204
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1CertificatesUploadFileSslKey = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"content":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEKMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMwo0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1CjY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1NjcKODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OQpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCCkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0QKRUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRgpHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdICklKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUoKS0xNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTApNTk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OCk9QUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1AKUVJTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUgpTVFVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUClVWV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVYKV1hZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWApZWmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaCmFiY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWIKY2RlZmdoaWprbG1ub3BxcnN0dXZ3eHl6MDEyMzQ1Njc4OUFCQ0RFRkdISUpLTE1OT1BRUlNUVVZXWFlaYWJjZAplZmdoaWprbG1ub3BxcnN0dXZ3eHl6VjAxMjM0NTY3ODlBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWmFiY2RlCmZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==","type":"ssl-key"}
+response:
+ code: 204
+expectedStatus:
+ - Created
+`)
diff --git a/ecl/resource_ecl_mlb_health_monitor_v1.go b/ecl/resource_ecl_mlb_health_monitor_v1.go
new file mode 100644
index 00000000..eed8b961
--- /dev/null
+++ b/ecl/resource_ecl_mlb_health_monitor_v1.go
@@ -0,0 +1,377 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors"
+)
+
+func resourceMLBHealthMonitorV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBHealthMonitorV1Create,
+ Read: resourceMLBHealthMonitorV1Read,
+ Update: resourceMLBHealthMonitorV1Update,
+ Delete: resourceMLBHealthMonitorV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "port": &schema.Schema{
+ Type: schema.TypeInt,
+ Required: true,
+ },
+ "protocol": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "interval": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "retry": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "timeout": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "path": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "http_status_code": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ },
+ }
+
+ return result
+}
+
+func resourceMLBHealthMonitorV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := health_monitors.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ Port: d.Get("port").(int),
+ Protocol: d.Get("protocol").(string),
+ Interval: d.Get("interval").(int),
+ Retry: d.Get("retry").(int),
+ Timeout: d.Get("timeout").(int),
+ Path: d.Get("path").(string),
+ HttpStatusCode: d.Get("http_status_code").(string),
+ LoadBalancerID: d.Get("load_balancer_id").(string),
+ }
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer health monitor with options %+v", createOpts)
+
+ healthMonitor, err := health_monitors.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer health monitor with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(healthMonitor.ID)
+ log.Printf("[INFO] ECL managed load balancer health monitor ID: %s", healthMonitor.ID)
+
+ return resourceMLBHealthMonitorV1Read(d, meta)
+}
+
+func resourceMLBHealthMonitorV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*health_monitors.HealthMonitor, error) {
+ var healthMonitor health_monitors.HealthMonitor
+
+ showOpts := health_monitors.ShowOpts{Changes: changes}
+ err := health_monitors.Show(client, d.Id(), showOpts).ExtractInto(&healthMonitor)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer health monitor (%s): %s", d.Id(), err)
+ }
+
+ return &healthMonitor, nil
+}
+
+func resourceMLBHealthMonitorV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ healthMonitor, err := resourceMLBHealthMonitorV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "health_monitor")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer health monitor (%s): %+v", d.Id(), healthMonitor)
+
+ if healthMonitor.ConfigurationStatus == "ACTIVE" {
+ d.Set("port", healthMonitor.Port)
+ d.Set("protocol", healthMonitor.Protocol)
+ d.Set("interval", healthMonitor.Interval)
+ d.Set("retry", healthMonitor.Retry)
+ d.Set("timeout", healthMonitor.Timeout)
+ d.Set("path", healthMonitor.Path)
+ d.Set("http_status_code", healthMonitor.HttpStatusCode)
+ } else if healthMonitor.ConfigurationStatus == "CREATE_STAGED" {
+ d.Set("port", healthMonitor.Staged.Port)
+ d.Set("protocol", healthMonitor.Staged.Protocol)
+ d.Set("interval", healthMonitor.Staged.Interval)
+ d.Set("retry", healthMonitor.Staged.Retry)
+ d.Set("timeout", healthMonitor.Staged.Timeout)
+ d.Set("path", healthMonitor.Staged.Path)
+ d.Set("http_status_code", healthMonitor.Staged.HttpStatusCode)
+ } else if healthMonitor.ConfigurationStatus == "UPDATE_STAGED" {
+ d.Set("port", ternary(healthMonitor.Staged.Port == 0, healthMonitor.Port, healthMonitor.Staged.Port))
+ d.Set("protocol", ternary(healthMonitor.Staged.Protocol == "", healthMonitor.Protocol, healthMonitor.Staged.Protocol))
+ d.Set("interval", ternary(healthMonitor.Staged.Interval == 0, healthMonitor.Interval, healthMonitor.Staged.Interval))
+ d.Set("retry", ternary(healthMonitor.Staged.Retry == 0, healthMonitor.Retry, healthMonitor.Staged.Retry))
+ d.Set("timeout", ternary(healthMonitor.Staged.Timeout == 0, healthMonitor.Timeout, healthMonitor.Staged.Timeout))
+ d.Set("path", ternary(healthMonitor.Staged.Path == "", healthMonitor.Path, healthMonitor.Staged.Path))
+ d.Set("http_status_code", ternary(healthMonitor.Staged.HttpStatusCode == "", healthMonitor.HttpStatusCode, healthMonitor.Staged.HttpStatusCode))
+ } else if healthMonitor.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", healthMonitor.Name)
+ d.Set("description", healthMonitor.Description)
+ d.Set("tags", healthMonitor.Tags)
+ d.Set("load_balancer_id", healthMonitor.LoadBalancerID)
+ d.Set("tenant_id", healthMonitor.TenantID)
+
+ return nil
+}
+
+func resourceMLBHealthMonitorV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer health monitor ...")
+
+ err = resourceMLBHealthMonitorV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer health monitor: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer health monitor ...")
+
+ err = resourceMLBHealthMonitorV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer health monitor: %s", err)
+ }
+
+ return resourceMLBHealthMonitorV1Read(d, meta)
+}
+
+func resourceMLBHealthMonitorV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts health_monitors.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer health monitor attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := health_monitors.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer health monitor attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBHealthMonitorV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ healthMonitor, err := resourceMLBHealthMonitorV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if healthMonitor.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts health_monitors.CreateStagedOpts
+
+ if d.HasChange("port") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Port = d.Get("port").(int)
+ }
+
+ if d.HasChange("protocol") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Protocol = d.Get("protocol").(string)
+ }
+
+ if d.HasChange("interval") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Interval = d.Get("interval").(int)
+ }
+
+ if d.HasChange("retry") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Retry = d.Get("retry").(int)
+ }
+
+ if d.HasChange("timeout") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Timeout = d.Get("timeout").(int)
+ }
+
+ if d.HasChange("path") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Path = d.Get("path").(string)
+ }
+
+ if d.HasChange("http_status_code") {
+ isConfigurationsUpdated = true
+ createStagedOpts.HttpStatusCode = d.Get("http_status_code").(string)
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer health monitor configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := health_monitors.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer health monitor configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts health_monitors.UpdateStagedOpts
+
+ if d.HasChange("port") {
+ isConfigurationsUpdated = true
+ port := d.Get("port").(int)
+ updateStagedOpts.Port = &port
+ }
+
+ if d.HasChange("protocol") {
+ isConfigurationsUpdated = true
+ protocol := d.Get("protocol").(string)
+ updateStagedOpts.Protocol = &protocol
+ }
+
+ if d.HasChange("interval") {
+ isConfigurationsUpdated = true
+ interval := d.Get("interval").(int)
+ updateStagedOpts.Interval = &interval
+ }
+
+ if d.HasChange("retry") {
+ isConfigurationsUpdated = true
+ retry := d.Get("retry").(int)
+ updateStagedOpts.Retry = &retry
+ }
+
+ if d.HasChange("timeout") {
+ isConfigurationsUpdated = true
+ timeout := d.Get("timeout").(int)
+ updateStagedOpts.Timeout = &timeout
+ }
+
+ if d.HasChange("path") {
+ isConfigurationsUpdated = true
+ path := d.Get("path").(string)
+ updateStagedOpts.Path = &path
+ }
+
+ if d.HasChange("http_status_code") {
+ isConfigurationsUpdated = true
+ httpStatusCode := d.Get("http_status_code").(string)
+ updateStagedOpts.HttpStatusCode = &httpStatusCode
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer health monitor configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := health_monitors.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer health monitor configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBHealthMonitorV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer health monitor: %s", d.Id())
+
+ err = health_monitors.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer health monitor (%s)", d.Id())
+ return nil
+ }
+
+ healthMonitor, err := resourceMLBHealthMonitorV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if healthMonitor.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer health monitor (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer health monitor: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_health_monitor_v1_mock_test.go b/ecl/resource_ecl_mlb_health_monitor_v1_mock_test.go
new file mode 100644
index 00000000..62e9d555
--- /dev/null
+++ b/ecl/resource_ecl_mlb_health_monitor_v1_mock_test.go
@@ -0,0 +1,565 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1HealthMonitorResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsCreate)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterCreate)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsUpdateAttributes)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowBeforeUpdateConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1HealthMonitorsUpdateConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterApplyConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowBeforeCreateConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1HealthMonitorsCreateConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterCreateConfigurations)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsDelete)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1HealthMonitorsShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1HealthMonitor,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "name", "health_monitor"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "protocol", "http"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "interval", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "retry", "3"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "timeout", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "path", "/health"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "http_status_code", "200-299"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "name", "health_monitor-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "port", "0"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "protocol", "icmp"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "interval", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "retry", "3"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "timeout", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "path", ""),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "http_status_code", ""),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1HealthMonitorUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "name", "health_monitor-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "protocol", "http"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "interval", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "retry", "3"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "timeout", "5"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "path", "/health"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "http_status_code", "200-299"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_health_monitor_v1.health_monitor", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1HealthMonitor = fmt.Sprintf(`
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ name = "health_monitor"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ port = 80
+ protocol = "http"
+ interval = 5
+ retry = 3
+ timeout = 5
+ path = "/health"
+ http_status_code = "200-299"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1HealthMonitorUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ name = "health_monitor-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ port = 0
+ protocol = "icmp"
+ interval = 5
+ retry = 3
+ timeout = 5
+ path = ""
+ http_status_code = ""
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1HealthMonitorUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ name = "health_monitor-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ port = 80
+ protocol = "http"
+ interval = 5
+ retry = 3
+ timeout = 5
+ path = "/health"
+ http_status_code = "200-299"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1HealthMonitorsCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"health_monitor":{"description":"description","http_status_code":"200-299","interval":5,"load_balancer_id":"67fea379-cff0-4191-9175-de7d6941a040","name":"health_monitor","path":"/health","port":80,"protocol":"http","retry":3,"tags":{"key":"value"},"timeout":5}}
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": null,
+ "protocol": null,
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": null,
+ "http_status_code": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1HealthMonitorsShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": null,
+ "protocol": null,
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": null,
+ "http_status_code": null,
+ "current": null,
+ "staged": {
+ "port": 80,
+ "protocol": "http",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1HealthMonitorsShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": null,
+ "protocol": null,
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": null,
+ "http_status_code": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1HealthMonitorsShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": null,
+ "protocol": null,
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": null,
+ "http_status_code": null,
+ "current": null,
+ "staged": {
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1HealthMonitorsShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": "",
+ "current": {
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1HealthMonitorsShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1HealthMonitorsShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": "",
+ "current": {
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ },
+ "staged": {
+ "port": 80,
+ "protocol": "http",
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1HealthMonitorsShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": "",
+ "current": {
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1HealthMonitorsUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"health_monitor":{"description":"description-update","name":"health_monitor-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "health_monitor-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "port": null,
+ "protocol": null,
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": null,
+ "http_status_code": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1HealthMonitorsCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"health_monitor":{"http_status_code":"200-299","path":"/health","port":80,"protocol":"http"}}
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "port": 80,
+ "protocol": "http",
+ "interval": null,
+ "retry": null,
+ "timeout": null,
+ "path": "/health",
+ "http_status_code": "200-299"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1HealthMonitorsUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"health_monitor":{"http_status_code":"","path":"","port":0,"protocol":"icmp"}}
+response:
+ code: 200
+ body: >
+ {
+ "health_monitor": {
+ "port": 0,
+ "protocol": "icmp",
+ "interval": 5,
+ "retry": 3,
+ "timeout": 5,
+ "path": "",
+ "http_status_code": ""
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1HealthMonitorsDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_listener_v1.go b/ecl/resource_ecl_mlb_listener_v1.go
new file mode 100644
index 00000000..493fbc19
--- /dev/null
+++ b/ecl/resource_ecl_mlb_listener_v1.go
@@ -0,0 +1,301 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners"
+)
+
+func resourceMLBListenerV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBListenerV1Create,
+ Read: resourceMLBListenerV1Read,
+ Update: resourceMLBListenerV1Update,
+ Delete: resourceMLBListenerV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "port": &schema.Schema{
+ Type: schema.TypeInt,
+ Required: true,
+ },
+ "protocol": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ },
+ }
+
+ return result
+}
+
+func resourceMLBListenerV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := listeners.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ IPAddress: d.Get("ip_address").(string),
+ Port: d.Get("port").(int),
+ Protocol: d.Get("protocol").(string),
+ LoadBalancerID: d.Get("load_balancer_id").(string),
+ }
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer listener with options %+v", createOpts)
+
+ listener, err := listeners.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer listener with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(listener.ID)
+ log.Printf("[INFO] ECL managed load balancer listener ID: %s", listener.ID)
+
+ return resourceMLBListenerV1Read(d, meta)
+}
+
+func resourceMLBListenerV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*listeners.Listener, error) {
+ var listener listeners.Listener
+
+ showOpts := listeners.ShowOpts{Changes: changes}
+ err := listeners.Show(client, d.Id(), showOpts).ExtractInto(&listener)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer listener (%s): %s", d.Id(), err)
+ }
+
+ return &listener, nil
+}
+
+func resourceMLBListenerV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ listener, err := resourceMLBListenerV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "listener")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer listener (%s): %+v", d.Id(), listener)
+
+ if listener.ConfigurationStatus == "ACTIVE" {
+ d.Set("ip_address", listener.IPAddress)
+ d.Set("port", listener.Port)
+ d.Set("protocol", listener.Protocol)
+ } else if listener.ConfigurationStatus == "CREATE_STAGED" {
+ d.Set("ip_address", listener.Staged.IPAddress)
+ d.Set("port", listener.Staged.Port)
+ d.Set("protocol", listener.Staged.Protocol)
+ } else if listener.ConfigurationStatus == "UPDATE_STAGED" {
+ d.Set("ip_address", ternary(listener.Staged.IPAddress == "", listener.IPAddress, listener.Staged.IPAddress))
+ d.Set("port", ternary(listener.Staged.Port == 0, listener.Port, listener.Staged.Port))
+ d.Set("protocol", ternary(listener.Staged.Protocol == "", listener.Protocol, listener.Staged.Protocol))
+ } else if listener.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", listener.Name)
+ d.Set("description", listener.Description)
+ d.Set("tags", listener.Tags)
+ d.Set("load_balancer_id", listener.LoadBalancerID)
+ d.Set("tenant_id", listener.TenantID)
+
+ return nil
+}
+
+func resourceMLBListenerV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer listener ...")
+
+ err = resourceMLBListenerV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer listener: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer listener ...")
+
+ err = resourceMLBListenerV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer listener: %s", err)
+ }
+
+ return resourceMLBListenerV1Read(d, meta)
+}
+
+func resourceMLBListenerV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts listeners.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer listener attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := listeners.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer listener attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBListenerV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ listener, err := resourceMLBListenerV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if listener.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts listeners.CreateStagedOpts
+
+ if d.HasChange("ip_address") {
+ isConfigurationsUpdated = true
+ createStagedOpts.IPAddress = d.Get("ip_address").(string)
+ }
+
+ if d.HasChange("port") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Port = d.Get("port").(int)
+ }
+
+ if d.HasChange("protocol") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Protocol = d.Get("protocol").(string)
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer listener configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := listeners.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer listener configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts listeners.UpdateStagedOpts
+
+ if d.HasChange("ip_address") {
+ isConfigurationsUpdated = true
+ ipAddress := d.Get("ip_address").(string)
+ updateStagedOpts.IPAddress = &ipAddress
+ }
+
+ if d.HasChange("port") {
+ isConfigurationsUpdated = true
+ port := d.Get("port").(int)
+ updateStagedOpts.Port = &port
+ }
+
+ if d.HasChange("protocol") {
+ isConfigurationsUpdated = true
+ protocol := d.Get("protocol").(string)
+ updateStagedOpts.Protocol = &protocol
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer listener configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := listeners.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer listener configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBListenerV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer listener: %s", d.Id())
+
+ err = listeners.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer listener (%s)", d.Id())
+ return nil
+ }
+
+ listener, err := resourceMLBListenerV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if listener.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer listener (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer listener: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_listener_v1_mock_test.go b/ecl/resource_ecl_mlb_listener_v1_mock_test.go
new file mode 100644
index 00000000..a26db67c
--- /dev/null
+++ b/ecl/resource_ecl_mlb_listener_v1_mock_test.go
@@ -0,0 +1,473 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1ListenerResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersCreate)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterCreate)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersUpdateAttributes)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowBeforeUpdateConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1ListenersUpdateConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterApplyConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowBeforeCreateConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1ListenersCreateConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterCreateConfigurations)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersDelete)
+ mc.Register(t, "listeners", "/v1.0/listeners/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1ListenersShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Listener,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "name", "listener"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "protocol", "http"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "name", "listener-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "port", "443"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "protocol", "https"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1ListenerUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "name", "listener-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "ip_address", "10.0.0.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "protocol", "http"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_listener_v1.listener", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1Listener = fmt.Sprintf(`
+resource "ecl_mlb_listener_v1" "listener" {
+ name = "listener"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ ip_address = "10.0.0.1"
+ port = 80
+ protocol = "http"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1ListenerUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_listener_v1" "listener" {
+ name = "listener-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ ip_address = "10.0.0.1"
+ port = 443
+ protocol = "https"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1ListenerUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_listener_v1" "listener" {
+ name = "listener-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ ip_address = "10.0.0.1"
+ port = 80
+ protocol = "http"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1ListenersCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"listener":{"description":"description","ip_address":"10.0.0.1","load_balancer_id":"67fea379-cff0-4191-9175-de7d6941a040","name":"listener","port":80,"protocol":"http","tags":{"key":"value"}}}
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": null,
+ "port": null,
+ "protocol": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1ListenersShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": null,
+ "port": null,
+ "protocol": null,
+ "current": null,
+ "staged": {
+ "ip_address": "10.0.0.1",
+ "port": 80,
+ "protocol": "http"
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1ListenersShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": null,
+ "port": null,
+ "protocol": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1ListenersShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": null,
+ "port": null,
+ "protocol": null,
+ "current": null,
+ "staged": {
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1ListenersShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https",
+ "current": {
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1ListenersShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1ListenersShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https",
+ "current": {
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ },
+ "staged": {
+ "ip_address": null,
+ "port": 80,
+ "protocol": "http"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1ListenersShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https",
+ "current": {
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1ListenersUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"listener":{"description":"description-update","name":"listener-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "listener-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "ip_address": null,
+ "port": null,
+ "protocol": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1ListenersCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"listener":{"port":80,"protocol":"http"}}
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "ip_address": null,
+ "port": 80,
+ "protocol": "http"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1ListenersUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"listener":{"port":443,"protocol":"https"}}
+response:
+ code: 200
+ body: >
+ {
+ "listener": {
+ "ip_address": "10.0.0.1",
+ "port": 443,
+ "protocol": "https"
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1ListenersDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_load_balancer_action_v1.go b/ecl/resource_ecl_mlb_load_balancer_action_v1.go
new file mode 100644
index 00000000..6abae666
--- /dev/null
+++ b/ecl/resource_ecl_mlb_load_balancer_action_v1.go
@@ -0,0 +1,355 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+ "time"
+
+ "github.com/hashicorp/terraform/helper/resource"
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups"
+)
+
+func resourceMLBLoadBalancerActionV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBLoadBalancerActionV1Perform,
+ Read: resourceMLBLoadBalancerActionV1Read,
+ Update: resourceMLBLoadBalancerActionV1Perform,
+ Delete: resourceMLBLoadBalancerActionV1Delete,
+ Timeouts: &schema.ResourceTimeout{
+ Create: schema.DefaultTimeout(1 * time.Hour),
+ Update: schema.DefaultTimeout(1 * time.Hour),
+ },
+ Schema: map[string]*schema.Schema{
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "apply_configurations": &schema.Schema{
+ Type: schema.TypeBool,
+ Optional: true,
+ },
+ "system_update": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "system_update_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ },
+ },
+ },
+ },
+ }
+
+ return result
+}
+
+func resourceMLBLoadBalancerActionV1CheckApplyConfigurationsRequired(d *schema.ResourceData, client *eclcloud.ServiceClient) (bool, error) {
+ loadBalancer, err := resourceMLBLoadBalancerActionV1ShowLoadBalancer(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ if loadBalancer.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of load balancer (%s) is not ACTIVE", loadBalancer.ConfigurationStatus, loadBalancer.ID)
+ return true, nil
+ }
+
+ healthMonitors, err := resourceMLBLoadBalancerActionV1ListHealthMonitors(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, healthMonitor := range *healthMonitors {
+ if healthMonitor.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of health monitor (%s) is not ACTIVE", healthMonitor.ConfigurationStatus, healthMonitor.ID)
+ return true, nil
+ }
+ }
+
+ listeners, err := resourceMLBLoadBalancerActionV1ListListeners(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, listener := range *listeners {
+ if listener.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of listener (%s) is not ACTIVE", listener.ConfigurationStatus, listener.ID)
+ return true, nil
+ }
+ }
+
+ policies, err := resourceMLBLoadBalancerActionV1ListPolicies(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, policy := range *policies {
+ if policy.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of policy (%s) is not ACTIVE", policy.ConfigurationStatus, policy.ID)
+ return true, nil
+ }
+ }
+
+ routes, err := resourceMLBLoadBalancerActionV1ListRoutes(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, route := range *routes {
+ if route.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of route (%s) is not ACTIVE", route.ConfigurationStatus, route.ID)
+ return true, nil
+ }
+ }
+
+ rules, err := resourceMLBLoadBalancerActionV1ListRules(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, rule := range *rules {
+ if rule.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of rule (%s) is not ACTIVE", rule.ConfigurationStatus, rule.ID)
+ return true, nil
+ }
+ }
+
+ targetGroups, err := resourceMLBLoadBalancerActionV1ListTargetGroups(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ for _, targetGroup := range *targetGroups {
+ if targetGroup.ConfigurationStatus != "ACTIVE" {
+ log.Printf("[DEBUG] configuration_status (%s) of target group (%s) is not ACTIVE", targetGroup.ConfigurationStatus, targetGroup.ID)
+ return true, nil
+ }
+ }
+
+ return false, nil
+}
+
+func resourceMLBLoadBalancerActionV1CheckSystemUpdateRequired(d *schema.ResourceData, client *eclcloud.ServiceClient) (bool, error) {
+ var systemUpdate system_updates.SystemUpdate
+
+ loadBalancer, err := resourceMLBLoadBalancerActionV1ShowLoadBalancer(d, client)
+ if err != nil {
+ return false, err
+ }
+
+ systemUpdateID := d.Get("system_update").(map[string]interface{})["system_update_id"].(string)
+ err = system_updates.Show(client, systemUpdateID).ExtractInto(&systemUpdate)
+ if err != nil {
+ return false, fmt.Errorf("Unable to retrieve ECL managed load balancer system update (%s): %s", systemUpdateID, err)
+ }
+
+ if loadBalancer.Revision == systemUpdate.NextRevision {
+ log.Printf("[DEBUG] next_revision (%d) of system update (%s) matches with revision (%d) of load balancer (%s)", systemUpdate.NextRevision, systemUpdate.ID, loadBalancer.Revision, loadBalancer.ID)
+ return false, nil
+ } else if loadBalancer.Revision != systemUpdate.CurrentRevision {
+ return false, fmt.Errorf("current_revision (%d) of system update (%s) does not match with revision (%d) of load balancer (%s)", systemUpdate.CurrentRevision, systemUpdate.ID, loadBalancer.Revision, loadBalancer.ID)
+ }
+
+ return true, nil
+}
+
+func resourceMLBLoadBalancerActionV1Perform(d *schema.ResourceData, meta interface{}) error {
+ var isApplyConfigurationsRequired, isSystemUpdateRequired bool
+
+ loadBalancerID := d.Get("load_balancer_id").(string)
+
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ actionOpts := load_balancers.ActionOpts{}
+ if d.Get("apply_configurations").(bool) {
+ isApplyConfigurationsRequired, err = resourceMLBLoadBalancerActionV1CheckApplyConfigurationsRequired(d, managedLoadBalancerClient)
+ if err != nil {
+ return err
+ }
+ if isApplyConfigurationsRequired {
+ actionOpts.ApplyConfigurations = true
+ }
+ }
+ if len(d.Get("system_update").(map[string]interface{})) != 0 {
+ isSystemUpdateRequired, err = resourceMLBLoadBalancerActionV1CheckSystemUpdateRequired(d, managedLoadBalancerClient)
+ if err != nil {
+ return err
+ }
+ if isSystemUpdateRequired {
+ systemUpdate := load_balancers.ActionOptsSystemUpdate{
+ SystemUpdateID: d.Get("system_update").(map[string]interface{})["system_update_id"].(string),
+ }
+ actionOpts.SystemUpdate = &systemUpdate
+ }
+ }
+
+ if isApplyConfigurationsRequired || isSystemUpdateRequired {
+ log.Printf("[DEBUG] Performing action on ECL managed load balancer load balancer (%s) with options %+v", loadBalancerID, actionOpts)
+
+ err = load_balancers.Action(managedLoadBalancerClient, loadBalancerID, actionOpts).ExtractErr()
+ if err != nil {
+ return fmt.Errorf("Error performing action on ECL managed load balancer load balancer (%s) with options %+v: %s", loadBalancerID, actionOpts, err)
+ }
+
+ stateChangeConf := &resource.StateChangeConf{
+ Pending: []string{"PROCESSING"},
+ Target: []string{"COMPLETE"},
+ Refresh: resourceMLBLoadBalancerActionV1WaitForComplete(managedLoadBalancerClient, loadBalancerID),
+ Timeout: d.Timeout(schema.TimeoutCreate),
+ Delay: 5 * time.Second,
+ PollInterval: 30 * time.Second,
+ MinTimeout: 10 * time.Second,
+ }
+
+ _, err = stateChangeConf.WaitForState()
+ if err != nil {
+ return fmt.Errorf("Error waiting for ECL managed load balancer load balancer (%s) to become COMPLETE: %s", loadBalancerID, err)
+ }
+ } else {
+ log.Printf("[DEBUG] No action required on ECL managed load balancer load balancer (%s)", loadBalancerID)
+ }
+
+ d.SetId(loadBalancerID)
+
+ return resourceMLBLoadBalancerActionV1Read(d, meta)
+}
+
+func resourceMLBLoadBalancerActionV1WaitForComplete(client *eclcloud.ServiceClient, loadBalancerID string) resource.StateRefreshFunc {
+ return func() (interface{}, string, error) {
+ loadBalancer, err := load_balancers.Show(client, loadBalancerID, load_balancers.ShowOpts{}).Extract()
+ if err != nil {
+ return nil, "", err
+ }
+
+ return loadBalancer, loadBalancer.OperationStatus, nil
+ }
+}
+
+func resourceMLBLoadBalancerActionV1ShowLoadBalancer(d *schema.ResourceData, client *eclcloud.ServiceClient) (*load_balancers.LoadBalancer, error) {
+ var loadBalancer load_balancers.LoadBalancer
+
+ loadBalancerID := d.Get("load_balancer_id").(string)
+ err := load_balancers.Show(client, loadBalancerID, load_balancers.ShowOpts{}).ExtractInto(&loadBalancer)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer load balancer (%s): %s", loadBalancerID, err)
+ }
+
+ return &loadBalancer, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListHealthMonitors(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]health_monitors.HealthMonitor, error) {
+ listOpts := health_monitors.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := health_monitors.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ healthMonitors, err := health_monitors.ExtractHealthMonitors(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer health monitors with options %+v: %s", listOpts, err)
+ }
+
+ return &healthMonitors, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListListeners(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]listeners.Listener, error) {
+ listOpts := listeners.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := listeners.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ listeners, err := listeners.ExtractListeners(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer listeners with options %+v: %s", listOpts, err)
+ }
+
+ return &listeners, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListPolicies(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]policies.Policy, error) {
+ listOpts := policies.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := policies.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ policies, err := policies.ExtractPolicies(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer policies with options %+v: %s", listOpts, err)
+ }
+
+ return &policies, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListRoutes(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]routes.Route, error) {
+ listOpts := routes.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := routes.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ routes, err := routes.ExtractRoutes(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer routes with options %+v: %s", listOpts, err)
+ }
+
+ return &routes, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListRules(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]rules.Rule, error) {
+ listOpts := rules.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := rules.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ rules, err := rules.ExtractRules(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer rules with options %+v: %s", listOpts, err)
+ }
+
+ return &rules, nil
+}
+
+func resourceMLBLoadBalancerActionV1ListTargetGroups(d *schema.ResourceData, client *eclcloud.ServiceClient) (*[]target_groups.TargetGroup, error) {
+ listOpts := target_groups.ListOpts{LoadBalancerID: d.Get("load_balancer_id").(string)}
+ pages, err := target_groups.List(client, listOpts).AllPages()
+ if err != nil {
+ return nil, err
+ }
+
+ targetGroups, err := target_groups.ExtractTargetGroups(pages)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer target groups with options %+v: %s", listOpts, err)
+ }
+
+ return &targetGroups, nil
+}
+
+func resourceMLBLoadBalancerActionV1Read(d *schema.ResourceData, meta interface{}) error {
+ return nil
+}
+
+func resourceMLBLoadBalancerActionV1Delete(d *schema.ResourceData, meta interface{}) error {
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_load_balancer_action_v1_mock_test.go b/ecl/resource_ecl_mlb_load_balancer_action_v1_mock_test.go
new file mode 100644
index 00000000..d6b0c790
--- /dev/null
+++ b/ecl/resource_ecl_mlb_load_balancer_action_v1_mock_test.go
@@ -0,0 +1,511 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1LoadBalancerActionResource_ApplyConfigurations(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeActionCreateStaged)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08/action", testMockMLBV1LoadBalancersActionApplyConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionProcessing)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionCompleted)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancerActionApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "load_balancer_id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "apply_configurations", "true"),
+ resource.TestCheckNoResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "system_update"),
+ ),
+ },
+ },
+ })
+}
+
+func TestMockedAccMLBV1LoadBalancerActionResource_SystemUpdate(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeActionCreateStaged)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08/action", testMockMLBV1LoadBalancersActionSystemUpdate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionProcessing)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionCompleted)
+ mc.Register(t, "system_updates", "/v1.0/system_updates/31746df7-92f9-4b5e-ad05-59f6684a54eb", testMockMLBV1SystemUpdatesShow)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancerActionSystemUpdate,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "load_balancer_id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "system_update.system_update_id", "31746df7-92f9-4b5e-ad05-59f6684a54eb"),
+ resource.TestCheckNoResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "apply_configurations"),
+ ),
+ },
+ },
+ })
+}
+
+func TestMockedAccMLBV1LoadBalancerActionResource_ApplyConfigurationsAndSystemUpdate(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeActionCreateStaged)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08/action", testMockMLBV1LoadBalancersActionApplyConfigurationsAndSystemUpdate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionProcessing)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterActionCompleted)
+ mc.Register(t, "system_updates", "/v1.0/system_updates/31746df7-92f9-4b5e-ad05-59f6684a54eb", testMockMLBV1SystemUpdatesShow)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancerActionApplyConfigurationsAndSystemUpdate,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "load_balancer_id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "apply_configurations", "true"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "system_update.system_update_id", "31746df7-92f9-4b5e-ad05-59f6684a54eb"),
+ ),
+ },
+ },
+ })
+}
+
+func TestMockedAccMLBV1LoadBalancerActionResource_NoApplyConfigurations(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeActionActive)
+ mc.Register(t, "health_monitors", "/v1.0/health_monitors", testMockMLBV1HealthMonitorsListEmpty)
+ mc.Register(t, "listeners", "/v1.0/listeners", testMockMLBV1ListenersListEmpty)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesListEmpty)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesListEmpty)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesListEmpty)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsListEmpty)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancerActionApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "load_balancer_id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "apply_configurations", "true"),
+ resource.TestCheckNoResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "system_update"),
+ ),
+ },
+ },
+ })
+}
+
+func TestMockedAccMLBV1LoadBalancerActionResource_NoSystemUpdate(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeActionActive)
+ mc.Register(t, "system_updates", "/v1.0/system_updates/31746df7-92f9-4b5e-ad05-59f6684a54eb", testMockMLBV1SystemUpdatesShow)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancerActionSystemUpdate,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "load_balancer_id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "system_update.system_update_id", "31746df7-92f9-4b5e-ad05-59f6684a54eb"),
+ resource.TestCheckNoResourceAttr("ecl_mlb_load_balancer_action_v1.load_balancer_action", "apply_configurations"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1LoadBalancerActionApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+ load_balancer_id = "497f6eca-6276-4993-bfeb-53cbbbba6f08"
+ apply_configurations = true
+}
+`)
+
+var testAccMLBV1LoadBalancerActionSystemUpdate = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+ load_balancer_id = "497f6eca-6276-4993-bfeb-53cbbbba6f08"
+ system_update = {
+ system_update_id = "31746df7-92f9-4b5e-ad05-59f6684a54eb"
+ }
+}
+`)
+
+var testAccMLBV1LoadBalancerActionApplyConfigurationsAndSystemUpdate = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+ load_balancer_id = "497f6eca-6276-4993-bfeb-53cbbbba6f08"
+ apply_configurations = true
+ system_update = {
+ system_update_id = "31746df7-92f9-4b5e-ad05-59f6684a54eb"
+ }
+}
+`)
+
+var testMockMLBV1LoadBalancersShowBeforeActionCreateStaged = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null
+ }
+ }
+expectedStatus:
+ - ~
+`)
+
+var testMockMLBV1LoadBalancersShowBeforeActionActive = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 2,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - ~
+`)
+
+var testMockMLBV1LoadBalancersShowAfterActionProcessing = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "PROCESSING",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null
+ }
+ }
+expectedStatus:
+ - Performed
+counter:
+ max: 3
+`)
+
+var testMockMLBV1LoadBalancersShowAfterActionCompleted = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 2,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - Performed
+counter:
+ min: 4
+`)
+
+var testMockMLBV1LoadBalancersActionApplyConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"apply-configurations":null}
+response:
+ code: 204
+newStatus: Performed
+`)
+
+var testMockMLBV1LoadBalancersActionSystemUpdate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"system-update":{"system_update_id":"31746df7-92f9-4b5e-ad05-59f6684a54eb"}}
+response:
+ code: 204
+newStatus: Performed
+`)
+
+var testMockMLBV1LoadBalancersActionApplyConfigurationsAndSystemUpdate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"apply-configurations":null,"system-update":{"system_update_id":"31746df7-92f9-4b5e-ad05-59f6684a54eb"}}
+response:
+ code: 204
+newStatus: Performed
+`)
+
+var testMockMLBV1SystemUpdatesShow = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "system_update": {
+ "id": "31746df7-92f9-4b5e-ad05-59f6684a54eb",
+ "name": "security_update_202210",
+ "description": "description",
+ "href": "https://sdpf.ntt.com/news/2022100301/",
+ "publish_datetime": "2022-10-03 00:00:00",
+ "limit_datetime": "2022-10-11 12:59:59",
+ "current_revision": 1,
+ "next_revision": 2,
+ "applicable": true
+ }
+ }
+`)
+
+var testMockMLBV1HealthMonitorsListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "health_monitors": []
+ }
+`)
+
+var testMockMLBV1ListenersListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "listeners": []
+ }
+`)
+
+var testMockMLBV1PoliciesListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "policies": []
+ }
+`)
+
+var testMockMLBV1RoutesListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "routes": []
+ }
+`)
+
+var testMockMLBV1RulesListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "rules": []
+ }
+`)
+
+var testMockMLBV1TargetGroupsListEmpty = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ load_balancer_id:
+ - 497f6eca-6276-4993-bfeb-53cbbbba6f08
+response:
+ code: 200
+ body: >
+ {
+ "target_groups": []
+ }
+`)
diff --git a/ecl/resource_ecl_mlb_load_balancer_v1.go b/ecl/resource_ecl_mlb_load_balancer_v1.go
new file mode 100644
index 00000000..bb06a507
--- /dev/null
+++ b/ecl/resource_ecl_mlb_load_balancer_v1.go
@@ -0,0 +1,522 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+ "time"
+
+ "github.com/hashicorp/terraform/helper/resource"
+ "github.com/hashicorp/terraform/helper/schema"
+
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers"
+)
+
+func reservedFixedIPsSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeList,
+ Required: true,
+ MinItems: 4,
+ MaxItems: 4,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ },
+ },
+ }
+}
+
+func interfacesSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeList,
+ Required: true,
+ MinItems: 1,
+ MaxItems: 7,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "network_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "virtual_ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "reserved_fixed_ips": reservedFixedIPsSchemaForResource(),
+ },
+ },
+ }
+}
+
+func syslogServersSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeList,
+ Optional: true,
+ MaxItems: 2,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "port": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "protocol": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ },
+ },
+ }
+}
+
+func resourceMLBLoadBalancerV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBLoadBalancerV1Create,
+ Read: resourceMLBLoadBalancerV1Read,
+ Update: resourceMLBLoadBalancerV1Update,
+ Delete: resourceMLBLoadBalancerV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Timeouts: &schema.ResourceTimeout{
+ Delete: schema.DefaultTimeout(1 * time.Hour),
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "plan_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ ForceNew: true,
+ },
+ "syslog_servers": syslogServersSchemaForResource(),
+ "interfaces": interfacesSchemaForResource(),
+ },
+ }
+
+ return result
+}
+
+func resourceMLBLoadBalancerV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := load_balancers.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ PlanID: d.Get("plan_id").(string),
+ }
+
+ syslogServers := make([]load_balancers.CreateOptsSyslogServer, len(d.Get("syslog_servers").([]interface{})))
+ for i, syslogServer := range d.Get("syslog_servers").([]interface{}) {
+ syslogServers[i] = load_balancers.CreateOptsSyslogServer{
+ IPAddress: syslogServer.(map[string]interface{})["ip_address"].(string),
+ Port: syslogServer.(map[string]interface{})["port"].(int),
+ Protocol: syslogServer.(map[string]interface{})["protocol"].(string),
+ }
+ }
+ createOpts.SyslogServers = &syslogServers
+
+ interfaces := make([]load_balancers.CreateOptsInterface, len(d.Get("interfaces").([]interface{})))
+ for i, interfaceV := range d.Get("interfaces").([]interface{}) {
+ reservedFixedIPs := make([]load_balancers.CreateOptsReservedFixedIP, len(interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{})))
+ for j, reservedFixedIP := range interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{}) {
+ reservedFixedIPs[j] = load_balancers.CreateOptsReservedFixedIP{
+ IPAddress: reservedFixedIP.(map[string]interface{})["ip_address"].(string),
+ }
+ }
+
+ interfaces[i] = load_balancers.CreateOptsInterface{
+ NetworkID: interfaceV.(map[string]interface{})["network_id"].(string),
+ VirtualIPAddress: interfaceV.(map[string]interface{})["virtual_ip_address"].(string),
+ ReservedFixedIPs: &reservedFixedIPs,
+ }
+ }
+ createOpts.Interfaces = &interfaces
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer load balancer with options %+v", createOpts)
+
+ loadBalancer, err := load_balancers.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer load balancer with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(loadBalancer.ID)
+ log.Printf("[INFO] ECL managed load balancer load balancer ID: %s", loadBalancer.ID)
+
+ return resourceMLBLoadBalancerV1Read(d, meta)
+}
+
+func resourceMLBLoadBalancerV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*load_balancers.LoadBalancer, error) {
+ var loadBalancer load_balancers.LoadBalancer
+
+ showOpts := load_balancers.ShowOpts{Changes: changes}
+ err := load_balancers.Show(client, d.Id(), showOpts).ExtractInto(&loadBalancer)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer load balancer (%s): %s", d.Id(), err)
+ }
+
+ return &loadBalancer, nil
+}
+
+func resourceMLBLoadBalancerV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ loadBalancer, err := resourceMLBLoadBalancerV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "load_balancer")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer load balancer (%s): %+v", d.Id(), loadBalancer)
+
+ if loadBalancer.ConfigurationStatus == "ACTIVE" || (loadBalancer.ConfigurationStatus == "UPDATE_STAGED" && loadBalancer.Staged.SyslogServers == nil) {
+ syslogServers := make([]interface{}, len(loadBalancer.SyslogServers))
+ for i, syslogServer := range loadBalancer.SyslogServers {
+ syslogServers[i] = map[string]interface{}{
+ "ip_address": syslogServer.IPAddress,
+ "port": syslogServer.Port,
+ "protocol": syslogServer.Protocol,
+ }
+ }
+
+ d.Set("syslog_servers", syslogServers)
+ } else if loadBalancer.ConfigurationStatus == "CREATE_STAGED" || (loadBalancer.ConfigurationStatus == "UPDATE_STAGED" && loadBalancer.Staged.SyslogServers != nil) {
+ syslogServers := make([]interface{}, len(loadBalancer.Staged.SyslogServers))
+ for i, syslogServer := range loadBalancer.Staged.SyslogServers {
+ syslogServers[i] = map[string]interface{}{
+ "ip_address": syslogServer.IPAddress,
+ "port": syslogServer.Port,
+ "protocol": syslogServer.Protocol,
+ }
+ }
+
+ d.Set("syslog_servers", syslogServers)
+ }
+
+ if loadBalancer.ConfigurationStatus == "ACTIVE" || (loadBalancer.ConfigurationStatus == "UPDATE_STAGED" && loadBalancer.Staged.Interfaces == nil) {
+ reservedFixedIPs := make([]interface{}, len(loadBalancer.Interfaces))
+ for i, interfaceV := range loadBalancer.Interfaces {
+ results := make([]interface{}, len(interfaceV.ReservedFixedIPs))
+ for j, reservedFixedIP := range interfaceV.ReservedFixedIPs {
+ results[j] = map[string]interface{}{
+ "ip_address": reservedFixedIP.IPAddress,
+ }
+ }
+ reservedFixedIPs[i] = results
+ }
+
+ interfaces := make([]interface{}, len(loadBalancer.Interfaces))
+ for i, interfaceV := range loadBalancer.Interfaces {
+ interfaces[i] = map[string]interface{}{
+ "network_id": interfaceV.NetworkID,
+ "virtual_ip_address": interfaceV.VirtualIPAddress,
+ "reserved_fixed_ips": reservedFixedIPs[i],
+ }
+ }
+
+ d.Set("interfaces", interfaces)
+ } else if loadBalancer.ConfigurationStatus == "CREATE_STAGED" || (loadBalancer.ConfigurationStatus == "UPDATE_STAGED" && loadBalancer.Staged.Interfaces != nil) {
+ reservedFixedIPs := make([]interface{}, len(loadBalancer.Staged.Interfaces))
+ for i, interfaceV := range loadBalancer.Staged.Interfaces {
+ results := make([]interface{}, len(interfaceV.ReservedFixedIPs))
+ for j, reservedFixedIP := range interfaceV.ReservedFixedIPs {
+ results[j] = map[string]interface{}{
+ "ip_address": reservedFixedIP.IPAddress,
+ }
+ }
+ reservedFixedIPs[i] = results
+ }
+
+ interfaces := make([]interface{}, len(loadBalancer.Staged.Interfaces))
+ for i, interfaceV := range loadBalancer.Staged.Interfaces {
+ interfaces[i] = map[string]interface{}{
+ "network_id": interfaceV.NetworkID,
+ "virtual_ip_address": interfaceV.VirtualIPAddress,
+ "reserved_fixed_ips": reservedFixedIPs[i],
+ }
+ }
+
+ d.Set("interfaces", interfaces)
+ }
+
+ d.Set("name", loadBalancer.Name)
+ d.Set("description", loadBalancer.Description)
+ d.Set("tags", loadBalancer.Tags)
+ d.Set("plan_id", loadBalancer.PlanID)
+ d.Set("tenant_id", loadBalancer.TenantID)
+
+ return nil
+}
+
+func resourceMLBLoadBalancerV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer load balancer ...")
+
+ err = resourceMLBLoadBalancerV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer load balancer: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer load balancer ...")
+
+ err = resourceMLBLoadBalancerV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer load balancer: %s", err)
+ }
+
+ return resourceMLBLoadBalancerV1Read(d, meta)
+}
+
+func resourceMLBLoadBalancerV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts load_balancers.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer load balancer attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := load_balancers.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer load balancer attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBLoadBalancerV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ loadBalancer, err := resourceMLBLoadBalancerV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if loadBalancer.ConfigurationStatus == "ACTIVE" {
+ syslogServers := make([]load_balancers.CreateStagedOptsSyslogServer, len(d.Get("syslog_servers").([]interface{})))
+ reservedFixedIPs := make([][]load_balancers.CreateStagedOptsReservedFixedIP, len(d.Get("interfaces").([]interface{})))
+ interfaces := make([]load_balancers.CreateStagedOptsInterface, len(d.Get("interfaces").([]interface{})))
+
+ if d.HasChange("syslog_servers") {
+ isConfigurationsUpdated = true
+
+ for i, syslogServer := range d.Get("syslog_servers").([]interface{}) {
+ syslogServers[i] = load_balancers.CreateStagedOptsSyslogServer{
+ IPAddress: syslogServer.(map[string]interface{})["ip_address"].(string),
+ Port: syslogServer.(map[string]interface{})["port"].(int),
+ Protocol: syslogServer.(map[string]interface{})["protocol"].(string),
+ }
+ }
+ }
+
+ if d.HasChange("interfaces") {
+ isConfigurationsUpdated = true
+
+ for i, interfaceV := range d.Get("interfaces").([]interface{}) {
+ results := make([]load_balancers.CreateStagedOptsReservedFixedIP, len(interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{})))
+ for j, reservedFixedIP := range interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{}) {
+ results[j] = load_balancers.CreateStagedOptsReservedFixedIP{
+ IPAddress: reservedFixedIP.(map[string]interface{})["ip_address"].(string),
+ }
+ }
+ reservedFixedIPs[i] = results
+ }
+
+ for i, interfaceV := range d.Get("interfaces").([]interface{}) {
+ interfaces[i] = load_balancers.CreateStagedOptsInterface{
+ NetworkID: interfaceV.(map[string]interface{})["network_id"].(string),
+ VirtualIPAddress: interfaceV.(map[string]interface{})["virtual_ip_address"].(string),
+ ReservedFixedIPs: &reservedFixedIPs[i],
+ }
+ }
+ }
+
+ if isConfigurationsUpdated {
+ createStagedOpts := load_balancers.CreateStagedOpts{
+ SyslogServers: &syslogServers,
+ Interfaces: &interfaces,
+ }
+
+ log.Printf("[DEBUG] Updating ECL managed load balancer load balancer configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := load_balancers.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer load balancer configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ syslogServers := make([]load_balancers.UpdateStagedOptsSyslogServer, len(d.Get("syslog_servers").([]interface{})))
+ reservedFixedIPs := make([][]load_balancers.UpdateStagedOptsReservedFixedIP, len(d.Get("interfaces").([]interface{})))
+ interfaces := make([]load_balancers.UpdateStagedOptsInterface, len(d.Get("interfaces").([]interface{})))
+
+ if d.HasChange("syslog_servers") {
+ isConfigurationsUpdated = true
+
+ for i, syslogServer := range d.Get("syslog_servers").([]interface{}) {
+ result := load_balancers.UpdateStagedOptsSyslogServer{}
+ ipAddress := syslogServer.(map[string]interface{})["ip_address"].(string)
+ port := syslogServer.(map[string]interface{})["port"].(int)
+ protocol := syslogServer.(map[string]interface{})["protocol"].(string)
+ result.IPAddress = &ipAddress
+ result.Port = &port
+ result.Protocol = &protocol
+ syslogServers[i] = result
+ }
+ }
+
+ if d.HasChange("interfaces") {
+ isConfigurationsUpdated = true
+
+ for i, interfaceV := range d.Get("interfaces").([]interface{}) {
+ results := make([]load_balancers.UpdateStagedOptsReservedFixedIP, len(interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{})))
+ for j, reservedFixedIP := range interfaceV.(map[string]interface{})["reserved_fixed_ips"].([]interface{}) {
+ ipAddress := reservedFixedIP.(map[string]interface{})["ip_address"].(string)
+ results[j] = load_balancers.UpdateStagedOptsReservedFixedIP{
+ IPAddress: &ipAddress,
+ }
+ }
+ reservedFixedIPs[i] = results
+ }
+
+ for i, interfaceV := range d.Get("interfaces").([]interface{}) {
+ networkID := interfaceV.(map[string]interface{})["network_id"].(string)
+ virtualIPAddress := interfaceV.(map[string]interface{})["virtual_ip_address"].(string)
+ interfaces[i] = load_balancers.UpdateStagedOptsInterface{
+ NetworkID: &networkID,
+ VirtualIPAddress: &virtualIPAddress,
+ ReservedFixedIPs: &reservedFixedIPs[i],
+ }
+ }
+ }
+
+ if isConfigurationsUpdated {
+ updateStagedOpts := load_balancers.UpdateStagedOpts{
+ SyslogServers: &syslogServers,
+ Interfaces: &interfaces,
+ }
+
+ log.Printf("[DEBUG] Updating ECL managed load balancer load balancer configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := load_balancers.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer load balancer configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBLoadBalancerV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer load balancer: %s", d.Id())
+
+ err = load_balancers.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer load balancer (%s)", d.Id())
+ return nil
+ }
+
+ loadBalancer, err := resourceMLBLoadBalancerV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if loadBalancer.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer load balancer (%s)", d.Id())
+ return nil
+ }
+ return fmt.Errorf("Error deleting ECL managed load balancer load balancer: %s", err)
+ }
+
+ stateChangeConf := &resource.StateChangeConf{
+ Pending: []string{"PROCESSING"},
+ Target: []string{"DELETED"},
+ Refresh: resourceMLBLoadBalancerV1WaitForDeleted(managedLoadBalancerClient, d.Id()),
+ Timeout: d.Timeout(schema.TimeoutDelete),
+ Delay: 5 * time.Second,
+ PollInterval: 30 * time.Second,
+ MinTimeout: 10 * time.Second,
+ }
+
+ _, err = stateChangeConf.WaitForState()
+ if err != nil {
+ return fmt.Errorf("Error waiting for ECL managed load balancer load balancer (%s) to be deleted: %s", d.Id(), err)
+ }
+
+ return nil
+}
+
+func resourceMLBLoadBalancerV1WaitForDeleted(client *eclcloud.ServiceClient, loadBalancerID string) resource.StateRefreshFunc {
+ return func() (interface{}, string, error) {
+ loadBalancer, err := load_balancers.Show(client, loadBalancerID, load_balancers.ShowOpts{}).Extract()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Successfully deleted ECL managed load balancer load balancer (%s)", loadBalancerID)
+ return loadBalancer, "DELETED", nil
+ }
+ return nil, "", err
+ }
+
+ return loadBalancer, loadBalancer.OperationStatus, nil
+ }
+}
diff --git a/ecl/resource_ecl_mlb_load_balancer_v1_mock_test.go b/ecl/resource_ecl_mlb_load_balancer_v1_mock_test.go
new file mode 100644
index 00000000..ae1dac6d
--- /dev/null
+++ b/ecl/resource_ecl_mlb_load_balancer_v1_mock_test.go
@@ -0,0 +1,1077 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1LoadBalancerResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers", testMockMLBV1LoadBalancersCreate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterCreate)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersUpdateAttributes)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeUpdateConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1LoadBalancersUpdateConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterApplyConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowBeforeCreateConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1LoadBalancersCreateConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterCreateConfigurations)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersDelete)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterDeleteProcessing)
+ mc.Register(t, "load_balancers", "/v1.0/load_balancers/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1LoadBalancersShowAfterDeleteCompleted)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1LoadBalancer,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "name", "load_balancer"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "name", "load_balancer-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.ip_address", "192.168.0.6"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.1.ip_address", "192.168.1.6"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.1.port", "514"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.1.protocol", "udp"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.network_id", "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.virtual_ip_address", "192.168.0.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.0.2"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.0.3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.0.4"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.0.5"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.network_id", "58e6d72b-f5e7-4b83-b306-06989ff78a84"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.virtual_ip_address", "192.168.1.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.reserved_fixed_ips.0.ip_address", "192.168.1.2"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.reserved_fixed_ips.1.ip_address", "192.168.1.3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.reserved_fixed_ips.2.ip_address", "192.168.1.4"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.1.reserved_fixed_ips.3.ip_address", "192.168.1.5"),
+ ),
+ },
+ {
+ Config: testAccMLBV1LoadBalancerUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "name", "load_balancer-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "plan_id", "00713021-9aea-41da-9a88-87760c08fa72"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.ip_address", "192.168.1.6"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.port", "514"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "syslog_servers.0.protocol", "udp"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.network_id", "58e6d72b-f5e7-4b83-b306-06989ff78a84"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.virtual_ip_address", "192.168.1.1"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.0.ip_address", "192.168.1.2"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.1.ip_address", "192.168.1.3"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.2.ip_address", "192.168.1.4"),
+ resource.TestCheckResourceAttr("ecl_mlb_load_balancer_v1.load_balancer", "interfaces.0.reserved_fixed_ips.3.ip_address", "192.168.1.5"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1LoadBalancer = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ plan_id = "00713021-9aea-41da-9a88-87760c08fa72"
+ syslog_servers {
+ ip_address = "192.168.0.6"
+ port = 514
+ protocol = "udp"
+ }
+ interfaces {
+ network_id = "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"
+ virtual_ip_address = "192.168.0.1"
+ reserved_fixed_ips {
+ ip_address = "192.168.0.2"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.3"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.4"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.5"
+ }
+ }
+}
+`)
+
+var testAccMLBV1LoadBalancerUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ plan_id = "00713021-9aea-41da-9a88-87760c08fa72"
+ syslog_servers {
+ ip_address = "192.168.0.6"
+ port = 514
+ protocol = "udp"
+ }
+ syslog_servers {
+ ip_address = "192.168.1.6"
+ port = 514
+ protocol = "udp"
+ }
+ interfaces {
+ network_id = "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3"
+ virtual_ip_address = "192.168.0.1"
+ reserved_fixed_ips {
+ ip_address = "192.168.0.2"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.3"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.4"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.0.5"
+ }
+ }
+ interfaces {
+ network_id = "58e6d72b-f5e7-4b83-b306-06989ff78a84"
+ virtual_ip_address = "192.168.1.1"
+ reserved_fixed_ips {
+ ip_address = "192.168.1.2"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.3"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.4"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.5"
+ }
+ }
+}
+`)
+
+var testAccMLBV1LoadBalancerUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ plan_id = "00713021-9aea-41da-9a88-87760c08fa72"
+ syslog_servers {
+ ip_address = "192.168.1.6"
+ port = 514
+ protocol = "udp"
+ }
+ interfaces {
+ network_id = "58e6d72b-f5e7-4b83-b306-06989ff78a84"
+ virtual_ip_address = "192.168.1.1"
+ reserved_fixed_ips {
+ ip_address = "192.168.1.2"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.3"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.4"
+ }
+ reserved_fixed_ips {
+ ip_address = "192.168.1.5"
+ }
+ }
+}
+`)
+
+var testMockMLBV1LoadBalancersCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"load_balancer":{"description":"description","interfaces":[{"network_id":"d6797cf4-42b9-4cad-8591-9dd91c3f0fc3","reserved_fixed_ips":[{"ip_address":"192.168.0.2"},{"ip_address":"192.168.0.3"},{"ip_address":"192.168.0.4"},{"ip_address":"192.168.0.5"}],"virtual_ip_address":"192.168.0.1"}],"name":"load_balancer","plan_id":"00713021-9aea-41da-9a88-87760c08fa72","syslog_servers":[{"ip_address":"192.168.0.6","port":514,"protocol":"udp"}],"tags":{"key":"value"}}}
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1LoadBalancersShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null,
+ "current": null,
+ "staged": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1LoadBalancersShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1LoadBalancersShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null,
+ "current": null,
+ "staged": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1LoadBalancersShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ],
+ "current": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1LoadBalancersShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1LoadBalancersShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ],
+ "current": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ },
+ "staged": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1LoadBalancersShowAfterDeleteProcessing = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "monitoring_status": "ACTIVE",
+ "operation_status": "PROCESSING",
+ "primary_availability_zone": "zone1_groupa",
+ "secondary_availability_zone": "zone1_groupb",
+ "active_availability_zone": "zone1_groupa",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - Deleted
+counter:
+ max: 3
+`)
+
+var testMockMLBV1LoadBalancersShowAfterDeleteCompleted = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 404
+expectedStatus:
+ - Deleted
+counter:
+ min: 4
+`)
+
+var testMockMLBV1LoadBalancersUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"load_balancer":{"description":"description-update","name":"load_balancer-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "load_balancer-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "monitoring_status": "INITIAL",
+ "operation_status": "NONE",
+ "primary_availability_zone": null,
+ "secondary_availability_zone": null,
+ "active_availability_zone": "UNDEFINED",
+ "revision": 1,
+ "plan_id": "00713021-9aea-41da-9a88-87760c08fa72",
+ "plan_name": "50M_HA_4IF",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "syslog_servers": null,
+ "interfaces": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1LoadBalancersCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"load_balancer":{"interfaces":[{"network_id":"58e6d72b-f5e7-4b83-b306-06989ff78a84","reserved_fixed_ips":[{"ip_address":"192.168.1.2"},{"ip_address":"192.168.1.3"},{"ip_address":"192.168.1.4"},{"ip_address":"192.168.1.5"}],"virtual_ip_address":"192.168.1.1"}],"syslog_servers":[{"ip_address":"192.168.1.6","port":514,"protocol":"udp"}]}}
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1LoadBalancersUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"load_balancer":{"interfaces":[{"network_id":"d6797cf4-42b9-4cad-8591-9dd91c3f0fc3","reserved_fixed_ips":[{"ip_address":"192.168.0.2"},{"ip_address":"192.168.0.3"},{"ip_address":"192.168.0.4"},{"ip_address":"192.168.0.5"}],"virtual_ip_address":"192.168.0.1"},{"network_id":"58e6d72b-f5e7-4b83-b306-06989ff78a84","reserved_fixed_ips":[{"ip_address":"192.168.1.2"},{"ip_address":"192.168.1.3"},{"ip_address":"192.168.1.4"},{"ip_address":"192.168.1.5"}],"virtual_ip_address":"192.168.1.1"}],"syslog_servers":[{"ip_address":"192.168.0.6","port":514,"protocol":"udp"},{"ip_address":"192.168.1.6","port":514,"protocol":"udp"}]}}
+response:
+ code: 200
+ body: >
+ {
+ "load_balancer": {
+ "syslog_servers": [
+ {
+ "ip_address": "192.168.0.6",
+ "port": 514,
+ "protocol": "udp"
+ },
+ {
+ "ip_address": "192.168.1.6",
+ "port": 514,
+ "protocol": "udp"
+ }
+ ],
+ "interfaces": [
+ {
+ "network_id": "d6797cf4-42b9-4cad-8591-9dd91c3f0fc3",
+ "virtual_ip_address": "192.168.0.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.0.2"
+ },
+ {
+ "ip_address": "192.168.0.3"
+ },
+ {
+ "ip_address": "192.168.0.4"
+ },
+ {
+ "ip_address": "192.168.0.5"
+ }
+ ]
+ },
+ {
+ "network_id": "58e6d72b-f5e7-4b83-b306-06989ff78a84",
+ "virtual_ip_address": "192.168.1.1",
+ "reserved_fixed_ips": [
+ {
+ "ip_address": "192.168.1.2"
+ },
+ {
+ "ip_address": "192.168.1.3"
+ },
+ {
+ "ip_address": "192.168.1.4"
+ },
+ {
+ "ip_address": "192.168.1.5"
+ }
+ ]
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1LoadBalancersDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_policy_v1.go b/ecl/resource_ecl_mlb_policy_v1.go
new file mode 100644
index 00000000..a97c2859
--- /dev/null
+++ b/ecl/resource_ecl_mlb_policy_v1.go
@@ -0,0 +1,432 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies"
+)
+
+func resourceMLBPolicyV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBPolicyV1Create,
+ Read: resourceMLBPolicyV1Read,
+ Update: resourceMLBPolicyV1Update,
+ Delete: resourceMLBPolicyV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "algorithm": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "persistence": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "idle_timeout": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "sorry_page_url": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "source_nat": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "certificate_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "health_monitor_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "listener_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "default_target_group_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "tls_policy_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ },
+ }
+
+ return result
+}
+
+func resourceMLBPolicyV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := policies.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ Algorithm: d.Get("algorithm").(string),
+ Persistence: d.Get("persistence").(string),
+ IdleTimeout: d.Get("idle_timeout").(int),
+ SorryPageUrl: d.Get("sorry_page_url").(string),
+ SourceNat: d.Get("source_nat").(string),
+ CertificateID: d.Get("certificate_id").(string),
+ HealthMonitorID: d.Get("health_monitor_id").(string),
+ ListenerID: d.Get("listener_id").(string),
+ DefaultTargetGroupID: d.Get("default_target_group_id").(string),
+ TLSPolicyID: d.Get("tls_policy_id").(string),
+ LoadBalancerID: d.Get("load_balancer_id").(string),
+ }
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer policy with options %+v", createOpts)
+
+ policy, err := policies.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer policy with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(policy.ID)
+ log.Printf("[INFO] ECL managed load balancer policy ID: %s", policy.ID)
+
+ return resourceMLBPolicyV1Read(d, meta)
+}
+
+func resourceMLBPolicyV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*policies.Policy, error) {
+ var policy policies.Policy
+
+ showOpts := policies.ShowOpts{Changes: changes}
+ err := policies.Show(client, d.Id(), showOpts).ExtractInto(&policy)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer policy (%s): %s", d.Id(), err)
+ }
+
+ return &policy, nil
+}
+
+func resourceMLBPolicyV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ policy, err := resourceMLBPolicyV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "policy")
+ }
+
+ if policy.ConfigurationStatus == "ACTIVE" {
+ d.Set("algorithm", policy.Algorithm)
+ d.Set("persistence", policy.Persistence)
+ d.Set("idle_timeout", policy.IdleTimeout)
+ d.Set("sorry_page_url", policy.SorryPageUrl)
+ d.Set("source_nat", policy.SourceNat)
+ d.Set("certificate_id", policy.CertificateID)
+ d.Set("health_monitor_id", policy.HealthMonitorID)
+ d.Set("listener_id", policy.ListenerID)
+ d.Set("default_target_group_id", policy.DefaultTargetGroupID)
+ d.Set("tls_policy_id", policy.TLSPolicyID)
+ } else if policy.ConfigurationStatus == "CREATE_STAGED" {
+ d.Set("algorithm", policy.Staged.Algorithm)
+ d.Set("persistence", policy.Staged.Persistence)
+ d.Set("idle_timeout", policy.Staged.IdleTimeout)
+ d.Set("sorry_page_url", policy.Staged.SorryPageUrl)
+ d.Set("source_nat", policy.Staged.SourceNat)
+ d.Set("certificate_id", policy.Staged.CertificateID)
+ d.Set("health_monitor_id", policy.Staged.HealthMonitorID)
+ d.Set("listener_id", policy.Staged.ListenerID)
+ d.Set("default_target_group_id", policy.Staged.DefaultTargetGroupID)
+ d.Set("tls_policy_id", policy.Staged.TLSPolicyID)
+ } else if policy.ConfigurationStatus == "UPDATE_STAGED" {
+ d.Set("algorithm", ternary(policy.Staged.Algorithm == "", policy.Algorithm, policy.Staged.Algorithm))
+ d.Set("persistence", ternary(policy.Staged.Persistence == "", policy.Persistence, policy.Staged.Persistence))
+ d.Set("idle_timeout", ternary(policy.Staged.IdleTimeout == 0, policy.IdleTimeout, policy.Staged.IdleTimeout))
+ d.Set("sorry_page_url", ternary(policy.Staged.SorryPageUrl == "", policy.SorryPageUrl, policy.Staged.SorryPageUrl))
+ d.Set("source_nat", ternary(policy.Staged.SourceNat == "", policy.SourceNat, policy.Staged.SourceNat))
+ d.Set("certificate_id", ternary(policy.Staged.CertificateID == "", policy.CertificateID, policy.Staged.CertificateID))
+ d.Set("health_monitor_id", ternary(policy.Staged.HealthMonitorID == "", policy.HealthMonitorID, policy.Staged.HealthMonitorID))
+ d.Set("listener_id", ternary(policy.Staged.ListenerID == "", policy.ListenerID, policy.Staged.ListenerID))
+ d.Set("default_target_group_id", ternary(policy.Staged.DefaultTargetGroupID == "", policy.DefaultTargetGroupID, policy.Staged.DefaultTargetGroupID))
+ d.Set("tls_policy_id", ternary(policy.Staged.TLSPolicyID == "", policy.TLSPolicyID, policy.Staged.TLSPolicyID))
+ } else if policy.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", policy.Name)
+ d.Set("description", policy.Description)
+ d.Set("tags", policy.Tags)
+ d.Set("load_balancer_id", policy.LoadBalancerID)
+ d.Set("tenant_id", policy.TenantID)
+
+ return nil
+}
+
+func resourceMLBPolicyV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer policy ...")
+
+ err = resourceMLBPolicyV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer policy: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer policy ...")
+
+ err = resourceMLBPolicyV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer policy: %s", err)
+ }
+
+ return resourceMLBPolicyV1Read(d, meta)
+}
+
+func resourceMLBPolicyV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts policies.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer policy attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := policies.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer policy attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBPolicyV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ policy, err := resourceMLBPolicyV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if policy.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts policies.CreateStagedOpts
+
+ if d.HasChange("algorithm") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Algorithm = d.Get("algorithm").(string)
+ }
+
+ if d.HasChange("persistence") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Persistence = d.Get("persistence").(string)
+ }
+
+ if d.HasChange("idle_timeout") {
+ isConfigurationsUpdated = true
+ createStagedOpts.IdleTimeout = d.Get("idle_timeout").(int)
+ }
+
+ if d.HasChange("sorry_page_url") {
+ isConfigurationsUpdated = true
+ createStagedOpts.SorryPageUrl = d.Get("sorry_page_url").(string)
+ }
+
+ if d.HasChange("source_nat") {
+ isConfigurationsUpdated = true
+ createStagedOpts.SourceNat = d.Get("source_nat").(string)
+ }
+
+ if d.HasChange("certificate_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.CertificateID = d.Get("certificate_id").(string)
+ }
+
+ if d.HasChange("health_monitor_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.HealthMonitorID = d.Get("health_monitor_id").(string)
+ }
+
+ if d.HasChange("listener_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.ListenerID = d.Get("listener_id").(string)
+ }
+
+ if d.HasChange("default_target_group_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.DefaultTargetGroupID = d.Get("default_target_group_id").(string)
+ }
+
+ if d.HasChange("tls_policy_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.TLSPolicyID = d.Get("tls_policy_id").(string)
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer policy configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := policies.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer policy configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts policies.UpdateStagedOpts
+
+ if d.HasChange("algorithm") {
+ isConfigurationsUpdated = true
+ algorithm := d.Get("algorithm").(string)
+ updateStagedOpts.Algorithm = &algorithm
+ }
+
+ if d.HasChange("persistence") {
+ isConfigurationsUpdated = true
+ persistence := d.Get("persistence").(string)
+ updateStagedOpts.Persistence = &persistence
+ }
+
+ if d.HasChange("idle_timeout") {
+ isConfigurationsUpdated = true
+ idleTimeout := d.Get("idle_timeout").(int)
+ updateStagedOpts.IdleTimeout = &idleTimeout
+ }
+
+ if d.HasChange("sorry_page_url") {
+ isConfigurationsUpdated = true
+ sorryPageUrl := d.Get("sorry_page_url").(string)
+ updateStagedOpts.SorryPageUrl = &sorryPageUrl
+ }
+
+ if d.HasChange("source_nat") {
+ isConfigurationsUpdated = true
+ sourceNat := d.Get("source_nat").(string)
+ updateStagedOpts.SourceNat = &sourceNat
+ }
+
+ if d.HasChange("certificate_id") {
+ isConfigurationsUpdated = true
+ certificateID := d.Get("certificate_id").(string)
+ updateStagedOpts.CertificateID = &certificateID
+ }
+
+ if d.HasChange("health_monitor_id") {
+ isConfigurationsUpdated = true
+ healthMonitorID := d.Get("health_monitor_id").(string)
+ updateStagedOpts.HealthMonitorID = &healthMonitorID
+ }
+
+ if d.HasChange("listener_id") {
+ isConfigurationsUpdated = true
+ listenerID := d.Get("listener_id").(string)
+ updateStagedOpts.ListenerID = &listenerID
+ }
+
+ if d.HasChange("default_target_group_id") {
+ isConfigurationsUpdated = true
+ defaultTargetGroupID := d.Get("default_target_group_id").(string)
+ updateStagedOpts.DefaultTargetGroupID = &defaultTargetGroupID
+ }
+
+ if d.HasChange("tls_policy_id") {
+ isConfigurationsUpdated = true
+ tlsPolicyID := d.Get("tls_policy_id").(string)
+ updateStagedOpts.TLSPolicyID = &tlsPolicyID
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer policy configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := policies.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer policy configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBPolicyV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer policy: %s", d.Id())
+
+ err = policies.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer policy (%s)", d.Id())
+ return nil
+ }
+
+ policy, err := resourceMLBPolicyV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if policy.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer policy (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer policy: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_policy_v1_mock_test.go b/ecl/resource_ecl_mlb_policy_v1_mock_test.go
new file mode 100644
index 00000000..9456cc43
--- /dev/null
+++ b/ecl/resource_ecl_mlb_policy_v1_mock_test.go
@@ -0,0 +1,634 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1PolicyResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "policies", "/v1.0/policies", testMockMLBV1PoliciesCreate)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterCreate)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesUpdateAttributes)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowBeforeUpdateConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1PoliciesUpdateConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterApplyConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowBeforeCreateConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1PoliciesCreateConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterCreateConfigurations)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesDelete)
+ mc.Register(t, "policies", "/v1.0/policies/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1PoliciesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Policy,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "name", "policy"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "name", "policy-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "algorithm", "least-connection"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "persistence", "source-ip"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "idle_timeout", "120"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "sorry_page_url", ""),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "source_nat", "disable"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "certificate_id", ""),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tls_policy_id", ""),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1PolicyUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "name", "policy-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "algorithm", "round-robin"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "persistence", "cookie"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "idle_timeout", "600"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "sorry_page_url", "https://example.com/sorry"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "source_nat", "enable"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "certificate_id", "f57a98fe-d63e-4048-93a0-51fe163f30d7"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "health_monitor_id", "dd7a96d6-4e66-4666-baca-a8555f0c472c"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "listener_id", "68633f4f-f52a-402f-8572-b8173418904f"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "default_target_group_id", "a44c4072-ed90-4b50-a33a-6b38fb10c7db"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tls_policy_id", "4ba79662-f2a1-41a4-a3d9-595799bbcd86"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_policy_v1.policy", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1Policy = fmt.Sprintf(`
+resource "ecl_mlb_policy_v1" "policy" {
+ name = "policy"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ algorithm = "round-robin"
+ persistence = "cookie"
+ idle_timeout = 600
+ sorry_page_url = "https://example.com/sorry"
+ source_nat = "enable"
+ certificate_id = "f57a98fe-d63e-4048-93a0-51fe163f30d7"
+ health_monitor_id = "dd7a96d6-4e66-4666-baca-a8555f0c472c"
+ listener_id = "68633f4f-f52a-402f-8572-b8173418904f"
+ default_target_group_id = "a44c4072-ed90-4b50-a33a-6b38fb10c7db"
+ tls_policy_id = "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1PolicyUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_policy_v1" "policy" {
+ name = "policy-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ algorithm = "least-connection"
+ persistence = "source-ip"
+ idle_timeout = 120
+ sorry_page_url = ""
+ source_nat = "disable"
+ certificate_id = ""
+ health_monitor_id = "dd7a96d6-4e66-4666-baca-a8555f0c472c"
+ listener_id = "68633f4f-f52a-402f-8572-b8173418904f"
+ default_target_group_id = "a44c4072-ed90-4b50-a33a-6b38fb10c7db"
+ tls_policy_id = ""
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1PolicyUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_policy_v1" "policy" {
+ name = "policy-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ algorithm = "round-robin"
+ persistence = "cookie"
+ idle_timeout = 600
+ sorry_page_url = "https://example.com/sorry"
+ source_nat = "enable"
+ certificate_id = "f57a98fe-d63e-4048-93a0-51fe163f30d7"
+ health_monitor_id = "dd7a96d6-4e66-4666-baca-a8555f0c472c"
+ listener_id = "68633f4f-f52a-402f-8572-b8173418904f"
+ default_target_group_id = "a44c4072-ed90-4b50-a33a-6b38fb10c7db"
+ tls_policy_id = "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1PoliciesCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"policy":{"algorithm":"round-robin","certificate_id":"f57a98fe-d63e-4048-93a0-51fe163f30d7","default_target_group_id":"a44c4072-ed90-4b50-a33a-6b38fb10c7db","description":"description","health_monitor_id":"dd7a96d6-4e66-4666-baca-a8555f0c472c","idle_timeout":600,"listener_id":"68633f4f-f52a-402f-8572-b8173418904f","load_balancer_id":"67fea379-cff0-4191-9175-de7d6941a040","name":"policy","persistence":"cookie","sorry_page_url":"https://example.com/sorry","source_nat":"enable","tags":{"key":"value"},"tls_policy_id":"4ba79662-f2a1-41a4-a3d9-595799bbcd86"}}
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": null,
+ "persistence": null,
+ "idle_timeout": null,
+ "sorry_page_url": null,
+ "source_nat": null,
+ "certificate_id": null,
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1PoliciesShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": null,
+ "persistence": null,
+ "idle_timeout": null,
+ "sorry_page_url": null,
+ "source_nat": null,
+ "certificate_id": null,
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": null,
+ "current": null,
+ "staged": {
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1PoliciesShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": null,
+ "persistence": null,
+ "idle_timeout": null,
+ "sorry_page_url": null,
+ "source_nat": null,
+ "certificate_id": null,
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1PoliciesShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": null,
+ "persistence": null,
+ "idle_timeout": null,
+ "sorry_page_url": null,
+ "source_nat": null,
+ "certificate_id": null,
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": null,
+ "current": null,
+ "staged": {
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1PoliciesShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "",
+ "current": {
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1PoliciesShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1PoliciesShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "",
+ "current": {
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ },
+ "staged": {
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1PoliciesShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": "",
+ "current": {
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1PoliciesUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"policy":{"description":"description-update","name":"policy-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "policy-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "algorithm": null,
+ "persistence": null,
+ "idle_timeout": null,
+ "sorry_page_url": null,
+ "source_nat": null,
+ "certificate_id": null,
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1PoliciesCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"policy":{"algorithm":"round-robin","certificate_id":"f57a98fe-d63e-4048-93a0-51fe163f30d7","idle_timeout":600,"persistence":"cookie","sorry_page_url":"https://example.com/sorry","source_nat":"enable","tls_policy_id":"4ba79662-f2a1-41a4-a3d9-595799bbcd86"}}
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "algorithm": "round-robin",
+ "persistence": "cookie",
+ "idle_timeout": 600,
+ "sorry_page_url": "https://example.com/sorry",
+ "source_nat": "enable",
+ "certificate_id": "f57a98fe-d63e-4048-93a0-51fe163f30d7",
+ "health_monitor_id": null,
+ "listener_id": null,
+ "default_target_group_id": null,
+ "tls_policy_id": "4ba79662-f2a1-41a4-a3d9-595799bbcd86"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1PoliciesUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"policy":{"algorithm":"least-connection","certificate_id":"","idle_timeout":120,"persistence":"source-ip","sorry_page_url":"","source_nat":"disable","tls_policy_id":""}}
+response:
+ code: 200
+ body: >
+ {
+ "policy": {
+ "algorithm": "least-connection",
+ "persistence": "source-ip",
+ "idle_timeout": 120,
+ "sorry_page_url": "",
+ "source_nat": "disable",
+ "certificate_id": "",
+ "health_monitor_id": "dd7a96d6-4e66-4666-baca-a8555f0c472c",
+ "listener_id": "68633f4f-f52a-402f-8572-b8173418904f",
+ "default_target_group_id": "a44c4072-ed90-4b50-a33a-6b38fb10c7db",
+ "tls_policy_id": ""
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1PoliciesDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_route_v1.go b/ecl/resource_ecl_mlb_route_v1.go
new file mode 100644
index 00000000..785751d3
--- /dev/null
+++ b/ecl/resource_ecl_mlb_route_v1.go
@@ -0,0 +1,268 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes"
+)
+
+func resourceMLBRouteV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBRouteV1Create,
+ Read: resourceMLBRouteV1Read,
+ Update: resourceMLBRouteV1Update,
+ Delete: resourceMLBRouteV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "destination_cidr": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "next_hop_ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ },
+ }
+
+ return result
+}
+
+func resourceMLBRouteV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := routes.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ DestinationCidr: d.Get("destination_cidr").(string),
+ NextHopIPAddress: d.Get("next_hop_ip_address").(string),
+ LoadBalancerID: d.Get("load_balancer_id").(string),
+ }
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer route with options %+v", createOpts)
+
+ route, err := routes.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer route with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(route.ID)
+ log.Printf("[INFO] ECL managed load balancer route ID: %s", route.ID)
+
+ return resourceMLBRouteV1Read(d, meta)
+}
+
+func resourceMLBRouteV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*routes.Route, error) {
+ var route routes.Route
+
+ showOpts := routes.ShowOpts{Changes: changes}
+ err := routes.Show(client, d.Id(), showOpts).ExtractInto(&route)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer route (%s): %s", d.Id(), err)
+ }
+
+ return &route, nil
+}
+
+func resourceMLBRouteV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ route, err := resourceMLBRouteV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "route")
+ }
+
+ if route.ConfigurationStatus == "ACTIVE" {
+ d.Set("next_hop_ip_address", route.NextHopIPAddress)
+ } else if route.ConfigurationStatus == "CREATE_STAGED" {
+ d.Set("next_hop_ip_address", route.Staged.NextHopIPAddress)
+ } else if route.ConfigurationStatus == "UPDATE_STAGED" {
+ d.Set("next_hop_ip_address", ternary(route.Staged.NextHopIPAddress == "", route.NextHopIPAddress, route.Staged.NextHopIPAddress))
+ } else if route.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", route.Name)
+ d.Set("description", route.Description)
+ d.Set("tags", route.Tags)
+ d.Set("destination_cidr", route.DestinationCidr)
+ d.Set("load_balancer_id", route.LoadBalancerID)
+ d.Set("tenant_id", route.TenantID)
+
+ return nil
+}
+
+func resourceMLBRouteV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer route ...")
+
+ err = resourceMLBRouteV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer route: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer route ...")
+
+ err = resourceMLBRouteV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer route: %s", err)
+ }
+
+ return resourceMLBRouteV1Read(d, meta)
+}
+
+func resourceMLBRouteV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts routes.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer route attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := routes.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer route attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBRouteV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ route, err := resourceMLBRouteV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if route.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts routes.CreateStagedOpts
+
+ if d.HasChange("next_hop_ip_address") {
+ isConfigurationsUpdated = true
+ createStagedOpts.NextHopIPAddress = d.Get("next_hop_ip_address").(string)
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer route configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := routes.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer route configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts routes.UpdateStagedOpts
+
+ if d.HasChange("next_hop_ip_address") {
+ isConfigurationsUpdated = true
+ nextHopIPAddress := d.Get("next_hop_ip_address").(string)
+ updateStagedOpts.NextHopIPAddress = &nextHopIPAddress
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer route configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := routes.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer route configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBRouteV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer route: %s", d.Id())
+
+ err = routes.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer route (%s)", d.Id())
+ return nil
+ }
+
+ route, err := resourceMLBRouteV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if route.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer route (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer route: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_route_v1_mock_test.go b/ecl/resource_ecl_mlb_route_v1_mock_test.go
new file mode 100644
index 00000000..425ae9f9
--- /dev/null
+++ b/ecl/resource_ecl_mlb_route_v1_mock_test.go
@@ -0,0 +1,442 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1RouteResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "routes", "/v1.0/routes", testMockMLBV1RoutesCreate)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterCreate)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesUpdateAttributes)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowBeforeUpdateConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1RoutesUpdateConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterApplyConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowBeforeCreateConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1RoutesCreateConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterCreateConfigurations)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesDelete)
+ mc.Register(t, "routes", "/v1.0/routes/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RoutesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Route,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "name", "route"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "next_hop_ip_address", "192.168.0.254"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "name", "route-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "next_hop_ip_address", "192.168.1.254"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RouteUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "name", "route-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "destination_cidr", "172.16.0.0/24"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "next_hop_ip_address", "192.168.0.254"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_route_v1.route", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1Route = fmt.Sprintf(`
+resource "ecl_mlb_route_v1" "route" {
+ name = "route"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ destination_cidr = "172.16.0.0/24"
+ next_hop_ip_address = "192.168.0.254"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1RouteUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_route_v1" "route" {
+ name = "route-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ destination_cidr = "172.16.0.0/24"
+ next_hop_ip_address = "192.168.1.254"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testAccMLBV1RouteUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_route_v1" "route" {
+ name = "route-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ destination_cidr = "172.16.0.0/24"
+ next_hop_ip_address = "192.168.0.254"
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+}
+`)
+
+var testMockMLBV1RoutesCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"route":{"description":"description","destination_cidr":"172.16.0.0/24","load_balancer_id":"67fea379-cff0-4191-9175-de7d6941a040","name":"route","next_hop_ip_address":"192.168.0.254","tags":{"key":"value"}}}
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1RoutesShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": null,
+ "current": null,
+ "staged": {
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1RoutesShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1RoutesShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": null,
+ "current": null,
+ "staged": {
+ "next_hop_ip_address": "192.168.1.254"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1RoutesShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.1.254",
+ "current": {
+ "next_hop_ip_address": "192.168.1.254"
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1RoutesShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.1.254"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1RoutesShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.1.254",
+ "current": {
+ "next_hop_ip_address": "192.168.1.254"
+ },
+ "staged": {
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1RoutesShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": "192.168.1.254",
+ "current": {
+ "next_hop_ip_address": "192.168.1.254"
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1RoutesUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"route":{"description":"description-update","name":"route-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "route-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "destination_cidr": "172.16.0.0/24",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "next_hop_ip_address": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1RoutesCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"route":{"next_hop_ip_address":"192.168.0.254"}}
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "next_hop_ip_address": "192.168.0.254"
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1RoutesUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"route":{"next_hop_ip_address":"192.168.1.254"}}
+response:
+ code: 200
+ body: >
+ {
+ "route": {
+ "next_hop_ip_address": "192.168.1.254"
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1RoutesDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_rule_v1.go b/ecl/resource_ecl_mlb_rule_v1.go
new file mode 100644
index 00000000..952419e6
--- /dev/null
+++ b/ecl/resource_ecl_mlb_rule_v1.go
@@ -0,0 +1,346 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules"
+)
+
+func conditionsSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeList,
+ Required: true,
+ MinItems: 1,
+ MaxItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "path_patterns": &schema.Schema{
+ Type: schema.TypeList,
+ Optional: true,
+ Elem: &schema.Schema{
+ Type: schema.TypeString,
+ },
+ },
+ },
+ },
+ }
+}
+
+func resourceMLBRuleV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Create: resourceMLBRuleV1Create,
+ Read: resourceMLBRuleV1Read,
+ Update: resourceMLBRuleV1Update,
+ Delete: resourceMLBRuleV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "priority": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ "target_group_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "policy_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ "conditions": conditionsSchemaForResource(),
+ },
+ }
+
+ return result
+}
+
+func resourceMLBRuleV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := rules.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ Priority: d.Get("priority").(int),
+ TargetGroupID: d.Get("target_group_id").(string),
+ PolicyID: d.Get("policy_id").(string),
+ }
+
+ pathPatterns := make([]string, len(d.Get("conditions").([]interface{})[0].(map[string]interface{})["path_patterns"].([]interface{})))
+ for i, pathPattern := range d.Get("conditions").([]interface{})[0].(map[string]interface{})["path_patterns"].([]interface{}) {
+ pathPatterns[i] = pathPattern.(string)
+ }
+
+ condition := rules.CreateOptsCondition{
+ PathPatterns: pathPatterns,
+ }
+ createOpts.Conditions = &condition
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer rule with options %+v", createOpts)
+
+ rule, err := rules.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer rule with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(rule.ID)
+ log.Printf("[INFO] ECL managed load balancer rule ID: %s", rule.ID)
+
+ return resourceMLBRuleV1Read(d, meta)
+}
+
+func resourceMLBRuleV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*rules.Rule, error) {
+ var rule rules.Rule
+
+ showOpts := rules.ShowOpts{Changes: changes}
+ err := rules.Show(client, d.Id(), showOpts).ExtractInto(&rule)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer rule (%s): %s", d.Id(), err)
+ }
+
+ return &rule, nil
+}
+
+func resourceMLBRuleV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ rule, err := resourceMLBRuleV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "rule")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer rule (%s): %+v", d.Id(), rule)
+
+ conditions := make(map[string]interface{})
+
+ if rule.ConfigurationStatus == "ACTIVE" {
+ d.Set("priority", rule.Priority)
+ d.Set("target_group_id", rule.TargetGroupID)
+ conditions["path_patterns"] = rule.Conditions.PathPatterns
+ } else if rule.ConfigurationStatus == "CREATE_STAGED" {
+ d.Set("priority", rule.Staged.Priority)
+ d.Set("target_group_id", rule.Staged.TargetGroupID)
+ conditions["path_patterns"] = rule.Staged.Conditions.PathPatterns
+ } else if rule.ConfigurationStatus == "UPDATE_STAGED" {
+ d.Set("priority", ternary(rule.Staged.Priority == 0, rule.Priority, rule.Staged.Priority))
+ d.Set("target_group_id", ternary(rule.Staged.TargetGroupID == "", rule.TargetGroupID, rule.Staged.TargetGroupID))
+ conditions["path_patterns"] = ternary(rule.Staged.Conditions.PathPatterns == nil, rule.Conditions.PathPatterns, rule.Staged.Conditions.PathPatterns)
+ } else if rule.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", rule.Name)
+ d.Set("description", rule.Description)
+ d.Set("tags", rule.Tags)
+ d.Set("policy_id", rule.PolicyID)
+ d.Set("load_balancer_id", rule.LoadBalancerID)
+ d.Set("tenant_id", rule.TenantID)
+ d.Set("conditions", []interface{}{conditions})
+
+ return nil
+}
+
+func resourceMLBRuleV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer rule ...")
+
+ err = resourceMLBRuleV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer rule: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer rule ...")
+
+ err = resourceMLBRuleV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer rule: %s", err)
+ }
+
+ return resourceMLBRuleV1Read(d, meta)
+}
+
+func resourceMLBRuleV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts rules.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer rule attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := rules.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer rule attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBRuleV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ pathPatterns := make([]string, len(d.Get("conditions").([]interface{})[0].(map[string]interface{})["path_patterns"].([]interface{})))
+ for i, pathPattern := range d.Get("conditions").([]interface{})[0].(map[string]interface{})["path_patterns"].([]interface{}) {
+ pathPatterns[i] = pathPattern.(string)
+ }
+
+ rule, err := resourceMLBRuleV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if rule.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts rules.CreateStagedOpts
+
+ if d.HasChange("priority") {
+ isConfigurationsUpdated = true
+ createStagedOpts.Priority = d.Get("priority").(int)
+ }
+
+ if d.HasChange("target_group_id") {
+ isConfigurationsUpdated = true
+ createStagedOpts.TargetGroupID = d.Get("target_group_id").(string)
+ }
+
+ if d.HasChange("conditions") {
+ isConfigurationsUpdated = true
+ condition := rules.CreateStagedOptsCondition{
+ PathPatterns: pathPatterns,
+ }
+ createStagedOpts.Conditions = &condition
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer rule configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := rules.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer rule configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts rules.UpdateStagedOpts
+
+ if d.HasChange("priority") {
+ isConfigurationsUpdated = true
+ priority := d.Get("priority").(int)
+ updateStagedOpts.Priority = &priority
+ }
+
+ if d.HasChange("target_group_id") {
+ isConfigurationsUpdated = true
+ targetGroupID := d.Get("target_group_id").(string)
+ updateStagedOpts.TargetGroupID = &targetGroupID
+ }
+
+ if d.HasChange("conditions") {
+ isConfigurationsUpdated = true
+ condition := rules.UpdateStagedOptsCondition{
+ PathPatterns: &pathPatterns,
+ }
+ updateStagedOpts.Conditions = &condition
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer rule configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := rules.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer rule configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBRuleV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer rule: %s", d.Id())
+
+ err = rules.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer rule (%s)", d.Id())
+ return nil
+ }
+
+ rule, err := resourceMLBRuleV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if rule.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer rule (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer rule: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_rule_v1_mock_test.go b/ecl/resource_ecl_mlb_rule_v1_mock_test.go
new file mode 100644
index 00000000..61945104
--- /dev/null
+++ b/ecl/resource_ecl_mlb_rule_v1_mock_test.go
@@ -0,0 +1,516 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1RuleResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "rules", "/v1.0/rules", testMockMLBV1RulesCreate)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterCreate)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesUpdateAttributes)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowBeforeUpdateConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1RulesUpdateConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterApplyConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowBeforeCreateConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1RulesCreateConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterCreateConfigurations)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesDelete)
+ mc.Register(t, "rules", "/v1.0/rules/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1RulesShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1Rule,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "name", "rule"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "priority", "1"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "conditions.0.path_patterns.0", "^/statics/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "name", "rule-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "priority", "1"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "conditions.0.path_patterns.0", "^/statics/"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "conditions.0.path_patterns.1", "^/assets/"),
+ ),
+ },
+ {
+ Config: testAccMLBV1RuleUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "name", "rule-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "priority", "1"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "target_group_id", "29527a3c-9e5d-48b7-868f-6442c7d21a95"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "policy_id", "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_rule_v1.rule", "conditions.0.path_patterns.0", "^/assets/"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1Rule = fmt.Sprintf(`
+resource "ecl_mlb_rule_v1" "rule" {
+ name = "rule"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ priority = 1
+ target_group_id = "29527a3c-9e5d-48b7-868f-6442c7d21a95"
+ policy_id = "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"
+ conditions {
+ path_patterns = ["^/statics/"]
+ }
+}
+`)
+
+var testAccMLBV1RuleUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_rule_v1" "rule" {
+ name = "rule-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ priority = 1
+ target_group_id = "29527a3c-9e5d-48b7-868f-6442c7d21a95"
+ policy_id = "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"
+ conditions {
+ path_patterns = ["^/statics/", "^/assets/"]
+ }
+}
+`)
+
+var testAccMLBV1RuleUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_rule_v1" "rule" {
+ name = "rule-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ priority = 1
+ target_group_id = "29527a3c-9e5d-48b7-868f-6442c7d21a95"
+ policy_id = "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4"
+ conditions {
+ path_patterns = ["^/assets/"]
+ }
+}
+`)
+
+var testMockMLBV1RulesCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"rule":{"conditions":{"path_patterns":["^/statics/"]},"description":"description","name":"rule","policy_id":"fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4","priority":1,"tags":{"key":"value"},"target_group_id":"29527a3c-9e5d-48b7-868f-6442c7d21a95"}}
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": null,
+ "target_group_id": null,
+ "conditions": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1RulesShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": null,
+ "target_group_id": null,
+ "conditions": null,
+ "current": null,
+ "staged": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/"]
+ }
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1RulesShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": null,
+ "target_group_id": null,
+ "conditions": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1RulesShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": null,
+ "target_group_id": null,
+ "conditions": null,
+ "current": null,
+ "staged": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1RulesShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ },
+ "current": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1RulesShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1RulesShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ },
+ "current": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ },
+ "staged": {
+ "priority": null,
+ "target_group_id": null,
+ "conditions": {
+ "path_patterns": ["^/assets/"]
+ }
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1RulesShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ },
+ "current": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1RulesUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"rule":{"description":"description-update","name":"rule-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "rule-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "policy_id": "fcb520e5-858d-4f9f-bc6c-7bd225fe7cf4",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "priority": null,
+ "target_group_id": null,
+ "conditions": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1RulesCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"rule":{"conditions":{"path_patterns":["^/assets/"]}}}
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "priority": null,
+ "target_group_id": null,
+ "conditions": {
+ "path_patterns": ["^/assets/"]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1RulesUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"rule":{"conditions":{"path_patterns":["^/statics/","^/assets/"]}}}
+response:
+ code: 200
+ body: >
+ {
+ "rule": {
+ "priority": 1,
+ "target_group_id": "29527a3c-9e5d-48b7-868f-6442c7d21a95",
+ "conditions": {
+ "path_patterns": ["^/statics/", "^/assets/"]
+ }
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1RulesDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/resource_ecl_mlb_target_group_v1.go b/ecl/resource_ecl_mlb_target_group_v1.go
new file mode 100644
index 00000000..23e791a9
--- /dev/null
+++ b/ecl/resource_ecl_mlb_target_group_v1.go
@@ -0,0 +1,329 @@
+package ecl
+
+import (
+ "fmt"
+ "log"
+
+ "github.com/hashicorp/terraform/helper/schema"
+ "github.com/nttcom/eclcloud/v2"
+ "github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups"
+)
+
+func membersSchemaForResource() *schema.Schema {
+ return &schema.Schema{
+ Type: schema.TypeList,
+ Required: true,
+ MinItems: 1,
+ Elem: &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "ip_address": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ },
+ "port": &schema.Schema{
+ Type: schema.TypeInt,
+ Required: true,
+ },
+ "weight": &schema.Schema{
+ Type: schema.TypeInt,
+ Optional: true,
+ },
+ },
+ },
+ }
+}
+
+func resourceMLBTargetGroupV1() *schema.Resource {
+ var result *schema.Resource
+
+ result = &schema.Resource{
+ Read: resourceMLBTargetGroupV1Read,
+ Create: resourceMLBTargetGroupV1Create,
+ Update: resourceMLBTargetGroupV1Update,
+ Delete: resourceMLBTargetGroupV1Delete,
+ Importer: &schema.ResourceImporter{
+ State: schema.ImportStatePassthrough,
+ },
+ Schema: map[string]*schema.Schema{
+ "name": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "description": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ },
+ "tags": &schema.Schema{
+ Type: schema.TypeMap,
+ Optional: true,
+ },
+ "load_balancer_id": &schema.Schema{
+ Type: schema.TypeString,
+ Required: true,
+ ForceNew: true,
+ },
+ "tenant_id": &schema.Schema{
+ Type: schema.TypeString,
+ Optional: true,
+ Computed: true,
+ },
+ "members": membersSchemaForResource(),
+ },
+ }
+
+ return result
+}
+
+func resourceMLBTargetGroupV1Create(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ createOpts := target_groups.CreateOpts{
+ Name: d.Get("name").(string),
+ Description: d.Get("description").(string),
+ Tags: d.Get("tags").(map[string]interface{}),
+ LoadBalancerID: d.Get("load_balancer_id").(string),
+ }
+
+ members := make([]target_groups.CreateOptsMember, len(d.Get("members").([]interface{})))
+ for i, member := range d.Get("members").([]interface{}) {
+ members[i] = target_groups.CreateOptsMember{
+ IPAddress: member.(map[string]interface{})["ip_address"].(string),
+ Port: member.(map[string]interface{})["port"].(int),
+ Weight: member.(map[string]interface{})["weight"].(int),
+ }
+ }
+ createOpts.Members = &members
+
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Creating ECL managed load balancer target group with options %+v", createOpts)
+
+ rule, err := target_groups.Create(managedLoadBalancerClient, createOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer target group with options %+v: %s", createOpts, err)
+ }
+
+ d.SetId(rule.ID)
+ log.Printf("[INFO] ECL managed load balancer target group ID: %s", rule.ID)
+
+ return resourceMLBTargetGroupV1Read(d, meta)
+}
+
+func resourceMLBTargetGroupV1Show(d *schema.ResourceData, client *eclcloud.ServiceClient, changes bool) (*target_groups.TargetGroup, error) {
+ var targetGroup target_groups.TargetGroup
+
+ showOpts := target_groups.ShowOpts{Changes: changes}
+ err := target_groups.Show(client, d.Id(), showOpts).ExtractInto(&targetGroup)
+ if err != nil {
+ return nil, fmt.Errorf("Unable to retrieve ECL managed load balancer target group (%s): %s", d.Id(), err)
+ }
+
+ return &targetGroup, nil
+}
+
+func resourceMLBTargetGroupV1Read(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ targetGroup, err := resourceMLBTargetGroupV1Show(d, managedLoadBalancerClient, true)
+ if err != nil {
+ return CheckDeleted(d, err, "target_group")
+ }
+
+ log.Printf("[DEBUG] Retrieved ECL managed load balancer target group (%s): %+v", d.Id(), targetGroup)
+
+ if targetGroup.ConfigurationStatus == "ACTIVE" || (targetGroup.ConfigurationStatus == "UPDATE_STAGED" && targetGroup.Members == nil) {
+ members := make([]interface{}, len(targetGroup.Members))
+ for i, member := range targetGroup.Members {
+ members[i] = map[string]interface{}{
+ "ip_address": member.IPAddress,
+ "port": member.Port,
+ "weight": member.Weight,
+ }
+ }
+
+ d.Set("members", members)
+ } else if targetGroup.ConfigurationStatus == "CREATE_STAGED" || (targetGroup.ConfigurationStatus == "UPDATE_STAGED" && targetGroup.Members != nil) {
+ members := make([]interface{}, len(targetGroup.Staged.Members))
+ for i, member := range targetGroup.Staged.Members {
+ members[i] = map[string]interface{}{
+ "ip_address": member.IPAddress,
+ "port": member.Port,
+ "weight": member.Weight,
+ }
+ }
+
+ d.Set("members", members)
+ } else if targetGroup.ConfigurationStatus == "DELETE_STAGED" {
+ d.SetId("")
+ return nil
+ }
+
+ d.Set("name", targetGroup.Name)
+ d.Set("description", targetGroup.Description)
+ d.Set("tags", targetGroup.Tags)
+ d.Set("load_balancer_id", targetGroup.LoadBalancerID)
+ d.Set("tenant_id", targetGroup.TenantID)
+
+ return nil
+}
+
+func resourceMLBTargetGroupV1Update(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating attributes of ECL managed load balancer target group ...")
+
+ err = resourceMLBTargetGroupV1UpdateAttributes(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating attributes of ECL managed load balancer target group: %s", err)
+ }
+
+ log.Printf("[DEBUG] Start updating configurations of ECL managed load balancer target group ...")
+
+ err = resourceMLBTargetGroupV1UpdateConfigurations(d, managedLoadBalancerClient)
+ if err != nil {
+ return fmt.Errorf("Error in updating configurations of ECL managed load balancer target group: %s", err)
+ }
+
+ return resourceMLBTargetGroupV1Read(d, meta)
+}
+
+func resourceMLBTargetGroupV1UpdateAttributes(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isAttributesUpdated bool
+ var updateOpts target_groups.UpdateOpts
+
+ if d.HasChange("name") {
+ isAttributesUpdated = true
+ name := d.Get("name").(string)
+ updateOpts.Name = &name
+ }
+
+ if d.HasChange("description") {
+ isAttributesUpdated = true
+ description := d.Get("description").(string)
+ updateOpts.Description = &description
+ }
+
+ if d.HasChange("tags") {
+ isAttributesUpdated = true
+ tags := d.Get("tags").(map[string]interface{})
+ updateOpts.Tags = &tags
+ }
+
+ if isAttributesUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer target group attributes (%s) with options %+v", d.Id(), updateOpts)
+
+ _, err := target_groups.Update(client, d.Id(), updateOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer target group attributes (%s) with options %+v: %s", d.Id(), updateOpts, err)
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBTargetGroupV1UpdateConfigurations(d *schema.ResourceData, client *eclcloud.ServiceClient) error {
+ var isConfigurationsUpdated bool
+
+ targetGroup, err := resourceMLBTargetGroupV1Show(d, client, false)
+ if err != nil {
+ return err
+ }
+
+ if targetGroup.ConfigurationStatus == "ACTIVE" {
+ var createStagedOpts target_groups.CreateStagedOpts
+
+ if d.HasChange("members") {
+ isConfigurationsUpdated = true
+
+ members := make([]target_groups.CreateStagedOptsMember, len(d.Get("members").([]interface{})))
+ for i, member := range d.Get("members").([]interface{}) {
+ members[i] = target_groups.CreateStagedOptsMember{
+ IPAddress: member.(map[string]interface{})["ip_address"].(string),
+ Port: member.(map[string]interface{})["port"].(int),
+ Weight: member.(map[string]interface{})["weight"].(int),
+ }
+ }
+ createStagedOpts.Members = &members
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer target group configurations (%s) with options %+v", d.Id(), createStagedOpts)
+
+ _, err := target_groups.CreateStaged(client, d.Id(), createStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer target group configurations (%s) with options %+v: %s", d.Id(), createStagedOpts, err)
+ }
+ }
+ } else {
+ var updateStagedOpts target_groups.UpdateStagedOpts
+
+ if d.HasChange("members") {
+ isConfigurationsUpdated = true
+
+ members := make([]target_groups.UpdateStagedOptsMember, len(d.Get("members").([]interface{})))
+ for i, member := range d.Get("members").([]interface{}) {
+ ipAddress := member.(map[string]interface{})["ip_address"].(string)
+ port := member.(map[string]interface{})["port"].(int)
+ weight := member.(map[string]interface{})["weight"].(int)
+ members[i] = target_groups.UpdateStagedOptsMember{
+ IPAddress: &ipAddress,
+ Port: &port,
+ Weight: &weight,
+ }
+ }
+ updateStagedOpts.Members = &members
+ }
+
+ if isConfigurationsUpdated {
+ log.Printf("[DEBUG] Updating ECL managed load balancer target group configurations (%s) with options %+v", d.Id(), updateStagedOpts)
+
+ _, err := target_groups.UpdateStaged(client, d.Id(), updateStagedOpts).Extract()
+ if err != nil {
+ return fmt.Errorf("Error updating ECL managed load balancer target group configurations (%s) with options %+v: %s", d.Id(), updateStagedOpts, err)
+ }
+ }
+ }
+
+ return nil
+}
+
+func resourceMLBTargetGroupV1Delete(d *schema.ResourceData, meta interface{}) error {
+ config := meta.(*Config)
+ managedLoadBalancerClient, err := config.managedLoadBalancerV1Client(GetRegion(d, config))
+ if err != nil {
+ return fmt.Errorf("Error creating ECL managed load balancer client: %s", err)
+ }
+
+ log.Printf("[DEBUG] Deleting ECL managed load balancer target group: %s", d.Id())
+
+ err = target_groups.Delete(managedLoadBalancerClient, d.Id()).ExtractErr()
+ if err != nil {
+ if _, ok := err.(eclcloud.ErrDefault404); ok {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer target group (%s)", d.Id())
+ return nil
+ }
+
+ targetGroup, err := resourceMLBTargetGroupV1Show(d, managedLoadBalancerClient, false)
+ if err != nil {
+ return err
+ }
+ if targetGroup.ConfigurationStatus == "DELETE_STAGED" {
+ log.Printf("[DEBUG] Already deleted ECL managed load balancer target group (%s)", d.Id())
+ return nil
+ }
+
+ return fmt.Errorf("Error deleting ECL managed load balancer target group: %s", err)
+ }
+
+ return nil
+}
diff --git a/ecl/resource_ecl_mlb_target_group_v1_mock_test.go b/ecl/resource_ecl_mlb_target_group_v1_mock_test.go
new file mode 100644
index 00000000..ab7f6b40
--- /dev/null
+++ b/ecl/resource_ecl_mlb_target_group_v1_mock_test.go
@@ -0,0 +1,570 @@
+package ecl
+
+import (
+ "fmt"
+ "testing"
+
+ "github.com/hashicorp/terraform/helper/resource"
+
+ "github.com/nttcom/terraform-provider-ecl/ecl/testhelper/mock"
+)
+
+func TestMockedAccMLBV1TargetGroupResource(t *testing.T) {
+ mc := mock.NewMockController()
+ defer mc.TerminateMockControllerSafety()
+
+ postKeystone := fmt.Sprintf(fakeKeystonePostTmpl, mc.Endpoint(), OS_REGION_NAME)
+
+ mc.Register(t, "keystone", "/v3/auth/tokens", postKeystone)
+ mc.Register(t, "target_groups", "/v1.0/target_groups", testMockMLBV1TargetGroupsCreate)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterCreate)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsUpdateAttributes)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowBeforeUpdateConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1TargetGroupsUpdateConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterUpdateConfigurations)
+ // Staged configurations of the load balancer and related resources are applied here
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterApplyConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowBeforeCreateConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08/staged", testMockMLBV1TargetGroupsCreateConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterCreateConfigurations)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsDelete)
+ mc.Register(t, "target_groups", "/v1.0/target_groups/497f6eca-6276-4993-bfeb-53cbbbba6f08", testMockMLBV1TargetGroupsShowAfterDelete)
+
+ mc.StartServer(t)
+
+ resource.Test(t, resource.TestCase{
+ PreCheck: func() { testAccPreCheck(t) },
+ Providers: testAccProviders,
+ Steps: []resource.TestStep{
+ {
+ Config: testAccMLBV1TargetGroup,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "name", "target_group"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "description", "description"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tags.key", "value"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupUpdateBeforeApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "name", "target_group-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.ip_address", "192.168.0.7"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.weight", "1"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.1.ip_address", "192.168.0.8"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.1.port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.1.weight", "1"),
+ ),
+ },
+ {
+ Config: testAccMLBV1TargetGroupUpdateAfterApplyConfigurations,
+ Check: resource.ComposeTestCheckFunc(
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "id", "497f6eca-6276-4993-bfeb-53cbbbba6f08"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "name", "target_group-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "description", "description-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tags.key-update", "value-update"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "load_balancer_id", "67fea379-cff0-4191-9175-de7d6941a040"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "tenant_id", "34f5c98ef430457ba81292637d0c6fd0"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.ip_address", "192.168.0.8"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.port", "80"),
+ resource.TestCheckResourceAttr("ecl_mlb_target_group_v1.target_group", "members.0.weight", "1"),
+ ),
+ },
+ },
+ })
+}
+
+var testAccMLBV1TargetGroup = fmt.Sprintf(`
+resource "ecl_mlb_target_group_v1" "target_group" {
+ name = "target_group"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+ members {
+ ip_address = "192.168.0.7"
+ port = 80
+ weight = 1
+ }
+}
+`)
+
+var testAccMLBV1TargetGroupUpdateBeforeApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_target_group_v1" "target_group" {
+ name = "target_group-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+ members {
+ ip_address = "192.168.0.7"
+ port = 80
+ weight = 1
+ }
+ members {
+ ip_address = "192.168.0.8"
+ port = 80
+ weight = 1
+ }
+}
+`)
+
+var testAccMLBV1TargetGroupUpdateAfterApplyConfigurations = fmt.Sprintf(`
+resource "ecl_mlb_target_group_v1" "target_group" {
+ name = "target_group-update"
+ description = "description-update"
+ tags = {
+ key-update = "value-update"
+ }
+ load_balancer_id = "67fea379-cff0-4191-9175-de7d6941a040"
+ members {
+ ip_address = "192.168.0.8"
+ port = 80
+ weight = 1
+ }
+}
+`)
+
+var testMockMLBV1TargetGroupsCreate = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"target_group":{"description":"description","load_balancer_id":"67fea379-cff0-4191-9175-de7d6941a040","members":[{"ip_address":"192.168.0.7","port":80,"weight":1}],"name":"target_group","tags":{"key":"value"}}}
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": null
+ }
+ }
+newStatus: Created
+`)
+
+var testMockMLBV1TargetGroupsShowAfterCreate = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group",
+ "description": "description",
+ "tags": {
+ "key": "value"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": null,
+ "current": null,
+ "staged": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - Created
+`)
+
+var testMockMLBV1TargetGroupsShowBeforeUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": null
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+`)
+
+var testMockMLBV1TargetGroupsShowAfterUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": null,
+ "current": null,
+ "staged": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedBeforeApply
+newStatus: ConfigurationsApplied
+`)
+
+var testMockMLBV1TargetGroupsShowAfterApplyConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ],
+ "current": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1TargetGroupsShowBeforeCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "ACTIVE",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+`)
+
+var testMockMLBV1TargetGroupsShowAfterCreateConfigurations = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "UPDATE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ],
+ "current": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ },
+ "staged": {
+ "members": [
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+ }
+expectedStatus:
+ - ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1TargetGroupsShowAfterDelete = fmt.Sprintf(`
+request:
+ method: GET
+ query:
+ changes:
+ - true
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "DELETE_STAGED",
+ "operation_status": "COMPLETE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ],
+ "current": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ },
+ "staged": null
+ }
+ }
+expectedStatus:
+ - Deleted
+`)
+
+var testMockMLBV1TargetGroupsUpdateAttributes = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"target_group":{"description":"description-update","name":"target_group-update","tags":{"key-update":"value-update"}}}
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
+ "name": "target_group-update",
+ "description": "description-update",
+ "tags": {
+ "key-update": "value-update"
+ },
+ "configuration_status": "CREATE_STAGED",
+ "operation_status": "NONE",
+ "load_balancer_id": "67fea379-cff0-4191-9175-de7d6941a040",
+ "tenant_id": "34f5c98ef430457ba81292637d0c6fd0",
+ "members": null
+ }
+ }
+expectedStatus:
+ - Created
+newStatus: AttributesUpdated
+`)
+
+var testMockMLBV1TargetGroupsCreateConfigurations = fmt.Sprintf(`
+request:
+ method: POST
+ body: >
+ {"target_group":{"members":[{"ip_address":"192.168.0.8","port":80,"weight":1}]}}
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "members": [
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - ConfigurationsApplied
+newStatus: ConfigurationsUpdatedAfterApply
+`)
+
+var testMockMLBV1TargetGroupsUpdateConfigurations = fmt.Sprintf(`
+request:
+ method: PATCH
+ body: >
+ {"target_group":{"members":[{"ip_address":"192.168.0.7","port":80,"weight":1},{"ip_address":"192.168.0.8","port":80,"weight":1}]}}
+response:
+ code: 200
+ body: >
+ {
+ "target_group": {
+ "members": [
+ {
+ "ip_address": "192.168.0.7",
+ "port": 80,
+ "weight": 1
+ },
+ {
+ "ip_address": "192.168.0.8",
+ "port": 80,
+ "weight": 1
+ }
+ ]
+ }
+ }
+expectedStatus:
+ - AttributesUpdated
+newStatus: ConfigurationsUpdatedBeforeApply
+`)
+
+var testMockMLBV1TargetGroupsDelete = fmt.Sprintf(`
+request:
+ method: DELETE
+response:
+ code: 204
+expectedStatus:
+ - Created
+ - ConfigurationsUpdatedAfterApply
+newStatus: Deleted
+`)
diff --git a/ecl/testhelper/mock/mock.go b/ecl/testhelper/mock/mock.go
index 66c8191e..021069b9 100644
--- a/ecl/testhelper/mock/mock.go
+++ b/ecl/testhelper/mock/mock.go
@@ -8,6 +8,7 @@ import (
"net/url"
"os"
"reflect"
+ "strings"
"testing"
"gopkg.in/yaml.v2"
@@ -131,15 +132,7 @@ func (mc MockController) setupHandler(t *testing.T, path string, mocks []Mock) {
}
}
- if v.Request.Body != "" && v.Request.Body != string(body) {
- continue
- }
-
- if v.Request.Method != r.Method {
- continue
- }
-
- if v.Request.Body != "" && v.Request.Body != string(body) {
+ if v.Request.Body != "" && strings.TrimSpace(v.Request.Body) != strings.TrimSpace(string(body)) {
continue
}
diff --git a/ecl/util.go b/ecl/util.go
index 8c2a19d0..db2bb8d9 100644
--- a/ecl/util.go
+++ b/ecl/util.go
@@ -246,3 +246,11 @@ func getTags(d *schema.ResourceData, tagName string) (map[string]string, error)
}
return tags, nil
}
+
+func ternary(condition bool, ifOutput interface{}, elseOutput interface{}) interface{} {
+ if condition {
+ return ifOutput
+ }
+
+ return elseOutput
+}
diff --git a/examples/managed-load-balancer/README.md b/examples/managed-load-balancer/README.md
new file mode 100644
index 00000000..fe1e855d
--- /dev/null
+++ b/examples/managed-load-balancer/README.md
@@ -0,0 +1,29 @@
+# How to configure Managed Load Balancer resources and apply them to an instance.
+
+This provides a template for creating a new Managed Load Balancer instance on Enterprise Cloud 2.0.
+
+First set the required environment variables for the Enterprise Cloud 2.0 provider by
+
+```
+source openrc
+```
+
+There is a sample of openrc as openrc.sample, so copy, rename it, and fill blank parameters afterward.
+
+Secondary run with a command like this:
+
+```
+cd resources
+terraform apply
+```
+
+The network and the subnet are created, and the load balancer and related resources are configured (like candidate-config) by this command.
+
+Thirdly run with a command like this:
+
+```
+cd action
+terraform apply
+```
+
+Configurations of the load balancer and related resources are applied to the instance by this command.
diff --git a/examples/managed-load-balancer/action/main.tf b/examples/managed-load-balancer/action/main.tf
new file mode 100644
index 00000000..10a8d64d
--- /dev/null
+++ b/examples/managed-load-balancer/action/main.tf
@@ -0,0 +1,19 @@
+resource "null_resource" "always_run" {
+ triggers = {
+ timestamp = "${timestamp()}"
+ }
+}
+
+data "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer"
+}
+
+resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+ load_balancer_id = data.ecl_mlb_load_balancer_v1.load_balancer.id
+ apply_configurations = true
+ lifecycle {
+ replace_triggered_by = [
+ null_resource.always_run
+ ]
+ }
+}
diff --git a/examples/managed-load-balancer/openrc.sample b/examples/managed-load-balancer/openrc.sample
new file mode 100644
index 00000000..888bf342
--- /dev/null
+++ b/examples/managed-load-balancer/openrc.sample
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+export OS_AUTH_URL=https://keystone-jp5-ecl.api.ntt.com/v3/
+export OS_USERNAME=YOUR_API_KEY
+export OS_PASSWORD=YOUR_API_SECRET_KEY
+export OS_USER_DOMAIN_ID=default
+export OS_PROJECT_DOMAIN_ID=default
diff --git a/examples/managed-load-balancer/resources/certificate/ca_dummy.pem b/examples/managed-load-balancer/resources/certificate/ca_dummy.pem
new file mode 100644
index 00000000..0b42bc74
--- /dev/null
+++ b/examples/managed-load-balancer/resources/certificate/ca_dummy.pem
@@ -0,0 +1,3 @@
+-----BEGIN CERTIFICATE-----
+dummy
+-----END CERTIFICATE-----
diff --git a/examples/managed-load-balancer/resources/certificate/server_dummy.crt b/examples/managed-load-balancer/resources/certificate/server_dummy.crt
new file mode 100644
index 00000000..0b42bc74
--- /dev/null
+++ b/examples/managed-load-balancer/resources/certificate/server_dummy.crt
@@ -0,0 +1,3 @@
+-----BEGIN CERTIFICATE-----
+dummy
+-----END CERTIFICATE-----
diff --git a/examples/managed-load-balancer/resources/certificate/server_dummy.key b/examples/managed-load-balancer/resources/certificate/server_dummy.key
new file mode 100644
index 00000000..dd7209c2
--- /dev/null
+++ b/examples/managed-load-balancer/resources/certificate/server_dummy.key
@@ -0,0 +1,3 @@
+-----BEGIN RSA PRIVATE KEY-----
+dummy
+-----END RSA PRIVATE KEY-----
diff --git a/examples/managed-load-balancer/resources/main.tf b/examples/managed-load-balancer/resources/main.tf
new file mode 100644
index 00000000..0013052f
--- /dev/null
+++ b/examples/managed-load-balancer/resources/main.tf
@@ -0,0 +1,142 @@
+data "ecl_mlb_plan_v1" "ha_50m_4if" {
+ name = "50M_HA_4IF"
+}
+
+data "ecl_mlb_tls_policy_v1" "tlsv1_2_202210_01" {
+ name = "TLSv1.2_202210_01"
+}
+
+resource "ecl_network_network_v2" "network" {
+ name = "network"
+}
+
+resource "ecl_network_subnet_v2" "subnet" {
+ name = "subnet"
+ network_id = ecl_network_network_v2.network.id
+ cidr = "192.168.0.0/24"
+}
+
+resource "ecl_mlb_certificate_v1" "certificate" {
+ name = "certificate"
+ ca_cert = {
+ content = filebase64("${path.module}/certificate/ca_dummy.pem")
+ }
+ ssl_cert = {
+ content = filebase64("${path.module}/certificate/server_dummy.crt")
+ }
+ ssl_key = {
+ content = filebase64("${path.module}/certificate/server_dummy.key")
+ }
+}
+
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer"
+ plan_id = data.ecl_mlb_plan_v1.ha_50m_4if.id
+ syslog_servers {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 15)
+ }
+ interfaces {
+ network_id = ecl_network_network_v2.network.id
+ virtual_ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 10)
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 11)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 12)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 13)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 14)
+ }
+ }
+ depends_on = [ecl_mlb_certificate_v1.certificate]
+}
+
+resource "ecl_mlb_route_v1" "route" {
+ name = "route"
+ destination_cidr = "172.16.0.0/24"
+ next_hop_ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 254)
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ name = "health_monitor"
+ port = 80
+ protocol = "http"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+
+resource "ecl_mlb_listener_v1" "listener" {
+ name = "listener"
+ ip_address = "10.0.0.1"
+ port = 443
+ protocol = "https"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+
+resource "ecl_mlb_target_group_v1" "target_group_1" {
+ name = "target_group_1"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+ members {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 16)
+ port = 80
+ }
+}
+
+resource "ecl_mlb_target_group_v1" "target_group_2" {
+ name = "target_group_2"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+ members {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 17)
+ port = 80
+ }
+}
+
+resource "ecl_mlb_policy_v1" "policy" {
+ name = "policy"
+ certificate_id = ecl_mlb_certificate_v1.certificate.id
+ health_monitor_id = ecl_mlb_health_monitor_v1.health_monitor.id
+ listener_id = ecl_mlb_listener_v1.listener.id
+ default_target_group_id = ecl_mlb_target_group_v1.target_group_1.id
+ tls_policy_id = data.ecl_mlb_tls_policy_v1.tlsv1_2_202210_01.id
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+
+resource "ecl_mlb_rule_v1" "rule" {
+ name = "rule"
+ target_group_id = ecl_mlb_target_group_v1.target_group_2.id
+ policy_id = ecl_mlb_policy_v1.policy.id
+ conditions {
+ path_patterns = ["^/statics/"]
+ }
+}
+
+# You can also write the following instead of ../action/main.tf
+#
+# resource "null_resource" "always_run" {
+# triggers = {
+# timestamp = "${timestamp()}"
+# }
+# }
+#
+# resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+# load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+# apply_configurations = true
+# depends_on = [
+# ecl_mlb_certificate_v1.certificate,
+# ecl_mlb_route_v1.route,
+# ecl_mlb_health_monitor_v1.health_monitor,
+# ecl_mlb_listener_v1.listener,
+# ecl_mlb_target_group_v1.target_group_1,
+# ecl_mlb_target_group_v1.target_group_2,
+# ecl_mlb_policy_v1.policy,
+# ecl_mlb_rule_v1.rule,
+# ]
+# lifecycle {
+# replace_triggered_by = [
+# null_resource.always_run
+# ]
+# }
+# }
diff --git a/go.mod b/go.mod
index f4944eb0..4e9ecbc6 100644
--- a/go.mod
+++ b/go.mod
@@ -2,7 +2,7 @@ module github.com/nttcom/terraform-provider-ecl
require (
github.com/hashicorp/terraform v0.12.6
- github.com/nttcom/eclcloud/v2 v2.7.0
+ github.com/nttcom/eclcloud/v2 v2.8.0
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e
gopkg.in/yaml.v2 v2.2.8
)
diff --git a/go.sum b/go.sum
index 788e49e0..031b4701 100644
--- a/go.sum
+++ b/go.sum
@@ -538,12 +538,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
-github.com/nttcom/eclcloud/v2 v2.4.1 h1:dufwTxX0eyMDTk5i4j3yNyRX8jaVM2+B6waLJbcGo0c=
-github.com/nttcom/eclcloud/v2 v2.4.1/go.mod h1:KoBB1B+xdeRXo0fNzggINrTQiuAsezh1SBVcbryS348=
-github.com/nttcom/eclcloud/v2 v2.5.0 h1:5X0adIpH6yRKOAI30/rveOL1knl54XNIlha1ZBbsqg0=
-github.com/nttcom/eclcloud/v2 v2.5.0/go.mod h1:KoBB1B+xdeRXo0fNzggINrTQiuAsezh1SBVcbryS348=
-github.com/nttcom/eclcloud/v2 v2.7.0 h1:A2oTNz/uhn7CARAY/z9VuISJF4VpbRDQO5vgJONVkts=
-github.com/nttcom/eclcloud/v2 v2.7.0/go.mod h1:KoBB1B+xdeRXo0fNzggINrTQiuAsezh1SBVcbryS348=
+github.com/nttcom/eclcloud/v2 v2.8.0 h1:l9QsBbOw3CEKHKG3REwd525Gbe0ACreAlwuXU3AJo9I=
+github.com/nttcom/eclcloud/v2 v2.8.0/go.mod h1:KoBB1B+xdeRXo0fNzggINrTQiuAsezh1SBVcbryS348=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/doc.go
index a0cd9ff6..02633bcd 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package certificates contains functionality for working with ECL Managed Load Balancer resources.
Example to list certificates
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/requests.go
index ff6d055a..dd5946c1 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package certificates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/results.go
index 5e1a11a8..2d3170ab 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package certificates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/urls.go
index e2e21a4c..874706b4 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/certificates/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package certificates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/doc.go
index b7cfae6f..8fb714ce 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package health_monitors contains functionality for working with ECL Managed Load Balancer resources.
Example to list health monitors
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/requests.go
index 39a33dae..1992ae73 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package health_monitors
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/results.go
index 12af174e..fc1b20fb 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package health_monitors
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/urls.go
index 106294e7..c3a2c6fa 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/health_monitors/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package health_monitors
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/doc.go
index 3ac6c464..7682c620 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package listeners contains functionality for working with ECL Managed Load Balancer resources.
Example to list listeners
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/requests.go
index 7be82b07..17201f33 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package listeners
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/results.go
index 9ac1068f..5fa0657b 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package listeners
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/urls.go
index c2aeed04..6e3e4ca7 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/listeners/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package listeners
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go
index 5c143775..2d40e690 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package load_balancers contains functionality for working with ECL Managed Load Balancer resources.
Example to list load balancers
@@ -117,20 +115,43 @@ Example to delete a load balancer
Example to perform apply-configurations action on a load balancer
+ actionOpts := load_balancers.ActionOpts{
+ ApplyConfigurations: true,
+ }
+
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
- err := load_balancers.ApplyConfigurations(managedLoadBalancerClient, id).ExtractErr()
+ err := load_balancers.Action(cli, id, actionOpts).ExtractErr()
if err != nil {
panic(err)
}
Example to perform system-update action on a load balancer
- systemUpdateOpts := load_balancers.SystemUpdateOpts{
+ systemUpdate := load_balancers.ActionOptsSystemUpdate{
+ SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb",
+ }
+ actionOpts := load_balancers.ActionOpts{
+ SystemUpdate: &systemUpdate,
+ }
+
+ id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
+ err := load_balancers.Action(cli, id, actionOpts).ExtractErr()
+ if err != nil {
+ panic(err)
+ }
+
+Example to perform apply-configurations and system-update action on a load balancer
+
+ systemUpdate := load_balancers.ActionOptsSystemUpdate{
SystemUpdateID: "31746df7-92f9-4b5e-ad05-59f6684a54eb",
}
+ actionOpts := load_balancers.ActionOpts{
+ ApplyConfigurations: true,
+ SystemUpdate: &systemUpdate,
+ }
id := "497f6eca-6276-4993-bfeb-53cbbbba6f08"
- err := load_balancers.SystemUpdate(managedLoadBalancerClient, id, systemUpdateOpts).ExtractErr()
+ err := load_balancers.Action(cli, id, actionOpts).ExtractErr()
if err != nil {
panic(err)
}
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go
index 0c70e378..6809ae83 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package load_balancers
import (
@@ -302,42 +299,49 @@ func Delete(c *eclcloud.ServiceClient, id string) (r DeleteResult) {
Action Load Balancer
*/
-// ApplyConfigurations performs action on a existing load balancer.
-func ApplyConfigurations(c *eclcloud.ServiceClient, id string) (r ActionResult) {
- b := map[string]interface{}{"apply-configurations": nil}
- _, r.Err = c.Post(actionURL(c, id), b, nil, &eclcloud.RequestOpts{
- OkCodes: []int{204},
- })
-
- return
-}
-
-// SystemUpdateOpts represents options used to perform action on a existing load balancer.
-type SystemUpdateOpts struct {
+// ActionOptsSystemUpdate represents system-update information in the load balancer action.
+type ActionOptsSystemUpdate struct {
// - ID of the system update that will be applied to the load balancer
SystemUpdateID string `json:"system_update_id"`
}
-// ToLoadBalancerSystemUpdateMap builds a request body from SystemUpdateOpts.
-func (opts SystemUpdateOpts) ToLoadBalancerSystemUpdateMap() (map[string]interface{}, error) {
- return eclcloud.BuildRequestBody(opts, "system-update")
-}
+// ActionOpts represents options used to perform action on a existing load balancer.
+type ActionOpts struct {
+
+ // - Added or changed configurations of the load balancer and related resources will be applied
+ ApplyConfigurations bool `json:"apply-configurations,omitempty"`
-// SystemUpdateOptsBuilder allows extensions to add additional parameters to the SystemUpdate request.
-type SystemUpdateOptsBuilder interface {
- ToLoadBalancerSystemUpdateMap() (map[string]interface{}, error)
+ // - Apply the system update to the load balancer
+ SystemUpdate *ActionOptsSystemUpdate `json:"system-update,omitempty"`
}
-// SystemUpdate accepts a SystemUpdateOpts struct and performs action on a existing load balancer using the values provided.
-func SystemUpdate(c *eclcloud.ServiceClient, id string, opts SystemUpdateOptsBuilder) (r ActionResult) {
- b, err := opts.ToLoadBalancerSystemUpdateMap()
- if err != nil {
- r.Err = err
+// ToLoadBalancerActionMap builds a request body from ActionOpts.
+func (opts ActionOpts) ToLoadBalancerActionMap() map[string]interface{} {
+ optsMap := make(map[string]interface{})
- return
+ if opts.ApplyConfigurations {
+ optsMap["apply-configurations"] = nil
+ }
+
+ if opts.SystemUpdate != nil {
+ optsMap["system-update"] = map[string]interface{}{
+ "system_update_id": opts.SystemUpdate.SystemUpdateID,
+ }
}
+ return optsMap
+}
+
+// ActionOptsBuilder allows extensions to add additional parameters to the Action request.
+type ActionOptsBuilder interface {
+ ToLoadBalancerActionMap() map[string]interface{}
+}
+
+// Action accepts a ActionOpts struct and performs action on a existing load balancer using the values provided.
+func Action(c *eclcloud.ServiceClient, id string, opts ActionOptsBuilder) (r ActionResult) {
+ b := opts.ToLoadBalancerActionMap()
+
_, r.Err = c.Post(actionURL(c, id), b, nil, &eclcloud.RequestOpts{
OkCodes: []int{204},
})
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/results.go
index e3679b71..aa34a4e0 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package load_balancers
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/urls.go
index 8a12ce13..361bd432 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/load_balancers/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package load_balancers
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/doc.go
index 4527fd76..6eb28a66 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package operations contains functionality for working with ECL Managed Load Balancer resources.
Example to list operations
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/requests.go
index c93f0d6c..2c148550 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package operations
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/results.go
index 2865c018..0d509086 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package operations
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/urls.go
index 5cdeb28c..36c8f39b 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/operations/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package operations
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/doc.go
index 0a3d9a45..c5710fbb 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package plans contains functionality for working with ECL Managed Load Balancer resources.
Example to list plans
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/requests.go
index ef8191f0..4f4bf320 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package plans
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/results.go
index 12645e1a..e1b6345f 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package plans
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/urls.go
index 2845e326..13c565e3 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/plans/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package plans
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/doc.go
index 28e6272b..a804c5df 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package policies contains functionality for working with ECL Managed Load Balancer resources.
Example to list policies
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/requests.go
index a8e1634c..1c610983 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package policies
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/results.go
index 7a345db6..d7c8ca0e 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package policies
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/urls.go
index e5196a3b..d169d788 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/policies/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package policies
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/doc.go
index 19f98e07..e6a5a70a 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package routes contains functionality for working with ECL Managed Load Balancer resources.
Example to list routes
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/requests.go
index 9a54be12..c2c746ae 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package routes
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/results.go
index 1629b39b..13e5be2f 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package routes
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/urls.go
index 0892a491..1f3fc6b5 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/routes/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package routes
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/doc.go
index 2ecbb9c3..1356c598 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package rules contains functionality for working with ECL Managed Load Balancer resources.
Example to list rules
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/requests.go
index 3da2422b..d465080a 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package rules
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/results.go
index e151343a..2dddb178 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package rules
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/urls.go
index a85f9277..dfc1edb8 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/rules/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package rules
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/doc.go
index f055e0ce..19bf8c20 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package system_updates contains functionality for working with ECL Managed Load Balancer resources.
Example to list system updates
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/requests.go
index 9c7174eb..caea0bf2 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package system_updates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/results.go
index fc8d7c1e..d6ca5d2e 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package system_updates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/urls.go
index 9cd40756..ea52a045 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/system_updates/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package system_updates
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/doc.go
index de5ceabc..bc9f5262 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package target_groups contains functionality for working with ECL Managed Load Balancer resources.
Example to list target groups
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/requests.go
index 42871956..3ae6ecd2 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package target_groups
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/results.go
index 1c964c4e..421b4dfc 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package target_groups
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/urls.go
index 8776912f..a93301c2 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/target_groups/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package target_groups
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/doc.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/doc.go
index 8ba1a3f1..f861a872 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/doc.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/doc.go
@@ -1,6 +1,4 @@
/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-
Package tls_policies contains functionality for working with ECL Managed Load Balancer resources.
Example to list tls policies
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/requests.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/requests.go
index 95a31252..35fb2756 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/requests.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/requests.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package tls_policies
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/results.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/results.go
index 2ccd1c5a..6ef0c358 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/results.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/results.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package tls_policies
import (
diff --git a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/urls.go b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/urls.go
index 05890ced..1b557517 100644
--- a/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/urls.go
+++ b/vendor/github.com/nttcom/eclcloud/v2/ecl/managed_load_balancer/v1/tls_policies/urls.go
@@ -1,6 +1,3 @@
-/*
-Generated by https://github.com/tamac-io/openapi-to-eclcloud-rb
-*/
package tls_policies
import (
diff --git a/vendor/modules.txt b/vendor/modules.txt
index ab718d8d..93ab28b2 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -290,7 +290,7 @@ github.com/mitchellh/mapstructure
# github.com/mitchellh/reflectwalk v1.0.0
## explicit
github.com/mitchellh/reflectwalk
-# github.com/nttcom/eclcloud/v2 v2.7.0
+# github.com/nttcom/eclcloud/v2 v2.8.0
## explicit; go 1.13
github.com/nttcom/eclcloud/v2
github.com/nttcom/eclcloud/v2/ecl
diff --git a/website/docs/d/mlb_certificate_v1.html.markdown b/website/docs/d/mlb_certificate_v1.html.markdown
index 0b1decf7..9987512b 100644
--- a/website/docs/d/mlb_certificate_v1.html.markdown
+++ b/website/docs/d/mlb_certificate_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_certificate_v1"
sidebar_current: "docs-ecl-datasource-mlb-certificate-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer certificate.
+ Use this data source to get information of a certificate within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_certificate\_v1
-Get information on an Enterprise Cloud Managed Load Balancer certificate.
+Use this data source to get information of a certificate within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,24 +20,14 @@ data "ecl_mlb_certificate_v1" "certificate" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
* `description` - (Optional) Description of the resource
* This field accepts single-byte characters only
* `tenant_id` - (Optional) ID of the owner tenant of the resource
-* `ca_cert_status` - (Optional) CA certificate file upload status of the certificate
- * Must be one of these values:
- * `"UPLOADED"`
- * `"NOT_UPLOADED"`
-* `ssl_cert_status` - (Optional) SSL certificate file upload status of the certificate
- * Must be one of these values:
- * `"UPLOADED"`
- * `"NOT_UPLOADED"`
-* `ssl_key_status` - (Optional) SSL key file upload status of the certificate
- * Must be one of these values:
- * `"UPLOADED"`
- * `"NOT_UPLOADED"`
## Attributes Reference
diff --git a/website/docs/d/mlb_health_monitor_v1.html.markdown b/website/docs/d/mlb_health_monitor_v1.html.markdown
index 19a707d5..fc8809c1 100644
--- a/website/docs/d/mlb_health_monitor_v1.html.markdown
+++ b/website/docs/d/mlb_health_monitor_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_health_monitor_v1"
sidebar_current: "docs-ecl-datasource-mlb-health-monitor-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer health monitor.
+ Use this data source to get information of a health monitor within Enterprise Cloud Managed Load Balancer.
---
-# ecl\_mlb\_health_monitor\_v1
+# ecl\_mlb\_health\_monitor\_v1
-Get information on an Enterprise Cloud Managed Load Balancer health monitor.
+Use this data source to get information of a health monitor within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_health_monitor_v1" "health_monitor" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_listener_v1.html.markdown b/website/docs/d/mlb_listener_v1.html.markdown
index 1bc191b4..5047c537 100644
--- a/website/docs/d/mlb_listener_v1.html.markdown
+++ b/website/docs/d/mlb_listener_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_listener_v1"
sidebar_current: "docs-ecl-datasource-mlb-listener-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer listener.
+ Use this data source to get information of a listener within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_listener\_v1
-Get information on an Enterprise Cloud Managed Load Balancer listener.
+Use this data source to get information of a listener within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_listener_v1" "listener" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_load_balancer_v1.html.markdown b/website/docs/d/mlb_load_balancer_v1.html.markdown
index bebf3c66..4ef01af0 100644
--- a/website/docs/d/mlb_load_balancer_v1.html.markdown
+++ b/website/docs/d/mlb_load_balancer_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_load_balancer_v1"
sidebar_current: "docs-ecl-datasource-mlb-load-balancer-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer load balancer.
+ Use this data source to get information of a load balancer within Enterprise Cloud Managed Load Balancer.
---
-# ecl\_mlb\_load_balancer\_v1
+# ecl\_mlb\_load\_balancer\_v1
-Get information on an Enterprise Cloud Managed Load Balancer load balancer.
+Use this data source to get information of a load balancer within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_load_balancer_v1" "load_balancer" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_operation_v1.html.markdown b/website/docs/d/mlb_operation_v1.html.markdown
index ab4a60f7..2bbdf882 100644
--- a/website/docs/d/mlb_operation_v1.html.markdown
+++ b/website/docs/d/mlb_operation_v1.html.markdown
@@ -1,28 +1,27 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_operation_v1"
sidebar_current: "docs-ecl-datasource-mlb-operation-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer operation.
+ Use this data source to get information of a operation within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_operation\_v1
-Get information on an Enterprise Cloud Managed Load Balancer operation.
+Use this data source to get information of a operation within Enterprise Cloud Managed Load Balancer.
## Example Usage
```hcl
-data "ecl_mlb_operation_v1" "" {
- name = ""
+data "ecl_mlb_operation_v1" "operation" {
+ resource_id = "4d5215ed-38bb-48ed-879a-fdb9ca58522f"
}
```
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `resource_id` - (Optional) ID of the resource
* `resource_type` - (Optional) Type of the resource
@@ -30,13 +29,6 @@ data "ecl_mlb_operation_v1" "" {
* `"ECL::ManagedLoadBalancer::LoadBalancer"`
* `request_id` - (Optional) The unique hyphenated UUID to identify the request
* The UUID which has been set by `X-MVNA-Request-Id` in request headers
-* `request_type` - (Optional) Type of the request
- * Must be one of these values:
- * `"Action::apply-configurations"`
- * `"Action::cancel-configurations"`
- * `"Action::system-update"`
- * `"Action::re-create"`
- * `"Delete"`
* `status` - (Optional) Operation status of the resource
* Must be one of these values:
* `"PROCESSING"`
@@ -44,8 +36,6 @@ data "ecl_mlb_operation_v1" "" {
* `"ERROR"`
* `"STUCK"`
* `tenant_id` - (Optional) ID of the owner tenant of the resource
-* `no_deleted` - (Optional) If `true` is set, operations of deleted resource is not displayed
-* `latest` - (Optional) If `true` is set, only the latest operation of each resource is displayed
## Attributes Reference
diff --git a/website/docs/d/mlb_plan_v1.html.markdown b/website/docs/d/mlb_plan_v1.html.markdown
index cb33f7fa..b55fe6c6 100644
--- a/website/docs/d/mlb_plan_v1.html.markdown
+++ b/website/docs/d/mlb_plan_v1.html.markdown
@@ -1,28 +1,27 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_plan_v1"
sidebar_current: "docs-ecl-datasource-mlb-plan-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer plan.
+ Use this data source to get information of a plan within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_plan\_v1
-Get information on an Enterprise Cloud Managed Load Balancer plan.
+Use this data source to get information of a plan within Enterprise Cloud Managed Load Balancer.
## Example Usage
```hcl
-data "ecl_mlb_plan_v1" "50M_HA_4IF" {
+data "ecl_mlb_plan_v1" "ha_50m_4if" {
name = "50M_HA_4IF"
}
```
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_policy_v1.html.markdown b/website/docs/d/mlb_policy_v1.html.markdown
index 9fbaeeb6..ee24864c 100644
--- a/website/docs/d/mlb_policy_v1.html.markdown
+++ b/website/docs/d/mlb_policy_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_policy_v1"
sidebar_current: "docs-ecl-datasource-mlb-policy-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer policy.
+ Use this data source to get information of a policy within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_policy\_v1
-Get information on an Enterprise Cloud Managed Load Balancer policy.
+Use this data source to get information of a policy within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_policy_v1" "policy" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_route_v1.html.markdown b/website/docs/d/mlb_route_v1.html.markdown
index af6cb75d..0450de63 100644
--- a/website/docs/d/mlb_route_v1.html.markdown
+++ b/website/docs/d/mlb_route_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_route_v1"
sidebar_current: "docs-ecl-datasource-mlb-route-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer route.
+ Use this data source to get information of a route within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_route\_v1
-Get information on an Enterprise Cloud Managed Load Balancer route.
+Use this data source to get information of a route within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_route_v1" "route" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_rule_v1.html.markdown b/website/docs/d/mlb_rule_v1.html.markdown
index f0491c0e..81c47827 100644
--- a/website/docs/d/mlb_rule_v1.html.markdown
+++ b/website/docs/d/mlb_rule_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_rule_v1"
sidebar_current: "docs-ecl-datasource-mlb-rule-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer rule.
+ Use this data source to get information of a rule within Enterprise Cloud Managed Load Balancer.
---
# ecl\_mlb\_rule\_v1
-Get information on an Enterprise Cloud Managed Load Balancer rule.
+Use this data source to get information of a rule within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_rule_v1" "rule" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_system_update_v1.html.markdown b/website/docs/d/mlb_system_update_v1.html.markdown
index 86422e8b..192e7d72 100644
--- a/website/docs/d/mlb_system_update_v1.html.markdown
+++ b/website/docs/d/mlb_system_update_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_system_update_v1"
sidebar_current: "docs-ecl-datasource-mlb-system-update-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer system update.
+ Use this data source to get information of a system update within Enterprise Cloud Managed Load Balancer.
---
-# ecl\_mlb\_system_update\_v1
+# ecl\_mlb\_system\_update\_v1
-Get information on an Enterprise Cloud Managed Load Balancer system update.
+Use this data source to get information of a system update within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_system_update_v1" "security_update_202210" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
@@ -32,7 +31,6 @@ data "ecl_mlb_system_update_v1" "security_update_202210" {
* `current_revision` - (Optional) Current revision for the system update
* `next_revision` - (Optional) Next revision for the system update
* `applicable` - (Optional) Whether the system update can be applied to the load balancer
-* `latest` - (Optional) If `true` is set, only the latest resource is displayed
## Attributes Reference
diff --git a/website/docs/d/mlb_target_group_v1.html.markdown b/website/docs/d/mlb_target_group_v1.html.markdown
index 2c15d9f0..02565980 100644
--- a/website/docs/d/mlb_target_group_v1.html.markdown
+++ b/website/docs/d/mlb_target_group_v1.html.markdown
@@ -1,17 +1,14 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_target_group_v1"
sidebar_current: "docs-ecl-datasource-mlb-target-group-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer target group.
+ Use this data source to get information of a target group within Enterprise Cloud Managed Load Balancer.
---
-# ecl\_mlb\_target_group\_v1
+# ecl\_mlb\_target\_group\_v1
-Get information on an Enterprise Cloud Managed Load Balancer target group.
+Use this data source to get information of a target group within Enterprise Cloud Managed Load Balancer.
## Example Usage
@@ -23,6 +20,8 @@ data "ecl_mlb_target_group_v1" "target_group" {
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/d/mlb_tls_policy_v1.html.markdown b/website/docs/d/mlb_tls_policy_v1.html.markdown
index b6e9affd..943d8c8b 100644
--- a/website/docs/d/mlb_tls_policy_v1.html.markdown
+++ b/website/docs/d/mlb_tls_policy_v1.html.markdown
@@ -1,28 +1,27 @@
---
-#
-# Generated by https://github.com/tamac-io/openapi-to-terraform-rb
-#
layout: "ecl"
page_title: "Enterprise Cloud: ecl_mlb_tls_policy_v1"
sidebar_current: "docs-ecl-datasource-mlb-tls-policy-v1"
description: |-
- Get information on an Enterprise Cloud Managed Load Balancer tls policy.
+ Use this data source to get information of a tls policy within Enterprise Cloud Managed Load Balancer.
---
-# ecl\_mlb\_tls_policy\_v1
+# ecl\_mlb\_tls\_policy\_v1
-Get information on an Enterprise Cloud Managed Load Balancer tls policy.
+Use this data source to get information of a tls policy within Enterprise Cloud Managed Load Balancer.
## Example Usage
```hcl
-data "ecl_mlb_tls_policy_v1" "TLSv1.2_202210_01" {
+data "ecl_mlb_tls_policy_v1" "tlsv1_2_202210_01" {
name = "TLSv1.2_202210_01"
}
```
## Argument Reference
+The following arguments are supported:
+
* `id` - (Optional) ID of the resource
* `name` - (Optional) Name of the resource
* This field accepts single-byte characters only
diff --git a/website/docs/r/mlb_certificate_v1.html.markdown b/website/docs/r/mlb_certificate_v1.html.markdown
new file mode 100644
index 00000000..272ab3e6
--- /dev/null
+++ b/website/docs/r/mlb_certificate_v1.html.markdown
@@ -0,0 +1,105 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_certificate_v1"
+sidebar_current: "docs-ecl-resource-mlb-certificate-v1"
+description: |-
+ Manages a certificate within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_certificate\_v1
+
+Manages a certificate within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a certificate to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_mlb_certificate_v1" "certificate" {
+ name = "certificate"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ ca_cert = {
+ content = filebase64("${path.module}/certificate/ca_cert.pem")
+ }
+ ssl_cert = {
+ content = filebase64("${path.module}/certificate/ssl_cert.crt")
+ }
+ ssl_key = {
+ content = filebase64("${path.module}/certificate/ssl_key.key")
+ }
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the certificate
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the certificate
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the certificate
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `ca_cert` - CA certificate file of the certificate
+ * Structure is [documented below](#ca-cert)
+* `ssl_cert` - SSL certificate file of the certificate
+ * Structure is [documented below](#ssl-cert)
+* `ssl_key` - SSL key file of the certificate
+ * Structure is [documented below](#ssl-key)
+
+The `ca_cert` block contains:
+
+* `content` - Content of the certificate file to be uploaded
+ * Content must be Base64 encoded
+ * The file size before encoding must be less than or equal to 16KB
+ * The file format before encoding must be PEM
+ * DER can be converted to PEM by using OpenSSL command
+
+The `ssl_cert` block contains:
+
+* `content` - Content of the certificate file to be uploaded
+ * Content must be Base64 encoded
+ * The file size before encoding must be less than or equal to 16KB
+ * The file format before encoding must be PEM
+ * DER can be converted to PEM by using OpenSSL command
+
+The `ssl_key` block contains:
+
+* `content` - Content of the certificate file to be uploaded
+ * Content must be Base64 encoded
+ * The file size before encoding must be less than or equal to 16KB
+ * The file format before encoding must be PEM
+ * DER can be converted to PEM by using OpenSSL command
+
+## Attributes Reference
+
+`id` is set to the ID of the certificate.
+In addition, the following attributes are exported:
+
+* `name` - Name of the certificate
+* `description` - Description of the certificate
+* `tags` - Tags of the certificate (JSON object format)
+* `tenant_id` - ID of the owner tenant of the certificate
+* `ca_cert` - CA certificate file of the certificate
+ * Structure is [documented below](#ca-cert)
+* `ssl_cert` - SSL certificate file of the certificate
+ * Structure is [documented below](#ssl-cert)
+* `ssl_key` - SSL key file of the certificate
+ * Structure is [documented below](#ssl-key)
+
+The `ca_cert` block contains:
+
+* `content` - Content of the certificate file
+
+The `ssl_cert` block contains:
+
+* `content` - Content of the certificate file
+
+The `ssl_key` block contains:
+
+* `content` - Content of the certificate file
diff --git a/website/docs/r/mlb_health_monitor_v1.html.markdown b/website/docs/r/mlb_health_monitor_v1.html.markdown
new file mode 100644
index 00000000..11fe62fa
--- /dev/null
+++ b/website/docs/r/mlb_health_monitor_v1.html.markdown
@@ -0,0 +1,97 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_health_monitor_v1"
+sidebar_current: "docs-ecl-resource-mlb-health-monitor-v1"
+description: |-
+ Manages a health monitor within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_health\_monitor\_v1
+
+Manages a health monitor within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a health monitor to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ name = "health_monitor"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ port = 80
+ protocol = "http"
+ interval = 5
+ retry = 3
+ timeout = 5
+ path = "/health"
+ http_status_code = "200-299"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the health monitor
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the health monitor
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the health monitor
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `port` - Port number of the health monitor for healthchecking
+ * If 'protocol' is 'icmp', value must be set `0`
+* `protocol` - Protocol of the health monitor for healthchecking
+ * Must be one of these values:
+ * `"icmp"`
+ * `"tcp"`
+ * `"http"`
+ * `"https"`
+* `interval` - (Optional) Interval of healthchecking (in seconds)
+* `retry` - (Optional) Retry count of healthchecking
+ * Initial monitoring is not included
+ * Retry is executed at the interval set in `interval`
+* `timeout` - (Optional) Timeout of healthchecking (in seconds)
+ * Value must be less than or equal to `interval`
+* `path` - (Optional) URL path of healthchecking
+ * If `protocol` is `"http"` or `"https"`, URL path can be set
+ * If `protocol` is neither `"http"` nor `"https"`, URL path must not be set
+ * Must be started with /
+* `http_status_code` - (Optional) HTTP status codes expected in healthchecking
+ * If `protocol` is `"http"` or `"https"`, HTTP status code (or range) can be set
+ * If `protocol` is neither `"http"` nor `"https"`, HTTP status code (or range) must not be set
+ * Format: `"xxx"` or `"xxx-xxx"` ( `xxx` between [100, 599])
+* `load_balancer_id` - ID of the load balancer which the health monitor belongs to
+
+## Attributes Reference
+
+`id` is set to the ID of the health monitor.
+In addition, the following attributes are exported:
+
+* `name` - Name of the health monitor
+* `description` - Description of the health monitor
+* `tags` - Tags of the health monitor (JSON object format)
+* `port` - Port number of the health monitor for healthchecking
+ * If `protocol` is `"icmp"`, returns `0`
+* `protocol` - Protocol of the health monitor for healthchecking
+* `interval` - Interval of healthchecking (in seconds)
+* `retry` - Retry count of healthchecking
+ * Initial monitoring is not included
+ * Retry is executed at the interval set in `interval`
+* `timeout` - Timeout of healthchecking (in seconds)
+* `path` - URL path of healthchecking
+ * If `protocol` is `"http"` or `"https"`, uses this parameter
+* `http_status_code` - HTTP status codes expected in healthchecking
+ * If `protocol` is `"http"` or `"https"`, uses this parameter
+ * Format: `"xxx"` or `"xxx-xxx"` ( `xxx` between [100, 599])
+* `load_balancer_id` - ID of the load balancer which the health monitor belongs to
+* `tenant_id` - ID of the owner tenant of the health monitor
diff --git a/website/docs/r/mlb_listener_v1.html.markdown b/website/docs/r/mlb_listener_v1.html.markdown
new file mode 100644
index 00000000..2ae5f709
--- /dev/null
+++ b/website/docs/r/mlb_listener_v1.html.markdown
@@ -0,0 +1,73 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_listener_v1"
+sidebar_current: "docs-ecl-resource-mlb-listener-v1"
+description: |-
+ Manages a listener within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_listener\_v1
+
+Manages a listener within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a listener to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_listener_v1" "listener" {
+ name = "listener"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ ip_address = "10.0.0.1"
+ port = 443
+ protocol = "https"
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the listener
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the listener
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the listener
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `ip_address` - IP address of the listener for listening
+ * Set an unique combination of IP address and port in all listeners which belong to the same load balancer
+ * Must not set a IP address which is included in `virtual_ip_address` and `reserved_fixed_ips` of load balancer interfaces that the listener belongs to
+ * Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
+* `port` - Port number of the listener for listening
+ * Combination of IP address and port must be unique for all listeners which belong to the same load balancer
+* `protocol` - Protocol of the listener for listening
+ * Must be one of these values:
+ * `"tcp"`
+ * `"udp"`
+ * `"http"`
+ * `"https"`
+* `load_balancer_id` - ID of the load balancer which the listener belongs to
+
+## Attributes Reference
+
+`id` is set to the ID of the listener.
+In addition, the following attributes are exported:
+
+* `name` - Name of the listener
+* `description` - Description of the listener
+* `tags` - Tags of the listener (JSON object format)
+* `ip_address` - IP address of the listener for listening
+* `port` - Port number of the listener for listening
+* `protocol` - Protocol of the listener for listening
+* `load_balancer_id` - ID of the load balancer which the listener belongs to
+* `tenant_id` - ID of the owner tenant of the listener
diff --git a/website/docs/r/mlb_load_balancer_action_v1.html.markdown b/website/docs/r/mlb_load_balancer_action_v1.html.markdown
new file mode 100644
index 00000000..47842d38
--- /dev/null
+++ b/website/docs/r/mlb_load_balancer_action_v1.html.markdown
@@ -0,0 +1,66 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_load_balancer_action_v1"
+sidebar_current: "docs-ecl-resource-mlb-load-balancer-action-v1"
+description: |-
+ Performs action on a Enterprise Cloud Managed Load Balancer instance.
+---
+
+# ecl\_mlb\_load\_balancer\_action\_v1
+
+Performs action on a Enterprise Cloud Managed Load Balancer instance.
+
+~> **Notice** The load balancer and related resources must be configured in another tf file before applying `ecl_mlb_load_balancer_action_v1` . Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "null_resource" "always_run" {
+ triggers = {
+ timestamp = "${timestamp()}"
+ }
+}
+
+data "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer"
+}
+
+data "ecl_mlb_system_update_v1" "security_update_202210" {
+ name = "security_update_202210"
+}
+
+resource "ecl_mlb_load_balancer_action_v1" "load_balancer_action" {
+ load_balancer_id = data.ecl_mlb_load_balancer_v1.load_balancer.id
+ apply_configurations = true
+ system_update = {
+ system_update_id = data.ecl_mlb_system_update_v1.security_update_202210.id
+ }
+ lifecycle {
+ replace_triggered_by = [
+ null_resource.always_run
+ ]
+ }
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `load_balancer_id` - ID of the load balancer to perform action
+* `apply_configurations` - (Optional) Whether to apply added or changed configurations of the load balancer and related resources
+* `system_update` - (Optional) Whether to apply the system update to the load balancer
+ * Structure is [documented below](#system-update)
+
+The `system_update` block contains:
+
+* `system_update_id` - ID of the system update that will be applied to the load balancer
+
+## Attributes Reference
+
+`id` is set to the ID of the load balancer.
+In addition, the following attributes are exported:
+
+* `load_balancer_id` - See argument reference above.
+* `apply_configurations` - See argument reference above.
+* `system_update` - See argument reference above.
diff --git a/website/docs/r/mlb_load_balancer_v1.html.markdown b/website/docs/r/mlb_load_balancer_v1.html.markdown
new file mode 100644
index 00000000..67224de1
--- /dev/null
+++ b/website/docs/r/mlb_load_balancer_v1.html.markdown
@@ -0,0 +1,159 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_load_balancer_v1"
+sidebar_current: "docs-ecl-resource-mlb-load-balancer-v1"
+description: |-
+ Manages a load balancer within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_load\_balancer\_v1
+
+Manages a load balancer within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a load balancer to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+data "ecl_mlb_plan_v1" "ha_50m_4if" {
+ name = "50M_HA_4IF"
+}
+
+resource "ecl_network_network_v2" "network" {
+ # ~ snip ~
+}
+
+resource "ecl_network_subnet_v2" "subnet" {
+ network_id = ecl_network_network_v2.network.id
+ cidr = "192.168.0.0/24"
+}
+
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ name = "load_balancer"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ plan_id = data.ecl_mlb_plan_v1.ha_50m_4if.id
+ syslog_servers {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 15)
+ port = 514
+ protocol = "udp"
+ }
+ interfaces {
+ network_id = ecl_network_network_v2.network.id
+ virtual_ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 10)
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 11)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 12)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 13)
+ }
+ reserved_fixed_ips {
+ ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 14)
+ }
+ }
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the load balancer
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the load balancer
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the load balancer
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `plan_id` - ID of the plan
+* `syslog_servers` - (Optional) Syslog servers to which access logs are transferred
+ * The facility code of syslog is 0 (kern), and the severity level is 6 (info)
+ * Only access logs to listeners which `protocol` is either `"http"` or `"https"` are transferred
+ * If `protocol` of `syslog_servers` is `"tcp"`
+ * Access logs are transferred to all healthy syslog servers set in `syslog_servers`
+ * If `protocol` of `syslog_servers` is `"udp"`
+ * Access logs are transferred to the syslog server set first in `syslog_servers` as long as it is healthy
+ * Access logs are transferred to the syslog server set second (last) in `syslog_servers` if the first syslog server is not healthy
+ * Structure is [documented below](#syslog-servers)
+* `interfaces` - Interfaces that attached to the load balancer
+ * `virtual_ip_address` and `reserved_fixed_ips` can not be changed once attached
+ * To change `virtual_ip_address` and `reserved_fixed_ips` , recreating the interface is needed
+ * Structure is [documented below](#interfaces)
+
+The `syslog_servers` block contains:
+
+* `ip_address` - IP address of the syslog server
+ * The load balancer sends ICMP to this IP address for health check purpose
+* `port` - (Optional) Port number of the syslog server
+* `protocol` - (Optional) Protocol of the syslog server
+ * Set same protocol in all syslog servers which belong to the same load balancer
+
+The `interfaces` block contains:
+
+* `network_id` - ID of the network that this interface belongs to
+ * Set a unique network ID in `interfaces`
+ * Set a network of which plane is data
+ * Must not set ID of a network that uses ISP shared address (RFC 6598)
+* `virtual_ip_address` - Virtual IP address of the interface within subnet
+ * Do not use this IP address at the interface of other devices, allowed address pairs, etc
+ * Set an unique IP address in `virtual_ip_address` and `reserved_fixed_ips`
+ * Set a network IP address and broadcast IP address
+ * Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
+* `reserved_fixed_ips` - IP addresses that are pre-reserved for applying configurations of load balancer to be performed without losing redundancy
+ * Structure is [documented below](#reserved-fixed-ips)
+
+The `reserved_fixed_ips` block contains:
+
+* `ip_address` - The IP address assign to this interface within subnet
+ * Do not use this IP address at the interface of other devices, allowed address pairs, etc
+ * Set an unique IP address in `virtual_ip_address` and `reserved_fixed_ips`
+ * Must not set a network IP address and broadcast IP address
+ * Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
+
+## Attributes Reference
+
+`id` is set to the ID of the load balancer.
+In addition, the following attributes are exported:
+
+* `name` - Name of the load balancer
+* `description` - Description of the load balancer
+* `tags` - Tags of the load balancer (JSON object format)
+* `plan_id` - ID of the plan
+* `tenant_id` - ID of the owner tenant of the load balancer
+* `syslog_servers` - Syslog servers to which access logs are transferred
+ * The facility code of syslog is 0 (kern), and the severity level is 6 (info)
+ * Only access logs to listeners which `protocol` is either `"http"` or `"https"` are transferred
+ * If `protocol` of `syslog_servers` is `"tcp"`
+ * Access logs are transferred to all healthy syslog servers set in `syslog_servers`
+ * If `protocol` of `syslog_servers` is `"udp"`
+ * Access logs are transferred to the syslog server set first in `syslog_servers` as long as it is healthy
+ * Access logs are transferred to the syslog server set second (last) in `syslog_servers` if the first syslog server is not healthy
+ * Structure is [documented below](#syslog-servers)
+* `interfaces` - Interfaces that attached to the load balancer
+ * Structure is [documented below](#interfaces)
+
+The `syslog_servers` block contains:
+
+* `ip_address` - IP address of the syslog server
+ * The load balancer sends ICMP to this IP address for health check purpose
+* `port` - Port number of the syslog server
+* `protocol` - Protocol of the syslog server
+
+The `interfaces` block contains:
+
+* `network_id` - ID of the network that this interface belongs to
+* `virtual_ip_address` - Virtual IP address of the interface within subnet
+ * Do not use this IP address at the interface of other devices, allowed address pairs, etc
+* `reserved_fixed_ips` - IP addresses that are pre-reserved for applying configurations of load balancer to be performed without losing redundancy
+ * Structure is [documented below](#reserved-fixed-ips)
+
+The `reserved_fixed_ips` block contains:
+
+* `ip_address` - The IP address assign to this interface within subnet
+ * Do not use this IP address at the interface of other devices, allowed address pairs, etc
diff --git a/website/docs/r/mlb_policy_v1.html.markdown b/website/docs/r/mlb_policy_v1.html.markdown
new file mode 100644
index 00000000..2178cff0
--- /dev/null
+++ b/website/docs/r/mlb_policy_v1.html.markdown
@@ -0,0 +1,153 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_policy_v1"
+sidebar_current: "docs-ecl-resource-mlb-policy-v1"
+description: |-
+ Manages a policy within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_policy\_v1
+
+Manages a policy within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a policy to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+data "ecl_mlb_tls_policy_v1" "tlsv1_2_202210_01" {
+ name = "TLSv1.2_202210_01"
+}
+
+resource "ecl_mlb_certificate_v1" "certificate" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_health_monitor_v1" "health_monitor" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_listener_v1" "listener" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_target_group_v1" "target_group" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_policy_v1" "policy" {
+ name = "policy"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ algorithm = "round-robin"
+ persistence = "cookie"
+ idle_timeout = 600
+ sorry_page_url = "https://example.com/sorry"
+ source_nat = "enable"
+ certificate_id = ecl_mlb_certificate_v1.certificate.id
+ health_monitor_id = ecl_mlb_health_monitor_v1.health_monitor.id
+ listener_id = ecl_mlb_listener_v1.listener.id
+ default_target_group_id = ecl_mlb_target_group_v1.target_group.id
+ tls_policy_id = data.ecl_mlb_tls_policy_v1.tlsv1_2_202210_01.id
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the policy
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the policy
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the policy
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `algorithm` - (Optional) Load balancing algorithm (method) of the policy
+ * Must be one of these values:
+ * `"round-robin"`
+ * `"weighted-round-robin"`
+ * `"least-connection"`
+ * `"weighted-least-connection"`
+ * `"source-ip-port-hash"`
+* `persistence` - (Optional) Persistence setting of the policy
+ * If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available
+ * Must be one of these values:
+ * `"none"`
+ * `"source-ip"`
+ * `"cookie"`
+* `idle_timeout` - (Optional) The duration (in seconds) during which a session is allowed to remain inactive
+ * There may be a time difference up to 60 seconds, between the set value and the actual timeout
+ * If `listener.protocol` is `"tcp"` or `"udp"`
+ * Default value is 120
+ * If `listener.protocol` is `"http"` or `"https"`
+ * Default value is 600
+ * On session timeout, the load balancer sends TCP RST packets to both the client and the real server
+* `sorry_page_url` - (Optional) URL of the sorry page to which accesses are redirected if all members in the target group are down
+ * If `listener.protocol` is `"http"` or `"https"`, this parameter can be set
+ * If `listener.protocol` is neither `"http"` nor `"https"`, must not set this parameter or set `""`
+* `source_nat` - (Optional) Source NAT setting of the policy
+ * If `source_nat` is `"enable"` and `listener.protocol` is `"http"` or `"https"`
+ * The source IP address of the request is replaced with `virtual_ip_address` which is assigned to the interface from which the request was sent
+ * `X-Forwarded-For` header with the IP address of the client is added
+ * Must be one of these values:
+ * `"enable"`
+ * `"disable"`
+* `certificate_id` - (Optional) ID of the certificate that assigned to the policy
+ * You can set a ID of the certificate in which `ca_cert.status`, `ssl_cert.status` and `ssl_key.status` are all `"UPLOADED"`
+ * If `listener.protocol` is `"https"`, set `certificate.id`
+ * If `listener.protocol` is not `"https"`, must not set this parameter or set `""`
+* `health_monitor_id` - ID of the health monitor that assigned to the policy
+ * Must not set ID of the health monitor that `configuration_status` is `"DELETE_STAGED"`
+* `listener_id` - ID of the listener that assigned to the policy
+ * Must not set ID of the listener that `configuration_status` is `"DELETE_STAGED"`
+ * Must not set ID of the listener that already assigned to the other policy
+* `default_target_group_id` - ID of the default target group that assigned to the policy
+ * Must not set ID of the target group that `configuration_status` is `"DELETE_STAGED"`
+* `tls_policy_id` - (Optional) ID of the TLS policy that assigned to the policy
+ * If `listener.protocol` is `"https"`, you can set this parameter explicitly
+ * If not set this parameter, the ID of the `tls_policy` with `default: true` will be automatically set
+ * If `listener.protocol` is not `"https"`, must not set this parameter or set `""`
+* `load_balancer_id` - ID of the load balancer which the policy belongs to
+
+## Attributes Reference
+
+`id` is set to the ID of the policy.
+In addition, the following attributes are exported:
+
+* `name` - Name of the policy
+* `description` - Description of the policy
+* `tags` - Tags of the policy (JSON object format)
+* `algorithm` - Load balancing algorithm (method) of the policy
+* `persistence` - Persistence setting of the policy
+ * If `listener.protocol` is `"http"` or `"https"`, `"cookie"` is available
+* `idle_timeout` - The duration (in seconds) during which a session is allowed to remain inactive
+ * There may be a time difference up to 60 seconds, between the set value and the actual timeout
+ * If `listener.protocol` is `"tcp"` or `"udp"`
+ * Default value is 120
+ * If `listener.protocol` is `"http"` or `"https"`
+ * Default value is 600
+ * On session timeout, the load balancer sends TCP RST packets to both the client and the real server
+* `sorry_page_url` - URL of the sorry page to which accesses are redirected if all members in the target group are down
+ * If protocol is not `"http"` or `"https"`, returns `""`
+* `source_nat` - Source NAT setting of the policy
+ * If `source_nat` is `"enable"` and `listener.protocol` is `"http"` or `"https"` ,
+ * The source IP address of the request is replaced with `virtual_ip_address` which is assigned to the interface from which the request was sent
+ * `X-Forwarded-For` header with the IP address of the client is added
+* `certificate_id` - ID of the certificate that assigned to the policy
+ * If protocol is not `"https"`, returns `""`
+* `health_monitor_id` - ID of the health monitor that assigned to the policy
+* `listener_id` - ID of the listener that assigned to the policy
+* `default_target_group_id` - ID of the default target group that assigned to the policy
+* `tls_policy_id` - ID of the TLS policy that assigned to the policy
+ * If protocol is not `"https"`, returns `""`
+* `load_balancer_id` - ID of the load balancer which the policy belongs to
+* `tenant_id` - ID of the owner tenant of the policy
diff --git a/website/docs/r/mlb_route_v1.html.markdown b/website/docs/r/mlb_route_v1.html.markdown
new file mode 100644
index 00000000..a840da1f
--- /dev/null
+++ b/website/docs/r/mlb_route_v1.html.markdown
@@ -0,0 +1,78 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_route_v1"
+sidebar_current: "docs-ecl-resource-mlb-route-v1"
+description: |-
+ Manages a route within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_route\_v1
+
+Manages a route within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a route to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_network_network_v2" "network" {
+ # ~ snip ~
+}
+
+resource "ecl_network_subnet_v2" "subnet" {
+ network_id = ecl_network_network_v2.network.id
+ cidr = "192.168.0.0/24"
+}
+
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_route_v1" "route" {
+ name = "route"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ destination_cidr = "172.16.0.0/24"
+ next_hop_ip_address = cidrhost(ecl_network_subnet_v2.subnet.cidr, 254)
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the (static) route
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the (static) route
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the (static) route
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `destination_cidr` - CIDR of destination for the (static) route
+ * If you configure `destination_cidr` as default gateway, set `0.0.0.0/0`
+ * `destination_cidr` can not be changed once configured
+ * If you want to change `destination_cidr`, recreate the (static) route again
+ * Set a unique CIDR for all (static) routes which belong to the same load balancer
+ * Set a CIDR which is not included in subnet of load balancer interfaces that the (static) route belongs to
+ * Must not set a link-local CIDR (RFC 3927) which includes Common Function Gateway
+* `next_hop_ip_address` - ID of the load balancer which the (static) route belongs to
+ * Set a CIDR which is not included in subnet of load balancer interfaces that the (static) route belongs to
+ * Must not set a network IP address and broadcast IP address
+* `load_balancer_id` - ID of the load balancer which the (static) route belongs to
+
+## Attributes Reference
+
+`id` is set to the ID of the route.
+In addition, the following attributes are exported:
+
+* `name` - Name of the (static) route
+* `description` - Description of the (static) route
+* `tags` - Tags of the (static) route (JSON object format)
+* `destination_cidr` - CIDR of destination for the (static) route
+* `next_hop_ip_address` - IP address of next hop for the (static) route
+* `load_balancer_id` - ID of the load balancer which the (static) route belongs to
+* `tenant_id` - ID of the owner tenant of the (static) route
diff --git a/website/docs/r/mlb_rule_v1.html.markdown b/website/docs/r/mlb_rule_v1.html.markdown
new file mode 100644
index 00000000..df2fa88a
--- /dev/null
+++ b/website/docs/r/mlb_rule_v1.html.markdown
@@ -0,0 +1,88 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_rule_v1"
+sidebar_current: "docs-ecl-resource-mlb-rule-v1"
+description: |-
+ Manages a rule within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_rule\_v1
+
+Manages a rule within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a rule to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_mlb_target_group_v1" "target_group" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_policy_v1" "policy" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_rule_v1" "rule" {
+ name = "rule"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ priority = 1
+ target_group_id = ecl_mlb_target_group_v1.target_group.id
+ policy_id = ecl_mlb_policy_v1.policy.id
+ conditions {
+ path_patterns = ["^/statics/"]
+ }
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the rule
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the rule
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the rule
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `priority` - (Optional) Priority of the rule
+ * Set an unique number in all rules which belong to the same policy
+* `target_group_id` - ID of the target group that assigned to the rule
+ * Set a different target group from `"default_target_group_id"` of the policy
+* `policy_id` - ID of the policy which the rule belongs to
+ * Set ID of the policy which has a listener in which protocol is either `"http"` or `"https"`
+* `conditions` - Conditions of the rules to distribute accesses to the target groups
+ * Set one or more condition
+ * Structure is [documented below](#conditions)
+
+The `conditions` block contains:
+
+* `path_patterns` - (Optional) URL path patterns (regular expressions) of the condition
+ * Set a path pattern as unique string in all path patterns which belong to the same policy
+ * Set a path pattern in PCRE (Perl Compatible Regular Expressions) format
+ * Capturing groups and backreferences are not supported
+
+## Attributes Reference
+
+`id` is set to the ID of the rule.
+In addition, the following attributes are exported:
+
+* `name` - Name of the rule
+* `description` - Description of the rule
+* `tags` - Tags of the rule (JSON object format)
+* `priority` - Priority of the rule
+* `target_group_id` - ID of the target group that assigned to the rule
+* `policy_id` - ID of the policy which the rule belongs to
+* `load_balancer_id` - ID of the load balancer which the rule belongs to
+* `tenant_id` - ID of the owner tenant of the rule
+* `conditions` - Conditions of the rules to distribute accesses to the target groups
+ * Structure is [documented below](#conditions)
+
+The `conditions` block contains:
+
+* `path_patterns` - URL path patterns (regular expressions) of the condition
diff --git a/website/docs/r/mlb_target_group_v1.html.markdown b/website/docs/r/mlb_target_group_v1.html.markdown
new file mode 100644
index 00000000..7059bddb
--- /dev/null
+++ b/website/docs/r/mlb_target_group_v1.html.markdown
@@ -0,0 +1,84 @@
+---
+layout: "ecl"
+page_title: "Enterprise Cloud: ecl_mlb_target_group_v1"
+sidebar_current: "docs-ecl-resource-mlb-target-group-v1"
+description: |-
+ Manages a target group within Enterprise Cloud Managed Load Balancer.
+---
+
+# ecl\_mlb\_target\_group\_v1
+
+Manages a target group within Enterprise Cloud Managed Load Balancer.
+
+-> **Note** Apply changes of a target group to the Managed Load Balancer instance using [ecl_mlb_load_balancer_action_v1](./mlb_load_balancer_action_v1) in another tf file. Please refer to [examples](https://github.com/nttcom/terraform-provider-ecl/tree/master/examples/managed-load-balancer) .
+
+## Example Usage
+
+```hcl
+resource "ecl_mlb_load_balancer_v1" "load_balancer" {
+ # ~ snip ~
+}
+
+resource "ecl_mlb_target_group_v1" "target_group" {
+ name = "target_group"
+ description = "description"
+ tags = {
+ key = "value"
+ }
+ load_balancer_id = ecl_mlb_load_balancer_v1.load_balancer.id
+ members {
+ ip_address = "192.168.0.7"
+ port = 80
+ weight = 1
+ }
+}
+```
+
+## Argument Reference
+
+The following arguments are supported:
+
+* `name` - (Optional) Name of the target group
+ * This field accepts single-byte characters only
+* `description` - (Optional) Description of the target group
+ * This field accepts single-byte characters only
+* `tags` - (Optional) Tags of the target group
+ * Set JSON object up to 32,768 characters
+ * Nested structure is permitted
+ * This field accepts single-byte characters only
+* `load_balancer_id` - ID of the load balancer which the target group belongs to
+* `members` - Members (real servers) of the target group
+ * Structure is [documented below](#members)
+
+The `members` block contains:
+
+* `ip_address` - IP address of the member (real server)
+ * Set an unique combination of IP address and port in all members which belong to the same target group
+ * Must not set a IP address which is included in `virtual_ip_address` and `reserved_fixed_ips` of load balancer interfaces that the target group belongs to
+ * Must not set a IP address of listeners which belong to the same load balancer as the target group
+ * Must not set a link-local IP address (RFC 3927) which includes Common Function Gateway
+* `port` - Port number of the member (real server)
+ * Set an unique combination of IP address and port in all members which belong to the same target group
+* `weight` - (Optional) Weight for the member (real server)
+ * If `policy.algorithm` is `"weighted-round-robin"` or `"weighted-least-connection"`, use this parameter
+ * Set same weight for the combination of IP address and port in all members which belong to the same load balancer
+
+## Attributes Reference
+
+`id` is set to the ID of the target group.
+In addition, the following attributes are exported:
+
+* `name` - Name of the target group
+* `description` - Description of the target group
+* `tags` - Tags of the target group (JSON object format)
+* `load_balancer_id` - ID of the load balancer which the target group belongs to
+* `tenant_id` - ID of the owner tenant of the target group
+* `members` - Members (real servers) of the target group
+ * Structure is [documented below](#members)
+
+The `members` block contains:
+
+* `ip_address` - IP address of the member (real server)
+* `port` - Port number of the member (real server)
+* `weight` - Weight for the member (real server)
+ * If `policy.algorithm` is `"weighted-round-robin"` or `"weighted-least-connection"`, uses this parameter