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

d/aws_vpc_peering_connection: Add IPv6 CIDR block attributes #36391

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/36391.txt
Original file line number Diff line number Diff line change
@@ -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
```
44 changes: 44 additions & 0 deletions internal/service/ec2/vpc_peering_connection_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -187,15 +191,17 @@ 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
}
}

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
Expand Down
8 changes: 6 additions & 2 deletions website/docs/d/vpc_peering_connection.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading