diff --git a/CHANGELOG.md b/CHANGELOG.md index a75e323..fdefaaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.9.0 (April 7, 2021) + +FIXES: + +* Add support for several selection tags +* Remove `selection_tag_type`, `selection_tag_key` and `selection_tag_value` in favour of a `selection_tags` list variable +* Update README and examples folder to include several selection tags examples + ## 0.8.0 (April 7, 2021) ENHANCEMENTS: diff --git a/README.md b/README.md index 90856a2..776dead 100644 --- a/README.md +++ b/README.md @@ -74,16 +74,22 @@ module "aws_backup_example" { { name = "selection-1" resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1"] - selection_tag = { - type = "STRINGEQUALS" - key = "Environment" - value = "production" - } + selection_tag = [ + { + type = "STRINGEQUALS" + key = "Environment" + value = "production" + }, + { + type = "STRINGEQUALS" + key = "Owner" + value = "production" + } + ] }, { - name = "selection-2" - resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table2"] - selection_tag = {} + name = "selection-2" + resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table2"] }, ] @@ -145,9 +151,7 @@ No Modules. | rules | A list of rule maps | `any` | `[]` | no | | selection\_name | The display name of a resource selection document | `string` | `null` | no | | selection\_resources | An array of strings that either contain Amazon Resource Names (ARNs) or match patterns of resources to assign to a backup plan | `list` | `[]` | no | -| selection\_tag\_key | The key in a key-value pair | `string` | `null` | no | -| selection\_tag\_type | An operation, such as StringEquals, that is applied to a key-value pair used to filter resources in a selection | `string` | `null` | no | -| selection\_tag\_value | The value in a key-value pair | `string` | `null` | no | +| selection\_tags | List of tags for `selection_name` var, when using variable definition. | `list` | `[]` | no | | selections | A list of selction maps | `any` | `[]` | no | | tags | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | | vault\_kms\_key\_arn | The server-side encryption key that is used to protect your backups | `string` | `null` | no | diff --git a/examples/complete_plan/README.md b/examples/complete_plan/README.md index 2600d20..c46f1e6 100644 --- a/examples/complete_plan/README.md +++ b/examples/complete_plan/README.md @@ -55,20 +55,27 @@ module "aws_backup_example" { { name = "selection-1" resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1"] - selection_tag = { - type = "STRINGEQUALS" - key = "Environment" - value = "production" - } + selection_tag = [ + { + type = "STRINGEQUALS" + key = "Environment" + value = "production" + }, + { + type = "STRINGEQUALS" + key = "Owner" + value = "production" + } + ] }, { - name = "selection-2" - resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table2"] + name = "selection-2" + resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table2"] }, ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/examples/complete_plan/main.tf b/examples/complete_plan/main.tf index c749944..7f9452f 100644 --- a/examples/complete_plan/main.tf +++ b/examples/complete_plan/main.tf @@ -62,11 +62,18 @@ module "aws_backup_example" { { name = "selection-1" resources = ["arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1"] - selection_tag = { - type = "STRINGEQUALS" - key = "Environment" - value = "production" - } + selection_tag = [ + { + type = "STRINGEQUALS" + key = "Environment" + value = "production" + }, + { + type = "STRINGEQUALS" + key = "Owner" + value = "production" + } + ] }, { name = "selection-2" @@ -75,7 +82,7 @@ module "aws_backup_example" { ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/examples/selection_by_tags/README.md b/examples/selection_by_tags/README.md index 89de8e9..6bf5ebd 100644 --- a/examples/selection_by_tags/README.md +++ b/examples/selection_by_tags/README.md @@ -42,29 +42,27 @@ module "aws_backup_example" { ] # Multiple selections - # - Selection-1: Environment = prod - # - Selection-2: Backup = critical + # - Selection-1: By tags: Environment = prod, Owner = devops selections = [ { - name = "selection-1" - selection_tag = { - type = "STRINGEQUALS" - key = "Environment" - value = "prod" - } - }, - { - name = "selection-2" - selection_tag = { - type = "STRINGEQUALS" - key = "Backup" - value = "critial" - } - }, + name = "selection-1" + selection_tag = [ + { + type = "STRINGEQUALS" + key = "Environment" + value = "production" + }, + { + type = "STRINGEQUALS" + key = "Owner" + value = "devops" + } + ] + } ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "prod" Terraform = true } diff --git a/examples/selection_by_tags/main.tf b/examples/selection_by_tags/main.tf index d954b67..718a19b 100644 --- a/examples/selection_by_tags/main.tf +++ b/examples/selection_by_tags/main.tf @@ -37,29 +37,27 @@ module "aws_backup_example" { ] # Multiple selections - # - Selection-1: Environment = prod - # - Selection-2: Backup = critical + # - Selection-1: By tags: Environment = prod, Owner = devops selections = [ { - name = "selection-1" - selection_tag = { - type = "STRINGEQUALS" - key = "Environment" - value = "prod" - } - }, - { - name = "selection-2" - selection_tag = { - type = "STRINGEQUALS" - key = "Backup" - value = "critial" - } - }, + name = "selection-1" + selection_tag = [ + { + type = "STRINGEQUALS" + key = "Environment" + value = "production" + }, + { + type = "STRINGEQUALS" + key = "Owner" + value = "devops" + } + ] + } ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "prod" Terraform = true } diff --git a/examples/simple_plan/README.md b/examples/simple_plan/README.md index 44bc4a1..3aa9cbc 100644 --- a/examples/simple_plan/README.md +++ b/examples/simple_plan/README.md @@ -48,7 +48,7 @@ module "aws_backup_example" { ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/examples/simple_plan/main.tf b/examples/simple_plan/main.tf index f4f0603..294cc32 100644 --- a/examples/simple_plan/main.tf +++ b/examples/simple_plan/main.tf @@ -34,7 +34,7 @@ module "aws_backup_example" { ] tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/examples/simple_plan_using_variables/README.md b/examples/simple_plan_using_variables/README.md index 30a1164..e6a0dfc 100644 --- a/examples/simple_plan_using_variables/README.md +++ b/examples/simple_plan_using_variables/README.md @@ -27,7 +27,7 @@ module "aws_backup_example" { # Tags tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/examples/simple_plan_using_variables/main.tf b/examples/simple_plan_using_variables/main.tf index 2d23839..5b913ad 100644 --- a/examples/simple_plan_using_variables/main.tf +++ b/examples/simple_plan_using_variables/main.tf @@ -22,7 +22,7 @@ module "aws_backup_example" { # Tags tags = { - Owner = "backup team" + Owner = "devops" Environment = "production" Terraform = true } diff --git a/selection.tf b/selection.tf index d8fa1f0..04a45cb 100644 --- a/selection.tf +++ b/selection.tf @@ -9,7 +9,7 @@ resource "aws_backup_selection" "ab_selection" { resources = lookup(element(local.selections, count.index), "resources", null) dynamic "selection_tag" { - for_each = length(lookup(element(local.selections, count.index), "selection_tag", {})) == 0 ? [] : [lookup(element(local.selections, count.index), "selection_tag", {})] + for_each = length(lookup(element(local.selections, count.index), "selection_tag", [])) == 0 ? [] : lookup(element(local.selections, count.index), "selection_tag", []) content { type = lookup(selection_tag.value, "type", null) key = lookup(selection_tag.value, "key", null) @@ -23,13 +23,9 @@ locals { # Selection selection = var.selection_name == null ? [] : [ { - name = var.selection_name - resources = var.selection_resources - selection_tag = var.selection_tag_type == null ? {} : { - type = var.selection_tag_type - key = var.selection_tag_key - value = var.selection_tag_value - } + name = var.selection_name + resources = var.selection_resources + selection_tag = var.selection_tags } ] diff --git a/variables.tf b/variables.tf index c5f73b5..aa91790 100644 --- a/variables.tf +++ b/variables.tf @@ -105,22 +105,10 @@ variable "selection_resources" { default = [] } -variable "selection_tag_type" { - description = "An operation, such as StringEquals, that is applied to a key-value pair used to filter resources in a selection" - type = string - default = null -} - -variable "selection_tag_key" { - description = "The key in a key-value pair" - type = string - default = null -} - -variable "selection_tag_value" { - description = "The value in a key-value pair" - type = string - default = null +variable "selection_tags" { + description = "List of tags for `selection_name` var, when using variable definition." + type = list + default = [] } # Selection