diff --git a/.changelog/36391.txt b/.changelog/36391.txt new file mode 100644 index 00000000000..3e8d0e3eef8 --- /dev/null +++ b/.changelog/36391.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +data-source/aws_vpc_peering_connection: Add `ipv6_cidr_block_set` and `peer_ipv6_cidr_block_set` attributes +``` diff --git a/internal/service/ec2/vpc_peering_connection_data_source.go b/internal/service/ec2/vpc_peering_connection_data_source.go index 29bcce80100..e19624a6644 100644 --- a/internal/service/ec2/vpc_peering_connection_data_source.go +++ b/internal/service/ec2/vpc_peering_connection_data_source.go @@ -55,6 +55,18 @@ func DataSourceVPCPeeringConnection() *schema.Resource { Optional: true, Computed: true, }, + "ipv6_cidr_block_set": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ipv6_cidr_block": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "owner_id": { Type: schema.TypeString, Optional: true, @@ -77,6 +89,18 @@ func DataSourceVPCPeeringConnection() *schema.Resource { }, }, }, + "peer_ipv6_cidr_block_set": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "ipv6_cidr_block": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, "peer_owner_id": { Type: schema.TypeString, Optional: true, @@ -176,6 +200,16 @@ func dataSourceVPCPeeringConnectionRead(ctx context.Context, d *schema.ResourceD return sdkdiag.AppendErrorf(diags, "setting cidr_block_set: %s", err) } + ipv6CidrBlockSet := []interface{}{} + for _, v := range vpcPeeringConnection.RequesterVpcInfo.Ipv6CidrBlockSet { + ipv6CidrBlockSet = append(ipv6CidrBlockSet, map[string]interface{}{ + "ipv6_cidr_block": aws.StringValue(v.Ipv6CidrBlock), + }) + } + if err := d.Set("ipv6_cidr_block_set", ipv6CidrBlockSet); err != nil { + return sdkdiag.AppendErrorf(diags, "setting ipv6_cidr_block_set: %s", err) + } + d.Set("region", vpcPeeringConnection.RequesterVpcInfo.Region) d.Set("peer_vpc_id", vpcPeeringConnection.AccepterVpcInfo.VpcId) d.Set("peer_owner_id", vpcPeeringConnection.AccepterVpcInfo.OwnerId) @@ -191,6 +225,16 @@ func dataSourceVPCPeeringConnectionRead(ctx context.Context, d *schema.ResourceD return sdkdiag.AppendErrorf(diags, "setting peer_cidr_block_set: %s", err) } + peerIpv6CidrBlockSet := []interface{}{} + for _, v := range vpcPeeringConnection.AccepterVpcInfo.Ipv6CidrBlockSet { + peerIpv6CidrBlockSet = append(peerIpv6CidrBlockSet, map[string]interface{}{ + "ipv6_cidr_block": aws.StringValue(v.Ipv6CidrBlock), + }) + } + if err := d.Set("peer_ipv6_cidr_block_set", peerIpv6CidrBlockSet); err != nil { + return sdkdiag.AppendErrorf(diags, "setting peer_ipv6_cidr_block_set: %s", err) + } + d.Set("peer_region", vpcPeeringConnection.AccepterVpcInfo.Region) if err := d.Set("tags", KeyValueTags(ctx, vpcPeeringConnection.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { diff --git a/internal/service/ec2/vpc_peering_connection_data_source_test.go b/internal/service/ec2/vpc_peering_connection_data_source_test.go index 8f5371263aa..7f6d1926161 100644 --- a/internal/service/ec2/vpc_peering_connection_data_source_test.go +++ b/internal/service/ec2/vpc_peering_connection_data_source_test.go @@ -58,12 +58,16 @@ func TestAccVPCPeeringConnectionDataSource_id(t *testing.T) { // resource.TestCheckResourceAttrPair(dataSourceName, "cidr_block_set.#", resourceName, "cidr_block_set.#"), // not in resource resource.TestCheckResourceAttr(dataSourceName, "cidr_block_set.#", "1"), resource.TestCheckTypeSetElemAttrPair(dataSourceName, "cidr_block_set.*.cidr_block", requesterVpcResourceName, "cidr_block"), + resource.TestCheckResourceAttr(dataSourceName, "ipv6_cidr_block_set.#", "1"), + resource.TestCheckTypeSetElemAttrPair(dataSourceName, "ipv6_cidr_block_set.*.ipv6_cidr_block", requesterVpcResourceName, "ipv6_cidr_block"), // resource.TestCheckResourceAttrPair(dataSourceName, "region", resourceName, "region"), // not in resource // resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block", resourceName, "peer_cidr_block"), // not in resource resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block", accepterVpcResourceName, "cidr_block"), // resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block_set.#", resourceName, "peer_cidr_block_set.#"), // not in resource resource.TestCheckResourceAttr(dataSourceName, "peer_cidr_block_set.#", "1"), resource.TestCheckTypeSetElemAttrPair(dataSourceName, "peer_cidr_block_set.*.cidr_block", accepterVpcResourceName, "cidr_block"), + resource.TestCheckResourceAttr(dataSourceName, "peer_ipv6_cidr_block_set.#", "1"), + resource.TestCheckTypeSetElemAttrPair(dataSourceName, "peer_ipv6_cidr_block_set.*.ipv6_cidr_block", accepterVpcResourceName, "ipv6_cidr_block"), resource.TestCheckResourceAttrPair(dataSourceName, "peer_owner_id", resourceName, "peer_owner_id"), // resource.TestCheckResourceAttrPair(dataSourceName, "peer_region", resourceName, "peer_region"), //not in resource resource.TestCheckResourceAttrPair(dataSourceName, "peer_vpc_id", resourceName, "peer_vpc_id"), @@ -187,7 +191,8 @@ data "aws_vpc_peering_connection" "test" { func testAccVPCPeeringConnectionDataSourceConfig_id(rName string) string { return fmt.Sprintf(` resource "aws_vpc" "requester" { - cidr_block = "10.1.0.0/16" + cidr_block = "10.1.0.0/16" + assign_generated_ipv6_cidr_block = true tags = { Name = %[1]q @@ -195,7 +200,8 @@ resource "aws_vpc" "requester" { } resource "aws_vpc" "accepter" { - cidr_block = "10.2.0.0/16" + cidr_block = "10.2.0.0/16" + assign_generated_ipv6_cidr_block = true tags = { Name = %[1]q diff --git a/website/docs/d/vpc_peering_connection.html.markdown b/website/docs/d/vpc_peering_connection.html.markdown index 0282ebedca1..7bd086d600f 100644 --- a/website/docs/d/vpc_peering_connection.html.markdown +++ b/website/docs/d/vpc_peering_connection.html.markdown @@ -79,9 +79,13 @@ All of the argument attributes except `filter` are also exported as result attri * `accepter` - Configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC. -* `cidr_block_set` - List of objects with CIDR blocks of the requester VPC. +* `cidr_block_set` - List of objects with IPv4 CIDR blocks of the requester VPC. -* `peer_cidr_block_set` - List of objects with CIDR blocks of the accepter VPC. +* `ipv6_cidr_block_set` - List of objects with IPv6 CIDR blocks of the requester VPC. + +* `peer_cidr_block_set` - List of objects with IPv4 CIDR blocks of the accepter VPC. + +* `peer_ipv6_cidr_block_set` - List of objects with IPv6 CIDR blocks of the accepter VPC. * `requester` - Configuration block that describes [VPC Peering Connection] (https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.