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.71k stars 9.07k forks source link

[Enhancement]: Add `associate_public_ip_address` to aws_network_interface resource #38275

Open RaJiska opened 1 month ago

RaJiska commented 1 month ago

Description

It would be nice to have a associate_public_ip_address parameter for the aws_network_interface resource so that it isn't required to allocate and manage an EIP.


The use case:

Making a HA service running in a active-passive fashion. The master and the backup each run in their own ASG, to leverage auto-recovery at the instance level., each ASG have exactly one instance. The master service needs to use a specific EIP address.

As master and backup need to communicate with one another an ENI is pre-provisioned for both to reserve a private IP each which is then passed via launch template's user data. Upon failover, the backup is promoted to master and self-assign the service EIP. After recovery from initial-master, it is unable to become master again as it's left without public IP to make calls to self-assign service EIP.

Having an auto-assigned IP would allow instances to have their primary IP be taken away while retaining their auto-assigned public IP as backup, and therefore still being able to make API calls. Private Link is not an option.

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

Potential Terraform Configuration

resource "aws_network_interface" "main" {
  description                 = "My ENI"
  subnet_id                   = var.subnet_id
  security_groups             = [aws_security_group.main.id]
  source_dest_check           = false
  associate_public_ip_address = true
}

References

This is implemented in AWS CLI via the options --associate-public-ip-address and --no-associate-public-ip-address.

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