From a992860b8d4e312a4b7997a651ef791beb2f6472 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 16 May 2016 10:13:20 -0700 Subject: [PATCH] providers/aws: key_pair import --- .../providers/aws/import_aws_key_pair_test.go | 29 +++++++++++++++++++ .../providers/aws/resource_aws_key_pair.go | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 builtin/providers/aws/import_aws_key_pair_test.go 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 000000000..312d800d5 --- /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 0d6c51fcf..670ff4ac6 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,