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

r/aws_medialive_channel: fix flatten/expand/docs vpc settings for a channel. #33558

Merged
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/33558.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/aws_medialive_channel: Fix VPC settings flatten/expand/docs.
```
29 changes: 18 additions & 11 deletions internal/service/medialive/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
},
Expand All @@ -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},
},
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down
8 changes: 7 additions & 1 deletion website/docs/r/medialive_channel.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
Loading