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

Added ability to show specified types of resources #4232

Closed

Conversation

little-arhat
Copy link

New argument -resource-types for show command allows to specify list
of resource types, i.e. "aws_instance,aws_db_instance" to limit output
for these types.

This is useful for ad-hoc queries regarding Terraform state -- getting
list of particular attributes, like ip addresses or tags, etc.

Since output of terraform show is not json, where tools like jshon
can be applied to filter, it's useful to have smth like proposed changes.

New argument `-resource-types` for `show` command allows to specify list
of resource types, i.e. "aws_instance,aws_db_instance" to limit output
for these types.

This is useful for ad-hoc queries regarding Terraform state -- getting
list of particular attributes, like ip addresses or tags, etc.

Since output of `terraform show` is not json, where tools like `jshon`
can be applied to filter, it's useful to have smth like proposed changes.
@jen20
Copy link
Contributor

jen20 commented Dec 9, 2015

Hi @little-arhat! Thanks for submitting this. I'd agree this functionality could be hard to replicate using filters in a pipeline and could be valuable. Is there any chance you could add a context test or two to verify expected behaviour? If not I can likely look at doing so but it may take a while longer.

@little-arhat
Copy link
Author

@jen20 cool, will look into this! Do you have any comments on functionality itself? anything else we should think of, some corner cases maybe?

@little-arhat
Copy link
Author

@jen20 tests added

@jen20
Copy link
Contributor

jen20 commented Dec 21, 2015

Thanks @little-arhat! Sorry for the delay on reviewing this.

@little-arhat
Copy link
Author

@jen20 Happy New Year! is everything ok with this? any other suggestion/fixes you might think of?

@josephholsten
Copy link
Contributor

@phinze, @mitchellh this is ready for your 👀, has tests, needs doc

@phinze
Copy link
Contributor

phinze commented Feb 29, 2016

The implementation here looks good! But I'm a little worried about potential "flag sprawl" by adding this feature. Picturing possible ways you might want to filter terraform show output, I can think of -resource-names, -module-names, etc., not to mention the negation side of all those options.

I'm thinking it might be a better strategy to try to address terraform show output filtering in a more holistic way. Two ideas:

(a) Add a JSON output format to terraform show, which would let users slice and dice the output with something like jq
(b) Support the full -target syntax on terraform show which would keep things consistent but allow scoping the output.

In order to do filtering equivalent to this, you'd need something more like (a).

@josephholsten
Copy link
Contributor

@little-arhat @phinze Just wanted to note that the original recommendation for how to solve this: terraform show -json | jq ... has been taken off the table with #2460

Are we okay with "(b) Support the full -target syntax on terraform show which would keep things consistent but allow scoping the output."

@mildwonkey
Copy link
Contributor

Hi folks! Sorry for the long, long silence here.

Now that terraform show has a -json flag which will let users (consistently!) "slice and dice the output" (to borrow phinze's phrase), I am going to close this PR. Thanks for all your work and the good conversation!

@mildwonkey mildwonkey closed this Aug 16, 2019
@ghost
Copy link

ghost commented Sep 16, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Sep 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants