Skip to content

Commit 10beb8e

Browse files
authored
Merge pull request #36391 from finalduty/f-aws_vpc_peering_connection-ipv6_cidr_block_set
d/aws_vpc_peering_connection: Add IPv6 CIDR block attributes
2 parents dfbf59d + 352b094 commit 10beb8e

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

.changelog/36391.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
data-source/aws_vpc_peering_connection: Add `ipv6_cidr_block_set` and `peer_ipv6_cidr_block_set` attributes
3+
```

internal/service/ec2/vpc_peering_connection_data_source.go

+44
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ func DataSourceVPCPeeringConnection() *schema.Resource {
5555
Optional: true,
5656
Computed: true,
5757
},
58+
"ipv6_cidr_block_set": {
59+
Type: schema.TypeList,
60+
Computed: true,
61+
Elem: &schema.Resource{
62+
Schema: map[string]*schema.Schema{
63+
"ipv6_cidr_block": {
64+
Type: schema.TypeString,
65+
Computed: true,
66+
},
67+
},
68+
},
69+
},
5870
"owner_id": {
5971
Type: schema.TypeString,
6072
Optional: true,
@@ -77,6 +89,18 @@ func DataSourceVPCPeeringConnection() *schema.Resource {
7789
},
7890
},
7991
},
92+
"peer_ipv6_cidr_block_set": {
93+
Type: schema.TypeList,
94+
Computed: true,
95+
Elem: &schema.Resource{
96+
Schema: map[string]*schema.Schema{
97+
"ipv6_cidr_block": {
98+
Type: schema.TypeString,
99+
Computed: true,
100+
},
101+
},
102+
},
103+
},
80104
"peer_owner_id": {
81105
Type: schema.TypeString,
82106
Optional: true,
@@ -176,6 +200,16 @@ func dataSourceVPCPeeringConnectionRead(ctx context.Context, d *schema.ResourceD
176200
return sdkdiag.AppendErrorf(diags, "setting cidr_block_set: %s", err)
177201
}
178202

203+
ipv6CidrBlockSet := []interface{}{}
204+
for _, v := range vpcPeeringConnection.RequesterVpcInfo.Ipv6CidrBlockSet {
205+
ipv6CidrBlockSet = append(ipv6CidrBlockSet, map[string]interface{}{
206+
"ipv6_cidr_block": aws.StringValue(v.Ipv6CidrBlock),
207+
})
208+
}
209+
if err := d.Set("ipv6_cidr_block_set", ipv6CidrBlockSet); err != nil {
210+
return sdkdiag.AppendErrorf(diags, "setting ipv6_cidr_block_set: %s", err)
211+
}
212+
179213
d.Set("region", vpcPeeringConnection.RequesterVpcInfo.Region)
180214
d.Set("peer_vpc_id", vpcPeeringConnection.AccepterVpcInfo.VpcId)
181215
d.Set("peer_owner_id", vpcPeeringConnection.AccepterVpcInfo.OwnerId)
@@ -191,6 +225,16 @@ func dataSourceVPCPeeringConnectionRead(ctx context.Context, d *schema.ResourceD
191225
return sdkdiag.AppendErrorf(diags, "setting peer_cidr_block_set: %s", err)
192226
}
193227

228+
peerIpv6CidrBlockSet := []interface{}{}
229+
for _, v := range vpcPeeringConnection.AccepterVpcInfo.Ipv6CidrBlockSet {
230+
peerIpv6CidrBlockSet = append(peerIpv6CidrBlockSet, map[string]interface{}{
231+
"ipv6_cidr_block": aws.StringValue(v.Ipv6CidrBlock),
232+
})
233+
}
234+
if err := d.Set("peer_ipv6_cidr_block_set", peerIpv6CidrBlockSet); err != nil {
235+
return sdkdiag.AppendErrorf(diags, "setting peer_ipv6_cidr_block_set: %s", err)
236+
}
237+
194238
d.Set("peer_region", vpcPeeringConnection.AccepterVpcInfo.Region)
195239

196240
if err := d.Set("tags", KeyValueTags(ctx, vpcPeeringConnection.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {

internal/service/ec2/vpc_peering_connection_data_source_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,16 @@ func TestAccVPCPeeringConnectionDataSource_id(t *testing.T) {
5858
// resource.TestCheckResourceAttrPair(dataSourceName, "cidr_block_set.#", resourceName, "cidr_block_set.#"), // not in resource
5959
resource.TestCheckResourceAttr(dataSourceName, "cidr_block_set.#", "1"),
6060
resource.TestCheckTypeSetElemAttrPair(dataSourceName, "cidr_block_set.*.cidr_block", requesterVpcResourceName, "cidr_block"),
61+
resource.TestCheckResourceAttr(dataSourceName, "ipv6_cidr_block_set.#", "1"),
62+
resource.TestCheckTypeSetElemAttrPair(dataSourceName, "ipv6_cidr_block_set.*.ipv6_cidr_block", requesterVpcResourceName, "ipv6_cidr_block"),
6163
// resource.TestCheckResourceAttrPair(dataSourceName, "region", resourceName, "region"), // not in resource
6264
// resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block", resourceName, "peer_cidr_block"), // not in resource
6365
resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block", accepterVpcResourceName, "cidr_block"),
6466
// resource.TestCheckResourceAttrPair(dataSourceName, "peer_cidr_block_set.#", resourceName, "peer_cidr_block_set.#"), // not in resource
6567
resource.TestCheckResourceAttr(dataSourceName, "peer_cidr_block_set.#", "1"),
6668
resource.TestCheckTypeSetElemAttrPair(dataSourceName, "peer_cidr_block_set.*.cidr_block", accepterVpcResourceName, "cidr_block"),
69+
resource.TestCheckResourceAttr(dataSourceName, "peer_ipv6_cidr_block_set.#", "1"),
70+
resource.TestCheckTypeSetElemAttrPair(dataSourceName, "peer_ipv6_cidr_block_set.*.ipv6_cidr_block", accepterVpcResourceName, "ipv6_cidr_block"),
6771
resource.TestCheckResourceAttrPair(dataSourceName, "peer_owner_id", resourceName, "peer_owner_id"),
6872
// resource.TestCheckResourceAttrPair(dataSourceName, "peer_region", resourceName, "peer_region"), //not in resource
6973
resource.TestCheckResourceAttrPair(dataSourceName, "peer_vpc_id", resourceName, "peer_vpc_id"),
@@ -187,15 +191,17 @@ data "aws_vpc_peering_connection" "test" {
187191
func testAccVPCPeeringConnectionDataSourceConfig_id(rName string) string {
188192
return fmt.Sprintf(`
189193
resource "aws_vpc" "requester" {
190-
cidr_block = "10.1.0.0/16"
194+
cidr_block = "10.1.0.0/16"
195+
assign_generated_ipv6_cidr_block = true
191196
192197
tags = {
193198
Name = %[1]q
194199
}
195200
}
196201
197202
resource "aws_vpc" "accepter" {
198-
cidr_block = "10.2.0.0/16"
203+
cidr_block = "10.2.0.0/16"
204+
assign_generated_ipv6_cidr_block = true
199205
200206
tags = {
201207
Name = %[1]q

website/docs/d/vpc_peering_connection.html.markdown

+6-2
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ All of the argument attributes except `filter` are also exported as result attri
7979
* `accepter` - Configuration block that describes [VPC Peering Connection]
8080
(https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the accepter VPC.
8181

82-
* `cidr_block_set` - List of objects with CIDR blocks of the requester VPC.
82+
* `cidr_block_set` - List of objects with IPv4 CIDR blocks of the requester VPC.
8383

84-
* `peer_cidr_block_set` - List of objects with CIDR blocks of the accepter VPC.
84+
* `ipv6_cidr_block_set` - List of objects with IPv6 CIDR blocks of the requester VPC.
85+
86+
* `peer_cidr_block_set` - List of objects with IPv4 CIDR blocks of the accepter VPC.
87+
88+
* `peer_ipv6_cidr_block_set` - List of objects with IPv6 CIDR blocks of the accepter VPC.
8589

8690
* `requester` - Configuration block that describes [VPC Peering Connection]
8791
(https://docs.aws.amazon.com/vpc/latest/peering/what-is-vpc-peering.html) options set for the requester VPC.

0 commit comments

Comments
 (0)