terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

Modifying network interface on eip fails on first apply if ec2 instance has multiple network interfaces

Open pkqk opened this issue 2 years ago • 1 comments

I reported this issue to terraform but have been advised it is probably an issue with the aws provider.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

$ terraform -v
Terraform v1.2.9
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v4.30.0

Affected Resource(s)

  • aws_eip
  • aws_network_interface
  • aws_instance

Terraform Configuration Files

This is a simplified example of the kind of config I have: https://gist.github.com/pkqk/e152f6aa999f363eeb61b4103a8ae172

Expected Behavior

The network_interface that the eip is associated with should change

Actual Behavior

│ Error: associating EC2 EIP (eipalloc-91b2b2f8): InvalidInstanceID: There are multiple interfaces attached to instance 'i-04da62195e57ff3ce'. Please specify an interface ID for the operation instead.
│ 	status code: 400, request id: 783a4364-4aad-42f1-a10b-2d8caf77ce88

a second plan and apply succeeds.

Steps to Reproduce

  1. terraform apply

Important Factoids

The ec2 instance the eip is being attached to has multiple eni network interfaces, I think the the network_interface_id is being lost at some point in the modification and it is defaulting to just assigning to the ec2 instance without specifying the network interface.

pkqk avatar Sep 09 '22 00:09 pkqk