diff --git a/builtin/providers/aws/resource_aws_key_pair.go b/builtin/providers/aws/resource_aws_key_pair.go index b9c406467..cf4d82c54 100644 --- a/builtin/providers/aws/resource_aws_key_pair.go +++ b/builtin/providers/aws/resource_aws_key_pair.go @@ -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" { + d.SetId("") + return nil + } return fmt.Errorf("Error retrieving KeyPair: %s", err) }