From af44dbd3cd1a15acd6c614d97309f66ae436938c Mon Sep 17 00:00:00 2001 From: stack72 Date: Thu, 23 Jun 2016 10:31:40 +0100 Subject: [PATCH] provider/aws: Support Import for `aws_cloudwatch_event_rule` ``` make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSCloudWatchEventRule_' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /vendor/) TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSCloudWatchEventRule_ -timeout 120m === RUN TestAccAWSCloudWatchEventRule_importBasic --- PASS: TestAccAWSCloudWatchEventRule_importBasic (20.15s) === RUN TestAccAWSCloudWatchEventRule_basic --- PASS: TestAccAWSCloudWatchEventRule_basic (35.25s) === RUN TestAccAWSCloudWatchEventRule_full --- PASS: TestAccAWSCloudWatchEventRule_full (19.43s) === RUN TestAccAWSCloudWatchEventRule_enable --- PASS: TestAccAWSCloudWatchEventRule_enable (50.52s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 125.380s ``` --- .../import_aws_cloudwatch_event_rule_test.go | 29 +++++++++++++++++++ .../aws/resource_aws_cloudwatch_event_rule.go | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 builtin/providers/aws/import_aws_cloudwatch_event_rule_test.go diff --git a/builtin/providers/aws/import_aws_cloudwatch_event_rule_test.go b/builtin/providers/aws/import_aws_cloudwatch_event_rule_test.go new file mode 100644 index 000000000..ac200dddf --- /dev/null +++ b/builtin/providers/aws/import_aws_cloudwatch_event_rule_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSCloudWatchEventRule_importBasic(t *testing.T) { + resourceName := "aws_cloudwatch_event_rule.foo" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCloudWatchEventRuleDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSCloudWatchEventRuleConfig, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"is_enabled"}, //this has a default value + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_cloudwatch_event_rule.go b/builtin/providers/aws/resource_aws_cloudwatch_event_rule.go index b56591e8f..9c420e807 100644 --- a/builtin/providers/aws/resource_aws_cloudwatch_event_rule.go +++ b/builtin/providers/aws/resource_aws_cloudwatch_event_rule.go @@ -20,6 +20,9 @@ func resourceAwsCloudWatchEventRule() *schema.Resource { Read: resourceAwsCloudWatchEventRuleRead, Update: resourceAwsCloudWatchEventRuleUpdate, Delete: resourceAwsCloudWatchEventRuleDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{