hello good morning, I am trying to go through a list that contains maps. It is a module to create a backup plan using the aws service. The input data is the list of maps and I want to iterate to obtain the name
main.hcl
inputs = {
datos = [
{
datos1={name ="backup-plan"},
datos2={name ="backup-ldap"}}
]
}
main.tf
.......
......
resource "aws_backup_plan" "backup-plan" {
dynamic "dato" {
for_each =local.datos
content {
name=dato.value["name"]
}
}
rule {
rule_name = "${var.time_rule_name}-${local.backups.retention}-day-retention"
target_vault_name = aws_backup_vault.backup-vault.name
schedule = local.backups.schedule
start_window = 60
completion_window = 300
lifecycle {
delete_after = local.backups.retention
}
recovery_point_tags = {
Project = var.project
Role = "backup"
Creator = "aws-backups"
}
}
tags = {
Project = var.project
Role = "backup"
}
}
resource "aws_backup_selection" "server-backup-selection" {
iam_role_arn = aws_iam_role.aws-backup-service-role.arn
name = "server-resources"
plan_id = aws_backup_plan.backup-plan.id
selection_tag {
type = "STRINGEQUALS"
key = var.key
value = "true"
}
}
errors are:
Error: Missing required argument
The argument “name” is required, but no definition was found.
Error: Unsupported block type
dynamic “dato” {
Blocks of type “dato” are not expected here.