amazon-web-servicesterraformterraform-provider-awsaws-backup

Aws backup plan multiple selection_tags


I have a question that I have been researching for a few hours now but still didn't manage to get a proper answer.

I'm defining an aws_backup_plan in terraform.

module "backup" {
  count  = var.backup_enabled ? 1 : 0
  source = "somwthing/backup/aws"
    
  enabled                  = var.backup_enabled
  version                  = "0.13.1"
  namespace                = "sr"
  stage                    = var.stage
  name                     = "storage-backups"
  tags                     = var.tags
  schedule                 = "cron(0 10 ? * * *)" # At 10:00 AM, daily
  iam_role_name            = local.iam_role_name  # unique role name per region as IAM resources are global
  delete_after             = 35                   # cannot be bigger than 35 days 
  enable_continuous_backup = true
  backup_resources         = var.backup_resources
  selection_tags = [
    { type = "STRINGEQUALS", key = "backup", value = "weekly" },
    { type = "STRINGEQUALS", key = "backup", value = "daily" }
  ]
}

I have just added { type = "STRINGEQUALS", key = "backup", value = "daily" } to the selection_tags. My question is, if I tag one resource with one of the tags in the array does it get assigned the backup plan? I.e. does this array behave like an OR operator?


Solution

  • Well it depends on how condition was written, In this particular example it behaves like an AND statement rather an OR. This was designed to provide refined targeting mechanisms when creating plans.

    Please take a look at this image from AWS backup:

    enter image description here