Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/aws_backup_plan - add import support #12381

Merged
merged 2 commits into from
Mar 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
```