Need help with nested for_each

I’m trying to create RDS databases and extensions using the cyrilgdn/postgresql provider. The inputs are stores in the yaml file as below

databases:
bgdb1:
name: “bgdb1”
connlimit: 30
extensions:
- pgaudit
- hstore
- pg_stat_statements
bgdb2:
name: “bgdb2”
connlimit: 20
extensions:
- pgaudit
- pg_stat_statements
bgdb3:
name: “bgdb3”
connlimit: 10
extensions:
- pgaudit
- pg_stat_statements

resource “postgresql_database” “my_db” {
for_each = yamldecode(file(“./rds.yaml”))[“databases”]
name = each.value.name
owner = “dbadmin”
template = “template0”
lc_collate = “en_US.UTF-8”
connection_limit = each.value.connlimit
allow_connections = true
}

Can someone help me with the logic on how to create the extensions for each database?