mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Handle AWS keypairs which no longer exist
When refreshing a keypair, update state appropriately rather than crash if the keypair no longer exists on AWS. Likely fixes #1851.
This commit is contained in:
parent
883e2848c6
commit
9e2ecafc46
@ -65,6 +65,11 @@ func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
}
|
}
|
||||||
resp, err := conn.DescribeKeyPairs(req)
|
resp, err := conn.DescribeKeyPairs(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
awsErr, ok := err.(aws.APIError)
|
||||||
|
if ok && awsErr.Code == "InvalidKeyPair.NotFound" {
|
||||||
|
d.SetId("")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("Error retrieving KeyPair: %s", err)
|
return fmt.Errorf("Error retrieving KeyPair: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user