Skip to content
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

Handle AWS keypairs which no longer exist #2005

Closed
wants to merge 1 commit into from

Conversation

bitglue
Copy link

@bitglue bitglue commented May 18, 2015

When refreshing a keypair, update state appropriately rather than crash
if the keypair no longer exists on AWS.

Likely fixes #1851.

@@ -65,6 +65,11 @@ func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
}
resp, err := conn.DescribeKeyPairs(req)
if err != nil {
awsErr, ok := err.(aws.APIError)
if ok && awsErr.Code == "InvalidKeyPair.NotFound" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about establishing a precedent to log a warning when we do d.SetId("") whenever we're in this NotFound situation? I imagine we don't do that in many places yet, or at all, but I feel like we should.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why it would merit a warning. As I see it, this is just one among many ways the AWS state could diverge from the desired state as described by the configuration. If I'm concerned about monitoring unintended deviations of state, I can just run terraform plan (having not changed the configuration) and see all the deviations.

@catsby
Copy link
Contributor

catsby commented May 20, 2015

Can you please rebase on master? There was a change upstream regarding errors returned in aws-sdk-go:

Basically, aws.APIError becomes awserr.Error

When refreshing a keypair, update state appropriately rather than crash
if the keypair no longer exists on AWS.

Likely fixes hashicorp#1851.
@bitglue bitglue force-pushed the keypair_refresh branch from 8225727 to 9e2ecaf Compare May 21, 2015 00:58
@bitglue
Copy link
Author

bitglue commented May 21, 2015

@catsby done.

@catsby
Copy link
Contributor

catsby commented May 21, 2015

Thanks! I tacked on a single commit in #2032 to comply with the new error type, going with that.

@catsby catsby closed this May 21, 2015
catsby added a commit that referenced this pull request May 21, 2015
@bitglue
Copy link
Author

bitglue commented May 21, 2015

Oh, duh. I'm not dumb...just forgot to commit my changes before pushing them :)

@catsby
Copy link
Contributor

catsby commented May 21, 2015

No worries, thanks again 😊

On Thursday, May 21, 2015, Phil Frost [email protected] wrote:

Oh, duh. I'm not dumb...just forgot to commit my changes before pushing
them :)


Reply to this email directly or view it on GitHub
#2005 (comment).

Clint

@bitglue bitglue deleted the keypair_refresh branch July 10, 2015 16:36
@ghost
Copy link

ghost commented May 1, 2020

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.

@ghost ghost locked and limited conversation to collaborators May 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The key pair 'deployer-key' does not exist
2 participants