Skip to content

Commit

Permalink
Merge pull request #36097 from chrisandrews7/b-aws_medialive_channel-…
Browse files Browse the repository at this point in the history
…empty-audio

r/medialive_channel: allow empty audio descriptions
  • Loading branch information
jar-b authored Mar 6, 2024
2 parents c505a03 + 9d5cb40 commit cb5c016
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .changelog/36097.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_medialive_channel: Fix handling of optional `encoder_settings.audio_descriptions` arguments
```
4 changes: 2 additions & 2 deletions internal/service/medialive/channel_encoder_settings_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -3063,7 +3063,7 @@ func expandChannelEncoderSettings(tfList []interface{}) *types.EncoderSettings {
m := tfList[0].(map[string]interface{})

var settings types.EncoderSettings
if v, ok := m["audio_descriptions"].(*schema.Set); ok && v.Len() > 0 {
if v, ok := m["audio_descriptions"].(*schema.Set); ok {
settings.AudioDescriptions = expandChannelEncoderSettingsAudioDescriptions(v.List())
}
if v, ok := m["output_groups"].([]interface{}); ok && len(v) > 0 {
Expand Down Expand Up @@ -3108,7 +3108,7 @@ func expandChannelEncoderSettingsAudioDescriptions(tfList []interface{}) []types
return nil
}

var audioDesc []types.AudioDescription
audioDesc := []types.AudioDescription{}
for _, tfItem := range tfList {
m, ok := tfItem.(map[string]interface{})
if !ok {
Expand Down
123 changes: 123 additions & 0 deletions internal/service/medialive/channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,54 @@ func TestAccMediaLiveChannel_hls(t *testing.T) {
})
}

func TestAccMediaLiveChannel_noAudio(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
t.Skip("skipping long-running test in short mode")
}

var channel medialive.DescribeChannelOutput
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_medialive_channel.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
acctest.PreCheckPartitionHasService(t, names.MediaLiveEndpointID)
testAccChannelsPreCheck(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.MediaLiveServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckChannelDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccChannelConfig_noAudio(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckChannelExists(ctx, resourceName, &channel),
resource.TestCheckResourceAttrSet(resourceName, "channel_id"),
resource.TestCheckResourceAttr(resourceName, "channel_class", "STANDARD"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttrSet(resourceName, "role_arn"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.codec", "AVC"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.input_resolution", "HD"),
resource.TestCheckResourceAttr(resourceName, "input_specification.0.maximum_bitrate", "MAX_20_MBPS"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "input_attachments.*", map[string]string{
"input_attachment_name": "example-input1",
}),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "destinations.*", map[string]string{
"id": rName,
}),
resource.TestCheckResourceAttr(resourceName, "encoder_settings.0.timecode_config.0.source", "EMBEDDED"),
resource.TestCheckTypeSetElemNestedAttrs(resourceName, "encoder_settings.0.video_descriptions.*", map[string]string{
"name": "test-video-name",
}),
resource.TestCheckNoResourceAttr(resourceName, "encoder_settings.0.audio_descriptions.*"),
),
},
},
})
}

func TestAccMediaLiveChannel_status(t *testing.T) {
ctx := acctest.Context(t)
if testing.Short() {
Expand Down Expand Up @@ -1803,6 +1851,81 @@ resource "aws_medialive_channel" "test" {
`, rName))
}

func testAccChannelConfig_noAudio(rName string) string {
return acctest.ConfigCompose(
testAccChannelConfig_base(rName),
testAccChannelConfig_baseS3(rName),
testAccChannelConfig_baseMultiplex(rName),
fmt.Sprintf(`
resource "aws_medialive_channel" "test" {
name = %[1]q
channel_class = "STANDARD"
role_arn = aws_iam_role.test.arn
input_specification {
codec = "AVC"
input_resolution = "HD"
maximum_bitrate = "MAX_20_MBPS"
}
input_attachments {
input_attachment_name = "example-input1"
input_id = aws_medialive_input.test.id
}
destinations {
id = %[1]q
settings {
url = "s3://${aws_s3_bucket.test1.id}/test1"
}
settings {
url = "s3://${aws_s3_bucket.test2.id}/test2"
}
}
encoder_settings {
timecode_config {
source = "EMBEDDED"
}
video_descriptions {
name = "test-video-name"
}
output_groups {
output_group_settings {
archive_group_settings {
destination {
destination_ref_id = %[1]q
}
}
}
outputs {
output_name = "test-output-name"
video_description_name = "test-video-name"
output_settings {
archive_output_settings {
name_modifier = "_1"
extension = "m2ts"
container_settings {
m2ts_settings {
audio_buffer_model = "ATSC"
buffer_model = "MULTIPLEX"
rate_mode = "CBR"
}
}
}
}
}
}
}
}
`, rName))
}

func testAccChannelConfig_caption_descriptions(rName string, fontResolution int) string {
return acctest.ConfigCompose(
testAccChannelConfig_base(rName),
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/medialive_channel.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ The following arguments are optional:

### Encoder Settings

* `audio_descriptions` - (Required) Audio descriptions for the channel. See [Audio Descriptions](#audio-descriptions) for more details.
* `output_groups` - (Required) Output groups for the channel. See [Output Groups](#output-groups) for more details.
* `timecode_config` - (Required) Contains settings used to acquire and adjust timecode information from inputs. See [Timecode Config](#timecode-config) for more details.
* `video_descriptions` - (Required) Video Descriptions. See [Video Descriptions](#video-descriptions) for more details.
* `audio_descriptions` - (Optional) Audio descriptions for the channel. See [Audio Descriptions](#audio-descriptions) for more details.
* `avail_blanking` - (Optional) Settings for ad avail blanking. See [Avail Blanking](#avail-blanking) for more details.
* `caption_descriptions` - (Optional) Caption Descriptions. See [Caption Descriptions](#caption-descriptions) for more details.
* `global_configuration` - (Optional) Configuration settings that apply to the event as a whole. See [Global Configuration](#global-configuration) for more details.
* `motion_graphics_configuration` - (Optional) Settings for motion graphics. See [Motion Graphics Configuration](#motion-graphics-configuration) for more details.
* `nielsen_configuration` - (Optional) Nielsen configuration settings. See [Nielsen Configuration](#nielsen-configuration) for more details.
* `avail_blanking` - (Optional) Settings for ad avail blanking. See [Avail Blanking](#avail-blanking) for more details.

### Input Attachments

Expand Down

0 comments on commit cb5c016

Please sign in to comment.