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.19k forks source link

[Enhancement]: EIP support for AWS provided public IP Pools #39449

Closed nothere517 closed 1 month ago

nothere517 commented 1 month ago

Description

I am unsure if this needs to be an enhancement or a bug so apologies in advance if enhancement is the wrong label.

AWS recently announced the ability to request Amazon-provided contiguous IPv4 blocks via their IPAM service. This allows you to request a public IP CIDR block and then allocate those to Elastic IP's to then be used for EC2 resources. I was able to follow their guide and create the resources via Terraform. I was able to create an IPAM, create a public IP pool provided by Amazon, and create a continuous CIDR block of IP's. The issue occurs when I try to create an EIP (elastic IP) resource specifying use of that pool. I included AWS links on how to do this via AWS CLI in the references section. It looks like there is a new property called "ipam-pool-id" which is not the same as "public_ipv_4_pool".

#this errors as ipam-pool is not a valid parameter value for public_ipv_4_pool. ipam-pool-id does not exist as a property for the existing aws_eip resource.
resource "awscc_ec2_eip" "demo_eip_ecs_cluster" {
  domain = "vpc"
  public_ipv_4_pool = "ipam-pool-{unique_aws_resource_value}"
}

There seems to be a new property called ipam-pool-id which is not a current option in the aws_eip resource.

This is availabe in AWS CLI specifying the IPAM pool ID. aws ec2 allocate-address --region us-east-1 --ipam-pool-id ipam-pool-{unique_aws_resource_value}

Terraform code sample to create the IPAM pool:

#create an IPAM in the account. This is used to allocate a Public IP CIDR block for the ECS cluster
resource "aws_vpc_ipam" "demo_ipam" {
  operating_regions {
    region_name = var.region
  }
  tier = "free"
}

#create a a pool in IPAM
resource "aws_vpc_ipam_pool" "demo_public_pool" {
  address_family = "ipv4"
  ipam_scope_id  = aws_vpc_ipam.demo_ipam.public_default_scope_id
  locale         = var.region
  public_ip_source = "amazon"
  description = "Public IP Pool for ECS Cluster"
  aws_service = "ec2"
}

#create a CIDR block in the pool
resource "aws_vpc_ipam_pool_cidr" "demo_public_pool_cidr" {
  ipam_pool_id   = aws_vpc_ipam_pool.demo_public_pool.id
  netmask_length = 30
}

The current resource property "public_ipv4_pool" not the same as the CLI property "ipam-pool-id"

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

Potential Terraform Configuration

#support for a new property called ipam-pool-id
resource "aws_eip" "demo_eip_ecs_cluster" {
  domain = "vpc"
  ipam_pool_id = aws_vpc_ipam_pool.demo_public_pool.id
}

References

https://aws.amazon.com/about-aws/whats-new/2024/08/amazon-provided-contiguous-ipv4-blocks/

https://docs.aws.amazon.com/vpc/latest/ipam/tutorials-eip-pool.html

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

github-actions[bot] commented 1 month ago

[!WARNING] This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

github-actions[bot] commented 1 month ago

This functionality has been released in v5.72.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 12 hours 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.