Skip to content

Commit

Permalink
Same fix for 'aws_default_subnet'.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed May 6, 2022
1 parent ab6a1b8 commit 70e2b07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .changelog/24685.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
```release-note:bug
resource/aws_subnet: Fix `InvalidSubnet.Conflict` errors when associating IPv6 CIDR blocks
```

```release-note:bug
resource/aws_default_subnet: Fix `InvalidSubnet.Conflict` errors when associating IPv6 CIDR blocks
```
6 changes: 4 additions & 2 deletions internal/service/ec2/vpc_default_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,17 @@ func resourceDefaultSubnetCreate(d *schema.ResourceData, meta interface{}) error
}

// Creating an IPv6-native default subnets associates an IPv6 CIDR block.
for _, v := range subnet.Ipv6CidrBlockAssociationSet {
for i, v := range subnet.Ipv6CidrBlockAssociationSet {
if aws.StringValue(v.Ipv6CidrBlockState.State) == ec2.SubnetCidrBlockStateCodeAssociating { //we can only ever have 1 IPv6 block associated at once
associationID := aws.StringValue(v.AssociationId)

_, err = WaitSubnetIPv6CIDRBlockAssociationCreated(conn, associationID)
subnetCidrBlockState, err := WaitSubnetIPv6CIDRBlockAssociationCreated(conn, associationID)

if err != nil {
return fmt.Errorf("error waiting for EC2 Default Subnet (%s) IPv6 CIDR block (%s) to become associated: %w", d.Id(), associationID, err)
}

subnet.Ipv6CidrBlockAssociationSet[i].Ipv6CidrBlockState = subnetCidrBlockState
}
}

Expand Down

0 comments on commit 70e2b07

Please sign in to comment.