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

Add variable selection_conditions #94

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ resource "aws_backup_selection" "default" {
plan_id = join("", aws_backup_plan.default[*].id)
resources = var.backup_resources
not_resources = var.not_resources

dynamic "selection_tag" {
for_each = var.selection_tags
content {
Expand All @@ -146,4 +147,38 @@ resource "aws_backup_selection" "default" {
value = selection_tag.value["value"]
}
}

condition {
dynamic "string_equals" {
for_each = var.selection_conditions.string_equals
content {
key = "aws:ResourceTag/${string_equals.value.key}"
value = string_equals.value.value
}
}

dynamic "string_like" {
for_each = var.selection_conditions.string_like
content {
key = "aws:ResourceTag/${string_like.value.key}"
value = string_like.value.value
}
}

dynamic "string_not_equals" {
for_each = var.selection_conditions.string_not_equals
content {
key = "aws:ResourceTag/${string_not_equals.value.key}"
value = string_not_equals.value.value
}
}

dynamic "string_not_like" {
for_each = var.selection_conditions.string_not_like
content {
key = "aws:ResourceTag/${string_not_like.value.key}"
value = string_not_like.value.value
}
}
}
}
23 changes: 23 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ variable "selection_tags" {
default = []
}

variable "selection_conditions" {
type = object({
string_equals = optional(list(object({
key = string
value = string
})), [])
string_like = optional(list(object({
key = string
value = string
})), [])
string_not_equals = optional(list(object({
key = string
value = string
})), [])
string_not_like = optional(list(object({
key = string
value = string
})), [])
})
description = "An array of conditions used to specify a set of resources to assign to a backup plan"
default = {}
}

variable "plan_name_suffix" {
type = string
description = "The string appended to the plan name"
Expand Down