-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
provider/aws: Make sure that VPC Peering Connection in a failed state returns an error. #9038
provider/aws: Make sure that VPC Peering Connection in a failed state returns an error. #9038
Conversation
Resolves #8933. |
The acceptance test is passing:
|
I need to add a test that covers the failed state. |
a7a87da
to
9859064
Compare
…ror. This commit adds simple logic which allows for a VPC Peering Connection that is in a failed state (e.g. due to an overlapping IP address ranges, etc.), to report such failed state as an error, rather then waiting for the time out to occur. Signed-off-by: Krzysztof Wilczynski <[email protected]>
9859064
to
a58650c
Compare
Generally, the idea is to bubble to error, as per:
Above has overlapping IP address ranges (CIDR), and so rightfully it fails. |
I am not sure how to test for a failure here. I've added a test, but it does not seem to execute, for example:
Maybe it is not possible to do it. |
Signed-off-by: Krzysztof Wilczynski <[email protected]>
I've added a test that checks for failure, and the acceptance test is passing:
|
Over to you @stack72 🚀 |
Type: schema.TypeString, | ||
Optional: true, | ||
ForceNew: true, | ||
Computed: true, | ||
}, | ||
"peer_vpc_id": &schema.Schema{ | ||
"peer_vpc_id": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the cleanup :)
return fmt.Errorf( | ||
"Error waiting for VPC Peering Connection (%s) to become available: %s", | ||
d.Id(), err) | ||
return errwrap.Wrapf(fmt.Sprintf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does feel a bit cumbersome with the fmt.Sprintf
, though.
@@ -139,23 +142,23 @@ func resourceAwsVPCPeeringRead(d *schema.ResourceData, meta interface{}) error { | |||
// When the VPC Peering Connection is pending acceptance, | |||
// the details about accepter and/or requester peering | |||
// options would not be included in the response. | |||
if pc.AccepterVpcInfo != nil && pc.AccepterVpcInfo.PeeringOptions != nil { | |||
if pc.AccepterVpcInfo.PeeringOptions != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we guarantee that pc.AccepterVpcInfo != nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for this extra check. Above, we set items that are being read from the structure too which are essential e.g. d.Set("peer_vpc_id", pc.AccepterVpcInfo.VpcId)
. Should this fail it would be long before we even get to peering options.
Walked through this review with @kwilczynski and he pointed out the rationale behind what has been done here. The tests pass so this looks good to merge:
|
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. |
This commit adds simple logic which allows for a VPC Peering Connection
that is in a failed state (e.g. due to an overlapping IP address ranges,
etc.), to report such failed state as an error, rather then waiting for
the time out to occur.
Signed-off-by: Krzysztof Wilczynski [email protected]