Merge pull request #7284 from hashicorp/import-aws-cwlg
provider/aws: Add Import support for `aws_cloudwatch_log_group`
This commit is contained in:
commit
1bbb75bc9a
|
@ -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
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue