Merge pull request #7284 from hashicorp/import-aws-cwlg

provider/aws: Add Import support for `aws_cloudwatch_log_group`
This commit is contained in:
James Nugent 2016-06-23 10:52:32 +03:00 committed by GitHub
commit 1bbb75bc9a
2 changed files with 33 additions and 1 deletions

View File

@ -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
},
},
})
}

View File

@ -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
}