Skip to content

Commit

Permalink
azurerm_media_live_event_output - support for `rewind_window_durati…
Browse files Browse the repository at this point in the history
…on` property (#20271)
  • Loading branch information
teowa authored Feb 6, 2023
1 parent 28a0ef9 commit 26dd01a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
15 changes: 14 additions & 1 deletion internal/services/media/media_live_output_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/liveevents"
"github.com/hashicorp/go-azure-sdk/resource-manager/media/2022-08-01/liveoutputs"
"github.com/hashicorp/terraform-provider-azurerm/helpers/tf"
"github.com/hashicorp/terraform-provider-azurerm/helpers/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/media/migration"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
Expand Down Expand Up @@ -60,7 +61,7 @@ func resourceMediaLiveOutput() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringIsNotEmpty,
ValidateFunc: validate.ISO8601DurationBetween("PT1M", "PT25H"),
},

"asset_name": {
Expand Down Expand Up @@ -101,6 +102,13 @@ func resourceMediaLiveOutput() *pluginsdk.Resource {
ForceNew: true,
ValidateFunc: validation.IntAtLeast(0),
},

"rewind_window_duration": {
Type: pluginsdk.TypeString,
Optional: true,
ForceNew: true,
ValidateFunc: validate.ISO8601DurationBetween("PT1M", "PT25H"),
},
},
}
}
Expand Down Expand Up @@ -158,6 +166,10 @@ func resourceMediaLiveOutputCreate(d *pluginsdk.ResourceData, meta interface{})
parameters.Properties.OutputSnapTime = utils.Int64(int64(outputSnapTime.(int)))
}

if rewindWindowLength, ok := d.GetOk("rewind_window_duration"); ok {
parameters.Properties.RewindWindowLength = utils.String(rewindWindowLength.(string))
}

if err := client.CreateThenPoll(ctx, id, parameters); err != nil {
return fmt.Errorf("creating %s: %+v", id, err)
}
Expand Down Expand Up @@ -209,6 +221,7 @@ func resourceMediaLiveOutputRead(d *pluginsdk.ResourceData, meta interface{}) er
outputSnapTime = *props.OutputSnapTime
}
d.Set("output_snap_time_in_seconds", outputSnapTime)
d.Set("rewind_window_duration", props.RewindWindowLength)
}
}

Expand Down
1 change: 1 addition & 0 deletions internal/services/media/media_live_output_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ resource "azurerm_media_live_event_output" "test" {
manifest_name = "testmanifest"
output_snap_time_in_seconds = 0
hls_fragments_per_ts_segment = 5
rewind_window_duration = "PT5M"
}
`, r.template(data))
}
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/media_live_output.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ resource "azurerm_media_live_event_output" "example" {
manifest_name = "testmanifest"
output_snap_time_in_seconds = 0
hls_fragments_per_ts_segment = 5
rewind_window_duration = "PT5M"
}
```

Expand All @@ -95,6 +96,8 @@ The following arguments are supported:

* `output_snap_time_in_seconds` - (Optional) The initial timestamp that the live output will start at, any content before this value will not be archived. Changing this forces a new Live Output to be created.

* `rewind_windown_duration` - (Optional) `ISO 8601` time between 1 minute to the duration of `archive_window_duration` to control seek-able window length during Live. The service won't use this property once LiveOutput stops. The archived VOD will have full content with original ArchiveWindowLength. For example, use `PT1H30M` to indicate 1 hour and 30 minutes of rewind window length. Service will use implicit default value 30m only if Live Event enables LL. Changing this forces a new Live Output to be created.

## Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:
Expand Down

0 comments on commit 26dd01a

Please sign in to comment.