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..2f394c50ede2 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), } @@ -323,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) 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" { diff --git a/website/docs/d/eventhub_namespace.html.markdown b/website/docs/d/eventhub_namespace.html.markdown index f62ee07863b9..651acb36c253 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` - Is this EventHub Namespace deployed across 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..2c54bef9b0eb 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) Specifies if the EventHub Namespace should be Zone Redundant (created across Availability Zones). + * `tags` - (Optional) A mapping of tags to assign to the resource. * `network_rulesets` - (Optional) A `network_rulesets` block as defined below.