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.76k stars 9.12k forks source link

Selecting Backups By Conditions: AWS_Backup_Selection returns unexpected block #23118

Closed oldManLemon closed 7 months ago

oldManLemon commented 2 years ago

Issue

Just following the instructions for creating a condition based backup lifecycle in AWS, when I attempt to use the condition block which is referenced in the documentation it returns an error stating the condition block was not expected?

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_selection#selecting-backups-by-conditions

Terraform CLI and Terraform AWS Provider Version

Affected Resource(s)

Terraform Configuration Files

There are more but at this point even the example is just returning the error

resource "aws_backup_selection" "our_chosen_resources" {
  iam_role_arn = aws_iam_role.aws_backup_role.arn
  name         = "my_selected_resources"
  plan_id      = aws_backup_plan.daily_backup_rention_policy.id

  condition {
    string_equals {
      key   = "aws:ResourceTag/Component"
      value = "rds"
    }
    string_like {
      key   = "aws:ResourceTag/Application"
      value = "app*"
    }
    string_not_equals {
      key   = "aws:ResourceTag/Backup"
      value = "false"
    }
    string_not_like {
      key   = "aws:ResourceTag/Environment"
      value = "test*"
    }
  }
}

Debug Output

Panic Output

Expected Behavior

Accepts the existence of the condition code block

Actual Behavior

ar.snapshot_tags - *terraform.NodeRootVariable
------
e: "aws_backup_selection.our_chosen_resources" waiting on "aws_iam_role.aws_backup_role"
2022/02/11 02:52:59 [ERROR] <root>: eval: *terraform.EvalValidateResource, err: Unsupported block type: Blocks of type "condition" are not expected here.
2022/02/11 02:52:59 [ERROR] <root>: eval: *terraform.EvalSequence, err: Unsupported block type: Blocks of type "condition" are not expected here.
2022/02/11 02:52:59 [TRACE] [walkValidate] Exiting eval tree: aws_backup_selection.our_chosen_resources
2022/02/11 02:52:59 [TRACE] vertex "aws_backup_selection.our_chosen_resources": visit complete
2022/02/11 02:52:59 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2022/02/11 02:52:59 [TRACE] dag/walk: upstream of "provider.aws (close)" errored, so skipping
2022/02/11 02:52:59 [TRACE] dag/walk: upstream of "root" errored, so skipping

Error: Unsupported block type

  on main.tf line 101, in resource "aws_backup_selection" "our_chosen_resources":
 101:   condition {

Blocks of type "condition" are not expected here.

Steps to Reproduce

  1. terraform apply

Important Factoids

ewbankkit commented 2 years ago

Relates #22074.

@oldManLemon Thanks for raising this issue. Which version of the Terraform AWS Provider are you using? The aws_backup_selection.condition block was added in v3.72.0.

celso-vts commented 2 years ago

I came across this issue and having the wrong pinned version for hashicorp/aws was the problem. Updating to the latest did the trick for me.

github-actions[bot] commented 8 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 6 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.