-
Notifications
You must be signed in to change notification settings - Fork 64
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
Extract nested json value via variable #129
Comments
Hi @derekleegh, |
@carlpett thanks for coming back to me. This use case comes from our org where we want to store a json block in parameter store rather than just single value. So as an example, we have the following secrets.json
We want to extract the Database section and store it as a single parameter store value. Workaround for now is we can achieve this by doing However, in terraform we would like the This will gives us flexibility of extracting the secrets using for_loop. Alternatively via the map values where data.sops_file.demo-secret.data["${var.secret_position}"] like this. |
Hey @derekleegh. Have you tried the Something like lookup(jsondecode(data.sops_file.demo-secret.raw), var.secret_position, {}) should work. |
Hi,
I have a unique use case here if I can get your advice on what is the best approach.
Based on your example on README.md, I would like to extract the
db
and get the value as a json.value = {"password": "bar"}
It works with your
jsondecode(data.sops_file.demo-secret.raw).db
How can i pass the
.db
as an variable?What i want to achieve is something like this:
jsondecode(data.sops_file.demo-secret.raw)[var.key]
where var.key is '.db'The idea is that the key we want to extract can be a variable without hardcoding the
.db
Hope you can help me with this use case.
Thanks
The text was updated successfully, but these errors were encountered: