hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.83k stars 9.18k forks source link

[Bug]: aws_vpn_connection incorrect validation of inside_ipv6_cidr #36232

Closed erikjoh closed 8 months ago

erikjoh commented 8 months ago

Terraform Core Version

1.7.4

AWS Provider Version

5.39.1

Affected Resource(s)

Expected Behavior

tunnel1_inside_ipv6_cidr and tunnel2_inside_ipv6_cidr should accept all possible cidrs within fd00::/8 .

For example fdff:1::1337:0:0/126 is within fd00::/8 :

$ ipcalc fd00::/8
Full Network:   fd00:0000:0000:0000:0000:0000:0000:0000/8
Network:    fd00::/8
Netmask:    ff00:: = 8

Address space:  Unique Local Unicast
HostMin:    fd00::
HostMax:    fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Hosts/Net:  2^(120) = 1329227995784915872903807060280344576

Actual Behavior

tunnel1_inside_ipv6_cidr and tunnel2_inside_ipv6_cidr only accept cidrs within fd00::/16 .

$ ipcalc fd00::/16
Full Network:   fd00:0000:0000:0000:0000:0000:0000:0000/16
Network:    fd00::/16
Netmask:    ffff:: = 16

Address space:  Unique Local Unicast
HostMin:    fd00::
HostMax:    fd00:ffff:ffff:ffff:ffff:ffff:ffff:ffff
Hosts/Net:  2^(112) = 5192296858534827628530496329220096

Relevant Error/Panic Output Snippet

╷
│ Error: invalid value for tunnel1_inside_ipv6_cidr (must be within fd00::/8)
│ 
│   with aws_vpn_connection.vpn-alpha,
│   on main.tf line 16, in resource "aws_vpn_connection" "vpn-alpha":
│   16:   tunnel1_inside_ipv6_cidr = "fdff:1::1337:0:0/126"
│ 
╵
╷
│ Error: invalid value for tunnel2_inside_ipv6_cidr (must be within fd00::/8)
│ 
│   with aws_vpn_connection.vpn-alpha,
│   on main.tf line 17, in resource "aws_vpn_connection" "vpn-alpha":
│   17:   tunnel2_inside_ipv6_cidr = "fdff:1::1337:1:0/126"
│ 
╵

Terraform Configuration Files

terraform {
  required_version = "~> 1.7.4"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">=5.39.1"
    }
  }
}

resource "aws_vpn_connection" "vpn-alpha" {
  customer_gateway_id      = "foo"
  transit_gateway_id       = "bar"
  type                     = "ipsec.1"
  tunnel1_inside_ipv6_cidr = "fdff:1::1337:0:0/126"
  tunnel2_inside_ipv6_cidr = "fdff:1::1337:1:0/126"
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

From the docs https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_VpnTunnelOptionsSpecification.html

TunnelInsideIpv6Cidr
The range of inside IPv6 addresses for the tunnel. Any specified CIDR blocks must be unique across all VPN connections that use the same transit gateway.

Constraints: A size /126 CIDR block from the local fd00::/8 range.

Type: String

Required: No

And the incorrect regex validation that causes this error:

https://github.com/hashicorp/terraform-provider-aws/blob/c7c1bc3e6d88d3d47979ba38c7a44c56e6763449/internal/service/ec2/vpnsite_connection.go#L1699

Would you like to implement a fix?

Yes

github-actions[bot] commented 8 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 8 months ago

This functionality has been released in v5.41.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

github-actions[bot] commented 7 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.