hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

[Bug]: aws_backup_selection: removing a condition is not reflected/picked up #30785

Open theunissenne opened 1 year ago

theunissenne commented 1 year ago

Terraform Core Version

1.3.5

AWS Provider Version

4.61.0

Affected Resource(s)

aws_backup_selection.

Situation:

resource "aws_backup_selection" "dynamodb_backup" {
  iam_role_arn = aws_iam_role.dynamodb_backup.arn
  name         = "${local.project_name}-selection"
  plan_id      = aws_backup_plan.dynamodb_backup.id
  resources = [
    "arn:aws:dynamodb:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/*"
  ]

  condition {
    string_equals {
      key   = "aws:ResourceTag/Stage"
      value = var.stage
    }
  }
}

if I remove condition:

resource "aws_backup_selection" "dynamodb_backup" {
  iam_role_arn = aws_iam_role.dynamodb_backup.arn
  name         = "${local.project_name}-selection"
  plan_id      = aws_backup_plan.dynamodb_backup.id
  resources = [
    "arn:aws:dynamodb:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/*"
  ]
}

Output says: No changes detected

Expected Behavior

I would expect the the condition to be removed from the resource.

Actual Behavior

Terraform says nothing changed

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_backup_vault" "dynamodb_backup" {
  name        = "${local.project_name}-vault"
  kms_key_arn = aws_kms_key.dynamodb_backup.arn
}

resource "aws_backup_plan" "dynamodb_backup" {
  name = "${local.project_name}-plan"

  rule {
    rule_name         = "${local.project_name}-rule"
    target_vault_name = aws_backup_vault.dynamodb_backup.name
    schedule          = var.backup_schedule

    lifecycle {
      delete_after = var.max_retention_period_in_days - 1
    }
  }

  tags = local.tags
}

resource "aws_backup_selection" "dynamodb_backup" {
  iam_role_arn = aws_iam_role.dynamodb_backup.arn
  name         = "${local.project_name}-selection"
  plan_id      = aws_backup_plan.dynamodb_backup.id
  resources = [
    "arn:aws:dynamodb:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/*"
  ]

  condition {
    string_equals {
      key   = "aws:ResourceTag/Stage"
      value = var.stage
    }
  }
}

resource "aws_backup_vault_lock_configuration" "dynamodb_backup" {
  backup_vault_name = aws_backup_vault.dynamodb_backup.name
  max_retention_days = var.max_retention_period_in_days
  min_retention_days = var.min_retention_period_in_days
}

Steps to Reproduce

Apply code with a single condition in aws_backup_selection. Afterwards remove the codition and reapply -> says no changes deteced

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue