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.85k stars 9.19k forks source link

[Enhancement]: aws_vpc_ipv4_cidr_block_association List of CIDRs instead of single items #40169

Open midnightconman opened 2 hours ago

midnightconman commented 2 hours ago

Description

It's very difficult to work with aws_vpc_ipv4_cidr_block_association to manage IPv4 CIDR blocks, normally you will be met with conflicting range or CIDR block in use by subnet errors. If you try to grow or merge CIDR blocks, you will be met with conflicting block errors as the individual items aren't ordered in AWS.

Would it be possible to add another function that would take a list of CIDR blocks and that function would take care of deleting older block / modifying the state in AWS? At the moment individuals would need to write something to maintain this list outside terraform if they plan to update CIDRs on any regular cadence.

Affected Resource(s) and/or Data Source(s)

No response

Potential Terraform Configuration

# We start by adding a small CIDR block

resource "aws_vpc" "main" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_vpc_ipv4_cidr_block_association" "a_cidr" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "172.20.0.0/16"
}

...

# We want to grow the existing CIDR block and we are greeted by a conflicting block error

resource "aws_vpc_ipv4_cidr_block_association" "a_cidr" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "172.20.0.0/15"
}

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 2 hours ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue