Skip to content

Commit

Permalink
updated terraform_resources.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed Mar 2, 2022
1 parent 41bdc0b commit 68554ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions terraform_resources.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -euo pipefail
# sourcing lib.sh results in Terraform errors 'is_verbose: command not found'

usage="
Terraform external program that returns a list of root module resource names for a given resource_type
Terraform external program that returns a list of resource ids and attribute for a given resource_type
Workaround for Terraform Splat expressions not supporting top level resources
Expand Down Expand Up @@ -82,7 +82,12 @@ attribute="${2:-name}"

terraform show -json -no-color |
jq -er "
.values.root_module.resources[] |
.values.root_module |
[
.resources[],
.child_modules[].resources[]
] |
flatten[] |
select(.type == \"$resource_type\") |
select(.values.id) |
{ (.values.id) : .values.$attribute }" |
Expand Down

0 comments on commit 68554ad

Please sign in to comment.