Get a reference of variable key map

Hi Community Team,

How can I use regional variable key inside the ‘DashboardBody’ of CloudWatch in terraform?

For example:
I’m trying this, you can see in main.tf file, how am I calling the regional variable key to get the value of load balancer, but it’s not working as expected and getting this error “The given key does not identify an element in this collection value.

how can I get the value of **a_alb** and **b_alb** inside the dashboard Body? Am I missing any context? Also, it would be great if there’s any different way to achieve this.

=======================
In terraform.tfvars file:

aws_region = {
Dev = “us-west-2”
Prod = “eu-west-1”
}

us-west-2 = {
a_alb = “app/wp-dd-Sss-2Cjnj3JHJKENBFKJje”
b_alb = “app/wp-dd-Sss-33rkjNKRNDjJHFBBs”
c_alb = “app/wp-dd-Sss-CJRNJENCJHjnj3Dja”

}
eu-west-1 = {
a_alb = “app/worp-dd-Rss-2Cjnj3JHJKENBFKJje”
b_alb = “app/worp-dd-Rss-3knkNDCXKJNAKDJ”
c_alb = “app/worp-dd-Rss-45KNDKNKSDJNFSD”
}

=======================
In variables.tf file:

variable “aws_region” {
type = map(string)
}

variable “us-west-2” {
type = map(string)
}

variable “eu-west-1” {
type = map(string)
}

========================
In main.tf file:

terraform {
required_providers {
aws = {
source = “hashicorp/aws”
version = “~> 4.0”
}
}
}

provider “aws” {
region = “${var.aws_region[“Dev”]}”
}

resource “aws_cloudwatch_dashboard” “main” {
dashboard_name = “${var.aws_region[“Dev”]}-Overview-dashboard”

dashboard_body = <<EOF
{
“widgets”: [
{
“height”: 6,
“width”: 8,
“y”: 0,
“x”: 0,
“type”: “metric”,
“properties”: {
“metrics”: [
[ “AWS/ApplicationELB”, “HTTPCode_Target_2XX_Count”, “LoadBalancer”, “${var.aws_region["a_alb"]}”, { “label”: “[HTTPCode_Target_2XX_Count” } ],
[ “.”, “HTTPCode_Target_5XX_Count”, “.”, “.”, { “label”: “[HTTPCode_Target_5XX_Count” } ],
[ “.”, “RequestCount”, “.”, “.”, { “label”: “[RequestCount” } ],
[ “.”, “HTTPCode_Target_4XX_Count”, “.”, “.”, { “label”: “[HTTPCode_Target_4XX_Count” } ]
],
“view”: “timeSeries”,
“stacked”: false,
“region”: “eu-west-1”,
“stat”: “Sum”,
“period”: 300,
“title”: “ALB Target Counts”,
“yAxis”: {
“left”: {
“label”: “”
}
}
}
},
]
}
EOF
}

===========

terraform init

terraform plan \

        -var='aws_region={"Dev":"us-west-2"}'

#terraform apply plan

please advise.