Skip to content

Commit

Permalink
Add multiple copy_action support
Browse files Browse the repository at this point in the history
  • Loading branch information
lgallard committed Jul 16, 2021
1 parent 7f977b3 commit 80a721e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.12.0 (July 16, 2021)

ENHANCEMENTS:

* Add multiple `copy_action` support (thanks @unni-kr)

## 0.11.6 (May 13, 2021)

FIXES:
Expand Down Expand Up @@ -31,7 +37,6 @@ ENHANCEMENTS:
* Add .gitignore file
* Update README


## 0.11.2 (April 10, 2021)

FIXES:
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ module "aws_backup_example" {
cold_storage_after = 0
delete_after = 30
},
copy_action = {
lifecycle = {
cold_storage_after = 0
delete_after = 90
copy_actions = [
{
lifecycle = {
cold_storage_after = 0
delete_after = 90
},
destination_vault_arn = "arn:aws:backup:us-west-2:123456789101:backup-vault:Default"
},
destination_vault_arn = "arn:aws:backup:us-west-2:123456789101:backup-vault:Default"
}
]
recovery_point_tags = {
Environment = "production"
}
Expand Down
21 changes: 15 additions & 6 deletions examples/complete_plan/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,22 @@ module "aws_backup_example" {
cold_storage_after = 0
delete_after = 30
},
copy_action = {
lifecycle = {
cold_storage_after = 0
delete_after = 90
copy_actions = [
{
lifecycle = {
cold_storage_after = 0
delete_after = 90
},
destination_vault_arn = "arn:aws:backup:us-west-2:123456789101:backup-vault:Default"
},
destination_vault_arn = "arn:aws:backup:us-west-2:123456789101:backup-vault:Default"
}
{
lifecycle = {
cold_storage_after = 0
delete_after = 90
},
destination_vault_arn = "arn:aws:backup:us-east-2:123456789101:backup-vault:Default"
},
]
recovery_point_tags = {
Environment = "production"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/complete_plan/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "env" {
type = map
type = map(any)
default = {}
}
2 changes: 1 addition & 1 deletion examples/selection_by_tags/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module "aws_backup_example" {
start_window = 120
completion_window = 360
lifecycle = {}
copy_action = {}
copy_actions = []
recovery_point_tags = {}
},
]
Expand Down
2 changes: 1 addition & 1 deletion examples/selection_by_tags/variables.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable "env" {
type = map
type = map(any)
default = {}
}
5 changes: 2 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ resource "aws_backup_plan" "ab_plan" {

# Lifecycle
dynamic "lifecycle" {
for_each = length(lookup(rule.value, "lifecycle")) == 0 ? [] : [lookup(rule.value, "lifecycle", {})]
for_each = length(lookup(rule.value, "lifecycle", {})) == 0 ? [] : [lookup(rule.value, "lifecycle", {})]
content {
cold_storage_after = lookup(lifecycle.value, "cold_storage_after", 0)
delete_after = lookup(lifecycle.value, "delete_after", 90)
Expand All @@ -34,7 +34,7 @@ resource "aws_backup_plan" "ab_plan" {

# Copy action
dynamic "copy_action" {
for_each = length(lookup(rule.value, "copy_action", {})) == 0 ? [] : [lookup(rule.value, "copy_action", {})]
for_each = lookup(rule.value, "copy_actions", [])
content {
destination_vault_arn = lookup(copy_action.value, "destination_vault_arn", null)

Expand All @@ -48,7 +48,6 @@ resource "aws_backup_plan" "ab_plan" {
}
}
}

}
}

Expand Down

0 comments on commit 80a721e

Please sign in to comment.