diff --git a/builtin/providers/aws/import_aws_key_pair_test.go b/builtin/providers/aws/import_aws_key_pair_test.go new file mode 100644 index 0000000000..312d800d55 --- /dev/null +++ b/builtin/providers/aws/import_aws_key_pair_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSKeyPair_importBasic(t *testing.T) { + resourceName := "aws_key_pair.a_key_pair" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSKeyPairDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSKeyPairConfig, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"public_key"}, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_key_pair.go b/builtin/providers/aws/resource_aws_key_pair.go index 0d6c51fcf9..670ff4ac6a 100644 --- a/builtin/providers/aws/resource_aws_key_pair.go +++ b/builtin/providers/aws/resource_aws_key_pair.go @@ -18,6 +18,9 @@ func resourceAwsKeyPair() *schema.Resource { Read: resourceAwsKeyPairRead, Update: nil, Delete: resourceAwsKeyPairDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, SchemaVersion: 1, MigrateState: resourceAwsKeyPairMigrateState,