diff --git a/azurerm/resource_arm_eventhub.go b/azurerm/resource_arm_eventhub.go index 68b1778c71b0..44f87caac8a1 100644 --- a/azurerm/resource_arm_eventhub.go +++ b/azurerm/resource_arm_eventhub.go @@ -68,6 +68,11 @@ func resourceArmEventHub() *schema.Resource { Type: schema.TypeBool, Required: true, }, + "skip_empty_archives": { + Type: schema.TypeBool, + Optional: true, + Default: false, + }, "encoding": { Type: schema.TypeString, Required: true, @@ -310,12 +315,14 @@ func expandEventHubCaptureDescription(d *schema.ResourceData) (*eventhub.Capture encoding := input["encoding"].(string) intervalInSeconds := input["interval_in_seconds"].(int) sizeLimitInBytes := input["size_limit_in_bytes"].(int) + skipEmptyArchives := input["skip_empty_archives"].(bool) captureDescription := eventhub.CaptureDescription{ Enabled: utils.Bool(enabled), Encoding: eventhub.EncodingCaptureDescription(encoding), IntervalInSeconds: utils.Int32(int32(intervalInSeconds)), SizeLimitInBytes: utils.Int32(int32(sizeLimitInBytes)), + SkipEmptyArchives: utils.Bool(skipEmptyArchives), } if v, ok := input["destination"]; ok { @@ -352,6 +359,10 @@ func flattenEventHubCaptureDescription(description *eventhub.CaptureDescription) output["enabled"] = *enabled } + if skipEmptyArchives := description.SkipEmptyArchives; skipEmptyArchives != nil { + output["skip_empty_archives"] = *skipEmptyArchives + } + output["encoding"] = string(description.Encoding) if interval := description.IntervalInSeconds; interval != nil { diff --git a/azurerm/resource_arm_eventhub_test.go b/azurerm/resource_arm_eventhub_test.go index 2c281135fa7b..69284ff1f35a 100644 --- a/azurerm/resource_arm_eventhub_test.go +++ b/azurerm/resource_arm_eventhub_test.go @@ -287,6 +287,7 @@ func TestAccAzureRMEventHub_captureDescription(t *testing.T) { Check: resource.ComposeTestCheckFunc( testCheckAzureRMEventHubExists(resourceName), resource.TestCheckResourceAttr(resourceName, "capture_description.0.enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "capture_description.0.skip_empty_archives", "true"), ), }, { @@ -546,6 +547,7 @@ resource "azurerm_eventhub" "test" { encoding = "Avro" interval_in_seconds = 60 size_limit_in_bytes = 10485760 + skip_empty_archives = true destination { name = "EventHubArchive.AzureBlockBlob" diff --git a/website/docs/r/eventhub.html.markdown b/website/docs/r/eventhub.html.markdown index 402d5b5dd2fd..a05226d3bc9d 100644 --- a/website/docs/r/eventhub.html.markdown +++ b/website/docs/r/eventhub.html.markdown @@ -68,6 +68,8 @@ A `capture_description` block supports the following: * `size_limit_in_bytes` - (Optional) Specifies the amount of data built up in your EventHub before a Capture Operation occurs. Value should be between `10485760` and `524288000` bytes. Defaults to `314572800` bytes. +* `skip_empty_archives` - (Optional) Specifies if empty files should not be emitted if no events occur during the Capture time window. Defaults to `false`. + * `destination` - (Required) A `destination` block as defined below. A `destination` block supports the following: