diff --git a/aws/resource_aws_backup_plan.go b/aws/resource_aws_backup_plan.go index 564f770c8f29..99769a9ded0f 100644 --- a/aws/resource_aws_backup_plan.go +++ b/aws/resource_aws_backup_plan.go @@ -18,6 +18,9 @@ func resourceAwsBackupPlan() *schema.Resource { Read: resourceAwsBackupPlanRead, Update: resourceAwsBackupPlanUpdate, Delete: resourceAwsBackupPlanDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, Schema: map[string]*schema.Schema{ "name": { diff --git a/aws/resource_aws_backup_plan_test.go b/aws/resource_aws_backup_plan_test.go index 7ce2dab20c54..f56194e97d7d 100644 --- a/aws/resource_aws_backup_plan_test.go +++ b/aws/resource_aws_backup_plan_test.go @@ -39,6 +39,11 @@ func TestAccAwsBackupPlan_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "version"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, }, }) } @@ -66,6 +71,11 @@ func TestAccAwsBackupPlan_withTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.Key2", "Value2a"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAwsBackupPlanConfig_tagsUpdated(rName), Check: resource.ComposeTestCheckFunc( @@ -124,6 +134,11 @@ func TestAccAwsBackupPlan_withRules(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAwsBackupPlanConfig_threeRules(rName), Check: resource.ComposeTestCheckFunc( @@ -190,6 +205,11 @@ func TestAccAwsBackupPlan_withLifecycle(t *testing.T) { testAccCheckAwsBackupPlanRuleAttr(resourceName, &ruleNameMap, rName, "recovery_point_tags.%", "0"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAwsBackupPlanConfig_lifecycleDeleteAfterOnly(rName), Check: resource.ComposeTestCheckFunc( @@ -259,6 +279,11 @@ func TestAccAwsBackupPlan_withRecoveryPointTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, { Config: testAccAwsBackupPlanConfig_recoveryPointTagsUpdated(rName), Check: resource.ComposeTestCheckFunc( diff --git a/website/docs/r/backup_plan.html.markdown b/website/docs/r/backup_plan.html.markdown index 7bada31b4972..3c3f01329b27 100644 --- a/website/docs/r/backup_plan.html.markdown +++ b/website/docs/r/backup_plan.html.markdown @@ -56,3 +56,11 @@ In addition to all arguments above, the following attributes are exported: * `id` - The id of the backup plan. * `arn` - The ARN of the backup plan. * `version` - Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan. + +## Import + +Backup Plan can be imported using the `id`, e.g. + +``` +$ terraform import aws_backup_plan.test +```