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

medialive/channel: add expand/flatten/docs for InputAttachment.AutomaticInputFailoverSettings. #33129

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
3 changes: 3 additions & 0 deletions .changelog/33129.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_medialive_channel: Implement expand/flatten functions for `automatic_input_failover_settings` in `input_attachments`
```
214 changes: 211 additions & 3 deletions internal/service/medialive/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,9 @@ func expandChannelInputAttachments(tfList []interface{}) []types.InputAttachment
if v, ok := m["input_settings"].([]interface{}); ok && len(v) > 0 {
a.InputSettings = expandInputAttachmentInputSettings(v)
}
if v, ok := m["automatic_input_failover_settings"].([]interface{}); ok && len(v) > 0 {
a.AutomaticInputFailoverSettings = expandInputAttachmentAutomaticInputFailoverSettings(v)
}

attachments = append(attachments, a)
}
Expand Down Expand Up @@ -1602,6 +1605,125 @@ func expandNetworkInputSettingsHLSInputSettings(tfList []interface{}) *types.Hls
return &out
}

func expandInputAttachmentAutomaticInputFailoverSettings(tfList []interface{}) *types.AutomaticInputFailoverSettings {
if tfList == nil {
return nil
}

m := tfList[0].(map[string]interface{})

var out types.AutomaticInputFailoverSettings
if v, ok := m["secondary_input_id"].(string); ok && v != "" {
out.SecondaryInputId = aws.String(v)
}
if v, ok := m["error_clear_time_msec"].(int); ok {
out.ErrorClearTimeMsec = int32(v)
}
if v, ok := m["failover_conditions"].(*schema.Set); ok && v.Len() > 0 {
out.FailoverConditions = expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditions(v.List())
}
if v, ok := m["input_preference"].(string); ok && v != "" {
out.InputPreference = types.InputPreference(v)
}

return &out
}

func expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditions(tfList []interface{}) []types.FailoverCondition {
if len(tfList) == 0 {
return nil
}

var out []types.FailoverCondition
for _, v := range tfList {
m, ok := v.(map[string]interface{})
if !ok {
continue
}

var o types.FailoverCondition
if v, ok := m["failover_condition_settings"].([]interface{}); ok && len(v) > 0 {
o.FailoverConditionSettings = expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettings(v)
}

out = append(out, o)
}

return out
}

func expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettings(tfList []interface{}) *types.FailoverConditionSettings {
if tfList == nil {
return nil
}

m := tfList[0].(map[string]interface{})

var out types.FailoverConditionSettings
if v, ok := m["audio_silence_settings"].([]interface{}); ok && len(v) > 0 {
out.AudioSilenceSettings = expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsAudioSilenceSettings(v)
}
if v, ok := m["input_loss_settings"].([]interface{}); ok && len(v) > 0 {
out.InputLossSettings = expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsInputLossSettings(v)
}
if v, ok := m["video_black_settings"].([]interface{}); ok && len(v) > 0 {
out.VideoBlackSettings = expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsVideoBlackSettings(v)
}

return &out
}

func expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsAudioSilenceSettings(tfList []interface{}) *types.AudioSilenceFailoverSettings {
if tfList == nil {
return nil
}

m := tfList[0].(map[string]interface{})

var out types.AudioSilenceFailoverSettings
if v, ok := m["audio_selector_name"].(string); ok && v != "" {
out.AudioSelectorName = aws.String(v)
}
if v, ok := m["audio_silence_threshold_msec"].(int); ok {
out.AudioSilenceThresholdMsec = int32(v)
}

return &out
}

func expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsInputLossSettings(tfList []interface{}) *types.InputLossFailoverSettings {
if tfList == nil {
return nil
}

m := tfList[0].(map[string]interface{})

var out types.InputLossFailoverSettings
if v, ok := m["input_loss_threshold_msec"].(int); ok {
out.InputLossThresholdMsec = int32(v)
}

return &out
}

func expandInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsVideoBlackSettings(tfList []interface{}) *types.VideoBlackFailoverSettings {
if tfList == nil {
return nil
}

m := tfList[0].(map[string]interface{})

var out types.VideoBlackFailoverSettings
if v, ok := m["black_detect_threshold"].(float32); ok {
out.BlackDetectThreshold = float64(v)
}
if v, ok := m["video_black_threshold_msec"].(int); ok {
out.VideoBlackThresholdMsec = int32(v)
}

return &out
}

func flattenChannelInputAttachments(tfList []types.InputAttachment) []interface{} {
if len(tfList) == 0 {
return nil
Expand All @@ -1611,13 +1733,15 @@ func flattenChannelInputAttachments(tfList []types.InputAttachment) []interface{

for _, item := range tfList {
m := map[string]interface{}{
"input_id": aws.ToString(item.InputId),
"input_attachment_name": aws.ToString(item.InputAttachmentName),
"input_settings": flattenInputAttachmentsInputSettings(item.InputSettings),
"input_id": aws.ToString(item.InputId),
"input_attachment_name": aws.ToString(item.InputAttachmentName),
"input_settings": flattenInputAttachmentsInputSettings(item.InputSettings),
"automatic_input_failover_settings": flattenInputAttachmentAutomaticInputFailoverSettings(item.AutomaticInputFailoverSettings),
}

out = append(out, m)
}

return out
}

Expand Down Expand Up @@ -1917,6 +2041,90 @@ func flattenNetworkInputSettingsHLSInputSettings(in *types.HlsInputSettings) []i
return []interface{}{m}
}

func flattenInputAttachmentAutomaticInputFailoverSettings(in *types.AutomaticInputFailoverSettings) []interface{} {
if in == nil {
return nil
}

m := map[string]interface{}{
"secondary_input_id": aws.ToString(in.SecondaryInputId),
"error_clear_time_msec": int(in.ErrorClearTimeMsec),
"failover_conditions": flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditions(in.FailoverConditions),
"input_preference": string(in.InputPreference),
}

return []interface{}{m}
}

func flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditions(tfList []types.FailoverCondition) []interface{} {
if len(tfList) == 0 {
return nil
}

var out []interface{}

for _, item := range tfList {
m := map[string]interface{}{
"failover_condition_settings": flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettings(item.FailoverConditionSettings),
}

out = append(out, m)
}
return out
}

func flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettings(in *types.FailoverConditionSettings) []interface{} {
if in == nil {
return nil
}

m := map[string]interface{}{
"audio_silence_settings": flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsAudioSilenceSettings(in.AudioSilenceSettings),
"input_loss_settings": flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsInputLossSettings(in.InputLossSettings),
"video_black_settings": flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsVideoBlackSettings(in.VideoBlackSettings),
}

return []interface{}{m}
}

func flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsAudioSilenceSettings(in *types.AudioSilenceFailoverSettings) []interface{} {
if in == nil {
return nil
}

m := map[string]interface{}{
"audio_selector_name": aws.ToString(in.AudioSelectorName),
"audio_silence_threshold_msec": int(in.AudioSilenceThresholdMsec),
}

return []interface{}{m}
}

func flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsInputLossSettings(in *types.InputLossFailoverSettings) []interface{} {
if in == nil {
return nil
}

m := map[string]interface{}{
"input_loss_threshold_msec": int(in.InputLossThresholdMsec),
}

return []interface{}{m}
}

func flattenInputAttachmentAutomaticInputFailoverSettingsFailoverConditionsFailoverConditionSettingsVideoBlackSettings(in *types.VideoBlackFailoverSettings) []interface{} {
if in == nil {
return nil
}

m := map[string]interface{}{
"black_detect_threshold": float32(in.BlackDetectThreshold),
"video_black_threshold_msec": int(in.VideoBlackThresholdMsec),
}

return []interface{}{m}
}

func expandChannelCdiInputSpecification(tfList []interface{}) *types.CdiInputSpecification {
if tfList == nil {
return nil
Expand Down
36 changes: 34 additions & 2 deletions website/docs/r/medialive_channel.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ The following arguments are optional:

* `input_attachment_name` - (Optional) User-specified name for the attachment.
* `input_id` - (Required) The ID of the input.
* `input_settings` - (Optional) Settings of an input. See [Input Settings](#input-settings) for more details
* `input_settings` - (Optional) Settings of an input. See [Input Settings](#input-settings) for more details.
* `automatic_input_failover_settings` - (Optional) User-specified settings for defining what the conditions are for declaring the input unhealthy and failing over to a different input. See [Automatic Input Failover Settings](#automatic-input-failover-settings) for more details.

### Input Settings

Expand Down Expand Up @@ -263,6 +264,37 @@ The following arguments are optional:
* `retry_interval` - (Optional) The number of seconds between retries when an attempt to read a manifest or segment fails.
* `scte35_source_type` - (Optional) Identifies the source for the SCTE-35 messages that MediaLive will ingest.

### Automatic Input Failover Settings

* `secondary_input_id` - (Required) The input ID of the secondary input in the automatic input failover pair.
* `error_clear_time_msec` - (Optional) This clear time defines the requirement a recovered input must meet to be considered healthy. The input must have no failover conditions for this length of time. Enter a time in milliseconds. This value is particularly important if the input\_preference for the failover pair is set to PRIMARY\_INPUT\_PREFERRED, because after this time, MediaLive will switch back to the primary input.
* `failover_conditions` - (Optional) A list of failover conditions. If any of these conditions occur, MediaLive will perform a failover to the other input. See [Failover Conditions](#failover-conditions) for more details.
* `input_preference` - (Optional) Input preference when deciding which input to make active when a previously failed input has recovered.

### Failover Conditions

* `failover_condition_settings` - (Optional) Failover condition type-specific settings. See [Failover Condition Settings](#failover-condition-settings) for more details.

### Failover Condition Settings

* `audio_silence_settings` - (Optional) MediaLive will perform a failover if the specified audio selector is silent for the specified period. See [Audio Silence Failover Settings](#audio-silence-failover-settings) for more details.
* `input_loss_settings` - (Optional) MediaLive will perform a failover if content is not detected in this input for the specified period. See [Input Loss Failover Settings](#input-loss-failover-settings) for more details.
* `video_black_settings` - (Optional) MediaLive will perform a failover if content is considered black for the specified period. See [Video Black Failover Settings](#video-black-failover-settings) for more details.

### Audio Silence Failover Settings

* `audio_selector_name` - (Required) The name of the audio selector in the input that MediaLive should monitor to detect silence. Select your most important rendition. If you didn't create an audio selector in this input, leave blank.
* `audio_silence_threshold_msec` - (Optional) The amount of time (in milliseconds) that the active input must be silent before automatic input failover occurs. Silence is defined as audio loss or audio quieter than -50 dBFS.

### Input Loss Failover Settings

* `input_loss_threshold_msec` - (Optional) The amount of time (in milliseconds) that no input is detected. After that time, an input failover will occur.

### Video Black Failover Settings

* `black_detect_threshold` - (Optional) A value used in calculating the threshold below which MediaLive considers a pixel to be 'black'. For the input to be considered black, every pixel in a frame must be below this threshold. The threshold is calculated as a percentage (expressed as a decimal) of white. Therefore .1 means 10% white (or 90% black). Note how the formula works for any color depth. For example, if you set this field to 0.1 in 10-bit color depth: (10230.1=102.3), which means a pixel value of 102 or less is 'black'. If you set this field to .1 in an 8-bit color depth: (2550.1=25.5), which means a pixel value of 25 or less is 'black'. The range is 0.0 to 1.0, with any number of decimal places.
* `video_black_threshold_msec` - (Optional) The amount of time (in milliseconds) that the active input must be black before automatic input failover occurs.

### Maintenance

* `maintenance_day` - (Optional) The day of the week to use for maintenance.
Expand Down Expand Up @@ -692,7 +724,7 @@ The following arguments are optional:
* `media_package_output_settings` - (Optional) Media package output settings. This can be set as an empty block.
* `multiplex_output_settings` - (Optional) Multiplex output settings. See [Multiplex Output Settings](#multiplex-output-settings) for more details.
* `rtmp_output_settings` - (Optional) RTMP output settings. See [RTMP Output Settings](#rtmp-output-settings) for more details.
* `udp_output_settings` - (Optional) UDP output settings. See [UDP Output Settings](#udp-output-settings) for more details
* `udp_output_settings` - (Optional) UDP output settings. See [UDP Output Settings](#udp-output-settings) for more details.

### Archive Output Settings

Expand Down
Loading