-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Conversation
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.
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. |
@jen20 cool, will look into this! Do you have any comments on functionality itself? anything else we should think of, some corner cases maybe? |
@jen20 tests added |
Thanks @little-arhat! Sorry for the delay on reviewing this. |
@jen20 Happy New Year! is everything ok with this? any other suggestion/fixes you might think of? |
@phinze, @mitchellh this is ready for your 👀, has tests, needs doc |
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 In order to do filtering equivalent to this, you'd need something more like (a). |
@little-arhat @phinze Just wanted to note that the original recommendation for how to solve this: Are we okay with "(b) Support the full -target syntax on terraform show which would keep things consistent but allow scoping the output." |
Hi folks! Sorry for the long, long silence here. Now that |
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. |
New argument
-resource-types
forshow
command allows to specify listof 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 likejshon
can be applied to filter, it's useful to have smth like proposed changes.