Skip to content

Use terraform_remote_state in globals #743

Answered by katcipis
irenair asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @irenair,

Can't you manipulate "data.terraform_remote_state.vpc" as a string on globals, like this:

globals {
  obj = {
     value = "data.terraform_remote_state.vpc"
     number = 10
  }
}

And then when you need it to generate code, inside the content block, you use tm_hcl_expression, like this:

generate_hcl "_test.tf" {
  content {
    state = tm_hcl_expression(global.obj.value)
  }
}

This should work and the final generated code will be data.terraform_remote_state.vpc (no quotes).

There is some more details about this on #724

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by mariux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested help wanted Extra attention is needed
2 participants