-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
adding missing failed states for the NAT Gateways #8689
Conversation
@@ -101,7 +101,7 @@ func resourceAwsNatGatewayRead(d *schema.ResourceData, meta interface{}) error { | |||
if err != nil { | |||
return err | |||
} | |||
if ngRaw == nil || strings.ToLower(state) == "deleted" { | |||
if ngRaw == nil || strings.ToLower(state) == "deleted" || strings.ToLower(state) == "deleting" || strings.ToLower(state) == "failed" { |
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.
Would it be possible to re-factor this code a little? I know that you are just adding more checks, but it is getting pretty ugly. We could only do strings.ToLower(*resp.NatGateways[0].State)
once, for example. I would also move to using a lookup table to check for many states, but that would be a personal preference.
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.
Sure, I'll try to get that up later today.
@kwilczynski I believe that's what you were looking for (I used your changes on the vpc_peering check as a reference, I hope you don't mind). If you'd like to see any additional changes, please let me know. |
"failed": true, | ||
} | ||
|
||
if ngRaw == nil || status[strings.ToLower(state)] { |
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.
I would suggest checking for key existence the Go way, for example:
if _, ok := status[strings.ToLower(state)]; ngRaw == nil || ok {
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.
Ok, I'll re-work this and re-submit.
@erutherford thank you so much! Does this solve the problem you are seeing and does the acceptance test pass? |
@kwilczynski unfortunately, I was able to get out of my broken state by tainting the NAT Gateway resources and forcing the recreation. I can try to see if I can reproduce the issue by running an apply while the NAT gateway is in the deleting state, but reproducing the Internet Gateway timeout that occurred originally may be difficult. I'm open to suggestions though. On the acceptance testing front. Sorry, I skimped on that and had assumed it was a part of the CI testing that was occurring. I'll be sure to run that on my next commit before submitting it. Thanks again for your guidance. |
@erutherford the CI tests don't run acceptance tests (this happens once a day at the moment). You can run these by looking at the name of the tests and then invoking
I would recommend exporting the AWS credentials as environment variables so that Terraform would pick these up. |
…sh when the value doesn't exist
@kwilczynski I've updated to the format you mentioned and I've ensured the acceptance testing is passing for |
@erutherford no, thank you! :) You've done a remarkable thing: found an issue, took the time to troubleshoot, lodged an issue, and sent a fix. I wish everyone was doing this! Thank you so much for your help! Over to @stack72 now 🚀 |
Hi @erutherford To echo the statement that @kwilczynski made - a huge thanks for the contribution here :) It's great to get bug reports, but it's even better when someone helps us by fixing it as well :) I am just running the tests here and will merge when green Thanks Paul |
FYI:
|
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. |
Should resolve /issues/8687