Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get values from pseudo-nested maps? #20

Open
emcniece opened this issue Oct 1, 2019 · 0 comments
Open

How to get values from pseudo-nested maps? #20

emcniece opened this issue Oct 1, 2019 · 0 comments

Comments

@emcniece
Copy link

emcniece commented Oct 1, 2019

Hey, thank you for your work! Still doing some testing, but I've got a quick question: is it possible to get nested values from fake nested maps?

Context: I'm kind of hacking 0.11.0 to have nested maps, unable to upgrade to 0.12.0. I've got some environments that I want to iterate through elsewhere, and I'm trying to figure out how to get & set values inside a structure that looks like this:

locals {
  "block1" = {
    dev.env1  = "dev-var1"
    dev.env2  = "dev-var2"
    prod.env1 = "prod-var1"
    prod.env2 = "prod-var2"
    cat       = "meow"
  }
  "block2" = {
    dev.env3  = "dev-var3"
    dev.env4  = "dev-var4"
    prod.env3 = "prod-var3"
    prod.env4 = "prod-var4"
  }
}

So far, the only value I can extract from here is this:

cat test.tf | hclq get 'locals.block1.cat'
"meow"

Attempting to access the other commands seems to all return []:

cat ./test.tf | hclq get 'locals.block1.dev'
cat ./test.tf | hclq get 'locals.block1.dev.*'
cat ./test.tf | hclq get 'locals.block1.dev[]'
cat ./test.tf | hclq get 'locals.block1.dev[].*'
cat ./test.tf | hclq get 'locals.block1.dev.env1'
cat ./test.tf | hclq get 'locals.block1.dev.env1*'
cat ./test.tf | hclq get 'locals.block1.dev.env1.*'
cat ./test.tf | hclq get 'locals.block1.dev.env1[]'

Do you by chance know if it's possible to get & set the value for one of these dot-notated dev.env1 values?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant