“多选标签的 AWS 备份计划”

huangapple go评论59阅读模式
英文:

Aws backup plan multiple selection_tags

问题

我有一个问题,我已经研究了几个小时,但仍然没有得到一个合适的答案。

我正在terraform中定义一个aws_backup_plan。

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" }
  ]
}

我刚刚添加了 { type = "STRINGEQUALS", key = "backup", value = "daily" }selection_tags。我的问题是,如果我对一个资源打上数组中的一个标签,它会被分配给备份计划吗?也就是说,这个数组是否像一个OR运算符一样工作?

英文:

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?

答案1

得分: 2

这取决于条件的编写方式,在这个特定示例中,它的行为类似于“AND”语句而不是“OR”语句。这是为了在创建计划时提供精细的定位机制而设计的。

请查看来自AWS备份的这个图像:

“多选标签的 AWS 备份计划”

英文:

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:

“多选标签的 AWS 备份计划”

huangapple
  • 本文由 发表于 2023年6月29日 17:19:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76579730.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定