diff --git a/builtin/providers/aws/import_aws_cloudwatch_log_group_test.go b/builtin/providers/aws/import_aws_cloudwatch_log_group_test.go new file mode 100644 index 000000000..fcf8aab79 --- /dev/null +++ b/builtin/providers/aws/import_aws_cloudwatch_log_group_test.go @@ -0,0 +1,29 @@ +package aws + +import ( + "testing" + + "github.com/hashicorp/terraform/helper/resource" +) + +func TestAccAWSCloudWatchLogGroup_importBasic(t *testing.T) { + resourceName := "aws_cloudwatch_log_group.foobar" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSCloudWatchLogGroupDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccAWSCloudWatchLogGroupConfig, + }, + + resource.TestStep{ + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"retention_in_days"}, //this has a default value + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_cloudwatch_log_group.go b/builtin/providers/aws/resource_aws_cloudwatch_log_group.go index 6135dee89..a135b4017 100644 --- a/builtin/providers/aws/resource_aws_cloudwatch_log_group.go +++ b/builtin/providers/aws/resource_aws_cloudwatch_log_group.go @@ -16,6 +16,9 @@ func resourceAwsCloudWatchLogGroup() *schema.Resource { Read: resourceAwsCloudWatchLogGroupRead, Update: resourceAwsCloudWatchLogGroupUpdate, Delete: resourceAwsCloudWatchLogGroupDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": &schema.Schema{ @@ -60,7 +63,7 @@ func resourceAwsCloudWatchLogGroupCreate(d *schema.ResourceData, meta interface{ func resourceAwsCloudWatchLogGroupRead(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).cloudwatchlogsconn log.Printf("[DEBUG] Reading CloudWatch Log Group: %q", d.Get("name").(string)) - lg, err := lookupCloudWatchLogGroup(conn, d.Get("name").(string), nil) + lg, err := lookupCloudWatchLogGroup(conn, d.Id(), nil) if err != nil { return err }