You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+210-1Lines changed: 210 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Terraform module to create AWS Backup plans. AWS Backup is a fully managed backu
10
10
* Flexible backup plan customization
11
11
* Comprehensive backup management:
12
12
- Rules and selections
13
+
- Multiple plans per vault
13
14
- Copy actions and lifecycle policies
14
15
- Retention periods and windows
15
16
- Resource tagging
@@ -27,7 +28,7 @@ Terraform module to create AWS Backup plans. AWS Backup is a fully managed backu
27
28
28
29
## Usage
29
30
30
-
You can use this module to create a simple plan using the module's `rule_*` variables. You can also use the `rules` and `selections` list of maps variables to build a more complete plan by defining several rules and selections at once.
31
+
You can use this module to create a simple plan using the module's `rule_*` variables. You can also use the `rules` and `selections` list of maps variables to build a more complete plan by defining several rules and selections at once. For multiple backup plans, you can use the `plans` variable to create several plans with their own rules and selections.
31
32
32
33
Check the [examples](/examples/) folder where you can see how to configure backup plans with different selection criteria.
When upgrading from a previous version that used single plan configuration to the new multiple plans feature, you have two options:
452
+
453
+
#### Option 1: Continue using single plan (recommended for simple cases)
454
+
455
+
The module maintains full backward compatibility. Your existing configuration will continue to work without changes:
456
+
457
+
```hcl
458
+
# This will continue to work as before
459
+
module "aws_backup_example" {
460
+
source = "lgallard/backup/aws"
461
+
462
+
vault_name = "my-vault"
463
+
plan_name = "my-plan"
464
+
465
+
# Single rule using variables
466
+
rule_name = "daily-rule"
467
+
rule_schedule = "cron(0 12 * * ? *)"
468
+
469
+
# Or multiple rules using list
470
+
rules = [
471
+
{
472
+
name = "rule-1"
473
+
schedule = "cron(0 12 * * ? *)"
474
+
lifecycle = {
475
+
delete_after = 30
476
+
}
477
+
}
478
+
]
479
+
480
+
# Single selection using variables
481
+
selection_name = "my-selection"
482
+
selection_resources = ["arn:aws:dynamodb:..."]
483
+
484
+
# Or multiple selections using list
485
+
selections = [
486
+
{
487
+
name = "selection-1"
488
+
resources = ["arn:aws:dynamodb:..."]
489
+
}
490
+
]
491
+
}
492
+
```
493
+
494
+
#### Option 2: Migrate to multiple plans (recommended for complex scenarios)
495
+
496
+
If you want to use the new multiple plans feature, follow these steps:
497
+
498
+
1.**Update your configuration** to use the `plans` variable:
499
+
500
+
```hcl
501
+
# Before: Single plan configuration
502
+
module "aws_backup_example" {
503
+
source = "lgallard/backup/aws"
504
+
505
+
vault_name = "my-vault"
506
+
plan_name = "my-plan"
507
+
508
+
rules = [
509
+
{
510
+
name = "daily-rule"
511
+
schedule = "cron(0 12 * * ? *)"
512
+
lifecycle = { delete_after = 30 }
513
+
}
514
+
]
515
+
516
+
selections = [
517
+
{
518
+
name = "my-selection"
519
+
resources = ["arn:aws:dynamodb:..."]
520
+
}
521
+
]
522
+
}
523
+
524
+
# After: Multiple plans configuration
525
+
module "aws_backup_example" {
526
+
source = "lgallard/backup/aws"
527
+
528
+
vault_name = "my-vault"
529
+
530
+
plans = {
531
+
default = { # Use "default" as the plan key for smooth migration
532
+
name = "my-plan"
533
+
rules = [
534
+
{
535
+
name = "daily-rule"
536
+
schedule = "cron(0 12 * * ? *)"
537
+
lifecycle = { delete_after = 30 }
538
+
}
539
+
]
540
+
selections = {
541
+
my-selection = {
542
+
resources = ["arn:aws:dynamodb:..."]
543
+
}
544
+
}
545
+
}
546
+
}
547
+
}
548
+
```
549
+
550
+
2.**Handle resource migration** using Terraform state commands:
551
+
552
+
```bash
553
+
# Move the backup plan
554
+
terraform state mv 'module.aws_backup_example.aws_backup_plan.ab_plan[0]''module.aws_backup_example.aws_backup_plan.ab_plans["default"]'
555
+
556
+
# Move the backup selection(s) - adjust the selection key as needed
557
+
terraform state mv 'module.aws_backup_example.aws_backup_selection.ab_selection[0]''module.aws_backup_example.aws_backup_selection.plan_selections["default-my-selection"]'
558
+
559
+
# If using multiple selections, move each one:
560
+
terraform state mv 'module.aws_backup_example.aws_backup_selection.ab_selections["selection-name"]''module.aws_backup_example.aws_backup_selection.plan_selections["default-selection-name"]'
561
+
```
562
+
563
+
3.**Run terraform plan** to verify no resources will be recreated:
564
+
565
+
```bash
566
+
terraform plan
567
+
# Should show "No changes" if migration was successful
568
+
```
569
+
570
+
> **Note**: The exact state move commands depend on your current configuration. Use `terraform state list` to see your current resource addresses, and `terraform plan` to see what changes would be made before running the state move commands.
0 commit comments