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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions builtin/providers/aws/resource_aws_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.

d.SetId("")
return nil
}
return fmt.Errorf("Error retrieving KeyPair: %s", err)
}

Expand Down