Is it possible in terraform - dynamic attributes names

Hi,

is it possible to use dynamic attribute name ?

like:

data.terraform_remote_state.${var.statefilename}.outputs.vpc.id

Best,
Pawel

1 Like

Maybe for somebody will be helpfull:

I make foreach for data ā€œterraform_remote_stateā€ and get dynamic name from map like:

 pscloud_vpc_attachments = {
    for k, v in var.test_map : 
        k => { name = k, vpc_id = data.terraform_remote_state.rs[v.datafile].outputs.vpc.id, subnets_ids = [ for s in v.subnets : data.terraform_remote_state.rs[v.datafile].outputs.subnets_private[s].id  ] }

cheers

1 Like