From 76ee1aff42e5759fc47f7179f1a010e1e6a30a79 Mon Sep 17 00:00:00 2001 From: George Wu Date: Wed, 20 Sep 2023 19:29:20 -0700 Subject: [PATCH 1/2] r/aws_medialive_channel: fix flatten/expand vpc settings for a channel. --- .changelog/33558.txt | 3 +++ internal/service/medialive/channel.go | 29 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 .changelog/33558.txt diff --git a/.changelog/33558.txt b/.changelog/33558.txt new file mode 100644 index 00000000000..00d99cd711d --- /dev/null +++ b/.changelog/33558.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_medialive_channel: Fix VPC settings flatten/expand +``` diff --git a/internal/service/medialive/channel.go b/internal/service/medialive/channel.go index fd89f761668..2a9d88d4b43 100644 --- a/internal/service/medialive/channel.go +++ b/internal/service/medialive/channel.go @@ -695,7 +695,12 @@ func ResourceChannel() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "availability_zones": { - Type: schema.TypeList, + Type: schema.TypeSet, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "network_interface_ids": { + Type: schema.TypeSet, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, @@ -705,14 +710,14 @@ func ResourceChannel() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, "security_group_ids": { - Type: schema.TypeList, + Type: schema.TypeSet, Optional: true, Computed: true, MaxItems: 5, Elem: &schema.Schema{Type: schema.TypeString}, }, "subnet_ids": { - Type: schema.TypeList, + Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, }, @@ -2418,14 +2423,14 @@ func expandChannelVPC(tfList []interface{}) *types.VpcOutputSettings { m := tfList[0].(map[string]interface{}) settings := &types.VpcOutputSettings{} - if v, ok := m["security_group_ids"].([]string); ok && len(v) > 0 { - settings.SecurityGroupIds = v + if v, ok := m["security_group_ids"].(*schema.Set); ok && v.Len() > 0 { + settings.SecurityGroupIds = flex.ExpandStringValueSet(v) } - if v, ok := m["subnet_ids"].([]string); ok && len(v) > 0 { - settings.SubnetIds = v + if v, ok := m["subnet_ids"].(*schema.Set); ok && v.Len() > 0 { + settings.SubnetIds = flex.ExpandStringValueSet(v) } - if v, ok := m["public_address_allocation_ids"].([]string); ok && len(v) > 0 { - settings.PublicAddressAllocationIds = v + if v, ok := m["public_address_allocation_ids"].(*schema.Set); ok && v.Len() > 0 { + settings.PublicAddressAllocationIds = flex.ExpandStringValueSet(v) } return settings @@ -2437,8 +2442,10 @@ func flattenChannelVPC(apiObject *types.VpcOutputSettingsDescription) []interfac } m := map[string]interface{}{ - "security_group_ids": flex.FlattenStringValueList(apiObject.SecurityGroupIds), - "subnet_ids": flex.FlattenStringValueList(apiObject.SubnetIds), + "availability_zones": flex.FlattenStringValueSet(apiObject.AvailabilityZones), + "network_interface_ids": flex.FlattenStringValueSet(apiObject.NetworkInterfaceIds), + "security_group_ids": flex.FlattenStringValueSet(apiObject.SecurityGroupIds), + "subnet_ids": flex.FlattenStringValueSet(apiObject.SubnetIds), // public_address_allocation_ids is not included in the output struct } From 0a83521dbda2b5f7d3e37e25b38767a751895b25 Mon Sep 17 00:00:00 2001 From: George Wu Date: Sat, 23 Sep 2023 09:13:08 -0700 Subject: [PATCH 2/2] r/aws_medialive_channel: add missing documentationn for `vpc`. --- .changelog/33558.txt | 2 +- website/docs/r/medialive_channel.html.markdown | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.changelog/33558.txt b/.changelog/33558.txt index 00d99cd711d..acd04b96d83 100644 --- a/.changelog/33558.txt +++ b/.changelog/33558.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_medialive_channel: Fix VPC settings flatten/expand +resource/aws_medialive_channel: Fix VPC settings flatten/expand/docs. ``` diff --git a/website/docs/r/medialive_channel.html.markdown b/website/docs/r/medialive_channel.html.markdown index 936c3c85adc..1208d033389 100644 --- a/website/docs/r/medialive_channel.html.markdown +++ b/website/docs/r/medialive_channel.html.markdown @@ -109,7 +109,7 @@ The following arguments are optional: * `role_arn` - (Optional) Concise argument description. * `start_channel` - (Optional) Whether to start/stop channel. Default: `false` * `tags` - (Optional) A map of tags to assign to the channel. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. -* `vpc` - (Optional) Settings for the VPC outputs. +* `vpc` - (Optional) Settings for the VPC outputs. See [VPC](#vpc) for more details. ### CDI Input Specification @@ -761,6 +761,12 @@ The following arguments are optional: * `include_fec` - (Optional) Enables column only or column and row based FEC. * `row_length` - (Optional) The width of the FEC protection matrix. +### VPC + +* `subnet_ids` - (Required) A list of VPC subnet IDs from the same VPC. If STANDARD channel, subnet IDs must be mapped to two unique availability zones (AZ). +* `public_address_allocation_ids` - (Required) List of public address allocation ids to associate with ENIs that will be created in Output VPC. Must specify one for SINGLE_PIPELINE, two for STANDARD channels. +* `security_group_ids` - (Optional) A list of up to 5 EC2 VPC security group IDs to attach to the Output VPC network interfaces. If none are specified then the VPC default security group will be used. + ## Attribute Reference This resource exports the following attributes in addition to the arguments above: