Merge pull request #2032 from hashicorp/keypair_refresh
Keypair refresh (from #2005)
This commit is contained in:
commit
21845d0cd9
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/hashicorp/terraform/helper/schema"
|
||||
|
||||
"github.com/awslabs/aws-sdk-go/aws"
|
||||
"github.com/awslabs/aws-sdk-go/aws/awserr"
|
||||
"github.com/awslabs/aws-sdk-go/service/ec2"
|
||||
)
|
||||
|
||||
|
@ -65,6 +66,11 @@ func resourceAwsKeyPairRead(d *schema.ResourceData, meta interface{}) error {
|
|||
}
|
||||
resp, err := conn.DescribeKeyPairs(req)
|
||||
if err != nil {
|
||||
awsErr, ok := err.(awserr.Error)
|
||||
if ok && awsErr.Code() == "InvalidKeyPair.NotFound" {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Error retrieving KeyPair: %s", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue