From 28bfd04fd19e0637c889989298ec984c4e83b4c5 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Tue, 30 Jun 2020 10:51:21 +0200 Subject: [PATCH 1/6] Update eventhub_namespace for `ZoneRedundant` property Adds `zone_redundant` property to `eventhub_namespace` resource and datasource. Fixes #4872 --- .../services/eventhub/eventhub_namespace_data_source.go | 6 ++++++ .../services/eventhub/eventhub_namespace_resource.go | 8 ++++++++ website/docs/d/eventhub_namespace.html.markdown | 2 ++ website/docs/r/eventhub_namespace.html.markdown | 2 ++ 4 files changed, 18 insertions(+) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_data_source.go b/azurerm/internal/services/eventhub/eventhub_namespace_data_source.go index 25b198bc1cb3..408dac82c905 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_data_source.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_data_source.go @@ -48,6 +48,11 @@ func dataSourceEventHubNamespace() *schema.Resource { Computed: true, }, + "zone_redundant": { + Type: schema.TypeBool, + Computed: true, + }, + "capacity": { Type: schema.TypeInt, Computed: true, @@ -141,6 +146,7 @@ func dataSourceEventHubNamespaceRead(d *schema.ResourceData, meta interface{}) e d.Set("auto_inflate_enabled", props.IsAutoInflateEnabled) d.Set("kafka_enabled", props.KafkaEnabled) d.Set("maximum_throughput_units", int(*props.MaximumThroughputUnits)) + d.Set("zone_redundant", props.ZoneRedundant) } return tags.FlattenAndSet(d, resp.Tags) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go index 7b4be73e631f..62311c83382b 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go @@ -79,6 +79,12 @@ func resourceArmEventHubNamespace() *schema.Resource { Default: false, }, + "zone_redundant": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, + "maximum_throughput_units": { Type: schema.TypeInt, Optional: true, @@ -226,6 +232,7 @@ func resourceArmEventHubNamespaceCreateUpdate(d *schema.ResourceData, meta inter capacity := int32(d.Get("capacity").(int)) t := d.Get("tags").(map[string]interface{}) autoInflateEnabled := d.Get("auto_inflate_enabled").(bool) + zoneRedundant := d.Get("zone_redundant").(bool) parameters := eventhub.EHNamespace{ Location: &location, @@ -236,6 +243,7 @@ func resourceArmEventHubNamespaceCreateUpdate(d *schema.ResourceData, meta inter }, EHNamespaceProperties: &eventhub.EHNamespaceProperties{ IsAutoInflateEnabled: utils.Bool(autoInflateEnabled), + ZoneRedundant: utils.Bool(zoneRedundant), }, Tags: tags.Expand(t), } diff --git a/website/docs/d/eventhub_namespace.html.markdown b/website/docs/d/eventhub_namespace.html.markdown index f62ee07863b9..45f0d1022535 100644 --- a/website/docs/d/eventhub_namespace.html.markdown +++ b/website/docs/d/eventhub_namespace.html.markdown @@ -42,6 +42,8 @@ output "eventhub_namespace_id" { * `maximum_throughput_units` - Specifies the maximum number of throughput units when Auto Inflate is Enabled. +* `zone_redundant` - Enabling this property creates a Standard Event Hubs Namespace in regions supported availability zones. + * `tags` - A mapping of tags to assign to the EventHub Namespace. The following attributes are exported only if there is an authorization rule named diff --git a/website/docs/r/eventhub_namespace.html.markdown b/website/docs/r/eventhub_namespace.html.markdown index e541c6cab824..ca25d47ae823 100644 --- a/website/docs/r/eventhub_namespace.html.markdown +++ b/website/docs/r/eventhub_namespace.html.markdown @@ -49,6 +49,8 @@ The following arguments are supported: * `maximum_throughput_units` - (Optional) Specifies the maximum number of throughput units when Auto Inflate is Enabled. Valid values range from `1` - `20`. +* `zone_redundant` - (Optional) Enabling this property creates a Standard Event Hubs Namespace in regions supported availability zones. + * `tags` - (Optional) A mapping of tags to assign to the resource. * `network_rulesets` - (Optional) A `network_rulesets` block as defined below. From ceecdacd9418308097771d2bc46a1a3a86b62be9 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Tue, 30 Jun 2020 11:27:54 +0200 Subject: [PATCH 2/6] fmt --- .../internal/services/eventhub/eventhub_namespace_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go index 62311c83382b..5bdcfdd7fa51 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go @@ -243,7 +243,7 @@ func resourceArmEventHubNamespaceCreateUpdate(d *schema.ResourceData, meta inter }, EHNamespaceProperties: &eventhub.EHNamespaceProperties{ IsAutoInflateEnabled: utils.Bool(autoInflateEnabled), - ZoneRedundant: utils.Bool(zoneRedundant), + ZoneRedundant: utils.Bool(zoneRedundant), }, Tags: tags.Expand(t), } From 02d73635b87857b56bb45ddb1ebce44faf711daa Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Tue, 30 Jun 2020 11:30:44 +0200 Subject: [PATCH 3/6] Update website/docs/d/eventhub_namespace.html.markdown Co-authored-by: Tom Harvey --- website/docs/d/eventhub_namespace.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/d/eventhub_namespace.html.markdown b/website/docs/d/eventhub_namespace.html.markdown index 45f0d1022535..651acb36c253 100644 --- a/website/docs/d/eventhub_namespace.html.markdown +++ b/website/docs/d/eventhub_namespace.html.markdown @@ -42,7 +42,7 @@ output "eventhub_namespace_id" { * `maximum_throughput_units` - Specifies the maximum number of throughput units when Auto Inflate is Enabled. -* `zone_redundant` - Enabling this property creates a Standard Event Hubs Namespace in regions supported availability zones. +* `zone_redundant` - Is this EventHub Namespace deployed across Availability Zones? * `tags` - A mapping of tags to assign to the EventHub Namespace. From 61e26af8bd46c095ec861a1f7bb28a487bc97df5 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Tue, 30 Jun 2020 11:31:00 +0200 Subject: [PATCH 4/6] Update website/docs/r/eventhub_namespace.html.markdown Co-authored-by: Tom Harvey --- website/docs/r/eventhub_namespace.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/eventhub_namespace.html.markdown b/website/docs/r/eventhub_namespace.html.markdown index ca25d47ae823..2c54bef9b0eb 100644 --- a/website/docs/r/eventhub_namespace.html.markdown +++ b/website/docs/r/eventhub_namespace.html.markdown @@ -49,7 +49,7 @@ The following arguments are supported: * `maximum_throughput_units` - (Optional) Specifies the maximum number of throughput units when Auto Inflate is Enabled. Valid values range from `1` - `20`. -* `zone_redundant` - (Optional) Enabling this property creates a Standard Event Hubs Namespace in regions supported availability zones. +* `zone_redundant` - (Optional) Specifies if the EventHub Namespace should be Zone Redundant (created across Availability Zones). * `tags` - (Optional) A mapping of tags to assign to the resource. From 8434919b7caa40f60c73e1263a3c880a4beffc80 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Tue, 30 Jun 2020 11:36:25 +0200 Subject: [PATCH 5/6] Add tests --- .../tests/eventhub_namespace_resource_test.go | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/azurerm/internal/services/eventhub/tests/eventhub_namespace_resource_test.go b/azurerm/internal/services/eventhub/tests/eventhub_namespace_resource_test.go index 74e724c1dfb1..1ffa9e40cb6d 100644 --- a/azurerm/internal/services/eventhub/tests/eventhub_namespace_resource_test.go +++ b/azurerm/internal/services/eventhub/tests/eventhub_namespace_resource_test.go @@ -200,6 +200,25 @@ func TestAccAzureRMEventHubNamespace_maximumThroughputUnits(t *testing.T) { }) } +func TestAccAzureRMEventHubNamespace_zoneRedundant(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_eventhub_namespace", "test") + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { acceptance.PreCheck(t) }, + Providers: acceptance.SupportedProviders, + CheckDestroy: testCheckAzureRMEventHubNamespaceDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAzureRMEventHubNamespace_zoneRedundant(data), + Check: resource.ComposeTestCheckFunc( + testCheckAzureRMEventHubNamespaceExists(data.ResourceName), + ), + }, + data.ImportStep(), + }, + }) +} + func TestAccAzureRMEventHubNamespace_NonStandardCasing(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_eventhub_namespace", "test") @@ -704,6 +723,28 @@ resource "azurerm_eventhub_namespace" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } +func testAccAzureRMEventHubNamespace_zoneRedundant(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_eventhub_namespace" "test" { + name = "acctesteventhubnamespace-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + sku = "Standard" + capacity = "2" + zone_redundant = true +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} + func testAccAzureRMEventHubNamespace_basicWithTagsUpdate(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { From d28e4922a5added3574b99a8752e6b4604db53c8 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarenko Date: Wed, 1 Jul 2020 12:44:04 +0200 Subject: [PATCH 6/6] Set property during read too --- .../internal/services/eventhub/eventhub_namespace_resource.go | 1 + 1 file changed, 1 insertion(+) diff --git a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go index 5bdcfdd7fa51..2f394c50ede2 100644 --- a/azurerm/internal/services/eventhub/eventhub_namespace_resource.go +++ b/azurerm/internal/services/eventhub/eventhub_namespace_resource.go @@ -331,6 +331,7 @@ func resourceArmEventHubNamespaceRead(d *schema.ResourceData, meta interface{}) if props := resp.EHNamespaceProperties; props != nil { d.Set("auto_inflate_enabled", props.IsAutoInflateEnabled) d.Set("maximum_throughput_units", int(*props.MaximumThroughputUnits)) + d.Set("zone_redundant", props.ZoneRedundant) } ruleset, err := client.GetNetworkRuleSet(ctx, resGroup, name)