Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eventhub property skip empty archives #3074

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions azurerm/resource_arm_eventhub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions azurerm/resource_arm_eventhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/eventhub.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down