Open boonimus opened 9 months ago
Voting for Prioritization
Volunteering to Work on This Issue
I've hit this error when I've accidentally assigned two aws_eip
resources to an aws_instance
that only has one network adaptor.
For instance, to reproduce the error:
resource "aws_instance" "demo" {
ami = "ami-08e4526a271956ce2"
instance_type = "t3a.micro"
}
resource "aws_eip" "primary_ip" {
instance = aws_instance.demo.id
domain = "vpc"
}
resource "aws_eip" "secondary_ip" {
instance = aws_instance.demo.id
domain = "vpc"
}
The fix depends on what you intend to do - either drop the second IP address if it was an accidental assignment, or if you wanted two EIPs then add another network adaptor and change the aws_eip
resources to target the adaptors rather than the instance:
resource "aws_instance" "demo" {
ami = "ami-08e4526a271956ce2"
instance_type = "t3a.micro"
network_interface {
network_interface_id = aws_network_interface.primary.id
device_index = 0
}
network_interface {
network_interface_id = aws_network_interface.secondary.id
device_index = 1
}
}
resource "aws_eip" "primary_ip" {
network_interface = aws_network_interface.primary.id
domain = "vpc"
}
resource "aws_network_interface" "primary" {
subnet_id = aws_subnet.whatever.id
}
resource "aws_eip" "secondary_ip" {
network_interface = aws_network_interface.secondary.id
domain = "vpc"
}
resource "aws_network_interface" "secondary" {
subnet_id = aws_subnet.whatever.id
}
Terraform Core Version
1.6.6
AWS Provider Version
5.26.0
Affected Resource(s)
aws_eip_association
Expected Behavior
Details of associationId returned after creation (input of allocationId and networkInterfaceId), cdktf deploy continues to create resources and completes successfully.
Actual Behavior
"Error reading EC2 EIP Association (eipassoc-xxxxxx)" in logs. "cdktf deploy" fails at this point.
Curiously, when looking up an affected associationId in CloudTrail event logs, the association DID complete, and the response elements are visible. Furthermore, you can see the association completed in the EC2->EIP console. Subsequent runs of cdktf deploy result in success. This is also an intermittent issue, occuring in ~1/5 deployments.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Sample association tf generated by cdktf:
Steps to Reproduce
-create ENI and EIP -create subsequent association of those two
Issue is intermittent...
Debug Output
Cloudtrail for that same call:
Panic Output
No response
Important Factoids
My code creates a series ENIs and EIPs for new C5.18XL large instances. The ENIs <-> EIP association is done separately, as I was getting an error about the instance not being reading for EIP attachment. So it goes like this:
As mentioned earlier, the association always completes. The issue is that running cdktf deploy says the stack failed, which is confusing for customers. I can just tell them to run cdktf deploy again, but that seems counterintuitive. I feel like the provider is creating the association but somehow mishandling the response or trying to read it again immediately? Like I said, CloudTrail shows a successful association and response (see logs).
References
No response
Would you like to implement a fix?
None