# Shell Spell: Extracting and Propagating Multiple Values With jq

DevFeed: [Shell Spell: Extracting and Propagating Multiple Values With jq](<https://devfeed.tech/articles/shell-spell-extracting-and-propagating-multiple-values-with-jq-18815.md>)

Original publisher: [Read original article](<https://www.morling.dev/blog/extracting-and-propagating-multiple-values-with-jq/>)

Published: 2024-07-06T09:20:00Z

Content type: tutorial

Language: en

Sources: [Gunnar Morling](<https://devfeed.tech/sources/gunnar-morling.md>)

Topics: [Terraform](<https://devfeed.tech/topics/terraform.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Bash](<https://devfeed.tech/topics/bash.md>), [Amazon RDS](<https://devfeed.tech/topics/amazon-rds.md>), [Database](<https://devfeed.tech/topics/database.md>)

Tags: [amazon-rds](<https://devfeed.tech/tags/amazon-rds.md>), [cli](<https://devfeed.tech/tags/cli.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [commands](<https://devfeed.tech/tags/commands.md>), [json](<https://devfeed.tech/tags/json.md>), [password](<https://devfeed.tech/tags/password.md>), [postgres](<https://devfeed.tech/tags/postgres.md>), [terraform](<https://devfeed.tech/tags/terraform.md>)

## AI overview

A hands-on tutorial showing how to use shell pipelines and jq with Terraform state to retrieve a dynamically generated database password and host from an Amazon RDS-backed Postgres setup, then pass both values to psql.

## Source excerpt

In my day job at Decodable, I am currently working with Terraform to provision some cloud infrastructure for an upcoming hands-on lab. Part of this set-up is a Postgres database on Amazon RDS, which I am creating using the Terraform AWS modules. Now, once my database was up and running, I wanted to extract two dynamically generated values from Terraform: the random password created for the root user, and the database host URL. On my way down the rabbit hole for finding a CLI command for doing this efficiently, I learned a few interesting shell details which I'd like to share.