Skip to content

Commit

Permalink
resource/aws_backup_plan: Support resource import (#12381)
Browse files Browse the repository at this point in the history
Output from acceptance testing:

```
--- PASS: TestAccAwsBackupPlan_disappears (8.57s)
--- PASS: TestAccAwsBackupPlan_basic (9.42s)
--- PASS: TestAccAwsBackupPlan_withTags (19.27s)
--- PASS: TestAccAwsBackupPlan_withRules (19.68s)
--- PASS: TestAccAwsBackupPlan_withRecoveryPointTags (19.80s)
--- PASS: TestAccAwsBackupPlan_withLifecycle (24.37s)
```
  • Loading branch information
DrFaust92 authored Mar 16, 2020
1 parent e0307bc commit 7222645
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions aws/resource_aws_backup_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
25 changes: 25 additions & 0 deletions aws/resource_aws_backup_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func TestAccAwsBackupPlan_basic(t *testing.T) {
resource.TestCheckResourceAttrSet(resourceName, "version"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions website/docs/r/backup_plan.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 <id>
```

0 comments on commit 7222645

Please sign in to comment.