Open camlow325 opened 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
The workaround for this is to split the allow_remote_vpc_dns_resolution
out into a separate resource, with a depends_on
. That way terraform will wait until the peering connection is active before it tries to modify it to add the DNS resolution. So:
resource "aws_vpc_peering_connection" "this" {
auto_accept = true
peer_vpc_id = ...
vpc_id = ...
tags = {}
}
resource "aws_vpc_peering_connection_options" "accept_dns" {
vpc_peering_connection_id = aws_vpc_peering_connection.this.id
requester {
allow_remote_vpc_dns_resolution = true
}
depends_on = [
aws_vpc_peering_connection.this
]
}
Also, if you're creating the peering across multiple regions, is better to have the allow_remote_vpc_dns_resolution
for the accepter in the accepter block.
Terraform Core Version
1.0.8
AWS Provider Version
4.17.1
Affected Resource(s)
Expected Behavior
Apply with resource successful.
Actual Behavior
Intermittently, Terraform apply fails with an error like the following:
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
terraform apply
.Debug Output
For a couple of cases of this failure so far, we've seen the following behavior:
AcceptVpcPeeringConnection
call to AWS appears to be successful.status
returned in the subsequentDescribeVpcPeeringConnections
call is stillpending-acceptance
.ModifyVpcPeeringConnectionOptions
call to AWS, the provider returns the error because thestatus
for the connection was notactive
here.At step 2 above, in the
WaitVPCPeeringConnectionActive
call, the call stops the wait loop here because the currentstatus
,pending-acceptance
, is one of theTarget
values,Active
andPendingAcceptance
. I think if this logic could be modified to only allow a status ofActive
to terminate the loop, the code would wait until AWS eventually transitions thestate
toactive
before modifying connection options and that the error would, therefore, be avoided.After the Terraform run has completed with the failure, we have seen that the
status
of the connection in the AWS console does indeed transition toactive
automatically even though the Terraform provider does not wait for this to occur before erroring out.Debug snippets:
AcceptVpcPeeringConnection
request:DescribeVpcPeeringConnections
request after theAcceptVpcPeeringConnection
request:Panic Output
No response
Important Factoids
No response
References
16625 - Note that I filed this issue separately because the prior one seemed to be a more persistent issue for those that had seen it whereas this one has only happened a couple of times out of dozens of applies so far. That issue may ultimately be the same as this one, though.
Would you like to implement a fix?
None