Reference to variable in locals

Hello,

I have the locals block which looks like this:

routing = {
        "Ldap_Data" = {
            src_rt_ids = var.ldap_ops_private_route_table_ids
            dst_rt_ids = var.base_info["data_vpc"].private_route_table_ids
            src_cidr = var.ldap_ops_vpc_cidr
            dst_cidr = var.base_info["data_vpc"].cidr_block
            peering_connection_id = var.peering_connection_ids["Ldap-Data"]
            name = "ldap-data"
            src_provider = "aws.ldap"
            dst_provider = "aws.stack"
        }
}

In some cases var.base_info[“data_vpc”] doesn’t exist and it gives an error:
The given key does not identify an element in this collection value.

How to check, if this variable is set before assignment?

Solved this issue by using new “try” function: