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

azurerm_media_live_event_output - support for rewind_window_duration property #20271

Merged
merged 2 commits into from
Feb 6, 2023
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
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
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