Merge pull request #2032 from hashicorp/keypair_refresh

Keypair refresh (from #2005)
This commit is contained in:
Clint 2015-05-21 09:25:19 -05:00
commit 21845d0cd9
1 changed files with 6 additions and 0 deletions

View File

@ -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)
}