From 8fa75ea38322b897800b11bfb6347c579fae7def Mon Sep 17 00:00:00 2001 From: Radek Simko Date: Tue, 12 Jul 2016 08:49:33 +0100 Subject: [PATCH] provider/aws: Allow import of KMS key (#7599) --- .../providers/aws/import_aws_kms_key_test.go | 29 +++++++++++++++++++ builtin/providers/aws/resource_aws_kms_key.go | 4 +++ 2 files changed, 33 insertions(+) create mode 100644 builtin/providers/aws/import_aws_kms_key_test.go diff --git a/builtin/providers/aws/import_aws_kms_key_test.go b/builtin/providers/aws/import_aws_kms_key_test.go new file mode 100644 index 000000000..ba809a5dd --- /dev/null +++ b/builtin/providers/aws/import_aws_kms_key_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSKMSKey_importBasic(t *testing.T) { + resourceName := "aws_kms_key.foo" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSKmsKeyDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSKmsKey, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"deletion_window_in_days"}, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_kms_key.go b/builtin/providers/aws/resource_aws_kms_key.go index c096216ee..052dcadaa 100644 --- a/builtin/providers/aws/resource_aws_kms_key.go +++ b/builtin/providers/aws/resource_aws_kms_key.go @@ -19,6 +19,10 @@ func resourceAwsKmsKey() *schema.Resource { Update: resourceAwsKmsKeyUpdate, Delete: resourceAwsKmsKeyDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + Schema: map[string]*schema.Schema{ "arn": &schema.Schema{ Type: schema.TypeString,