Skip to content

Add terraform query subcommand (TF-25494) #37174

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

dbanck
Copy link
Member

@dbanck dbanck commented May 28, 2025

WIP

Target Release

1.13.x

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@dbanck dbanck added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label May 28, 2025
@dbanck dbanck force-pushed the dbanck/tfquery-cli branch from 69f538d to 5964722 Compare May 28, 2025 13:14
@dbanck dbanck force-pushed the dbanck/tfquery-cli branch from 5964722 to 788a724 Compare May 28, 2025 13:20
@hashicorp hashicorp deleted a comment from github-actions bot May 28, 2025
@hashicorp hashicorp deleted a comment from github-actions bot May 28, 2025
@dsa0x dsa0x force-pushed the sams/tfquery-execute branch 2 times, most recently from 518bd67 to 4ff576a Compare June 4, 2025 14:19
@dsa0x dsa0x force-pushed the sams/tfquery-execute branch 4 times, most recently from ee5b81f to 0d9f62d Compare June 10, 2025 09:01
@dbanck dbanck force-pushed the dbanck/tfquery-cli branch from 788a724 to ad7d289 Compare June 10, 2025 14:42
@dsa0x dsa0x force-pushed the sams/tfquery-execute branch from 0d9f62d to b0a7c2e Compare June 10, 2025 15:56
Base automatically changed from sams/tfquery-execute to sams/list-result-schema June 10, 2025 17:38
Base automatically changed from sams/list-result-schema to main June 10, 2025 18:08
@dbanck dbanck force-pushed the dbanck/tfquery-cli branch from ad7d289 to 5651d47 Compare June 11, 2025 07:53
Copy link
Member

@liamcervante liamcervante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some very early thoughts that jumped out to me - don't need to be addressed properly yet or anything.


ProviderAddr addrs.AbsProviderConfig

Results cty.Value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Results cty.Value
Results []cty.Value

Since this must be a slice / tuple - is it perhaps more clear to just not include that part in the cty encoding? This makes it totally unambiguous that this is a list of things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we're storing the result in the following form:

cty.ObjectVal(map[string]cty.Value{"data": cty.TupleVal(results), "config": config})

This matches the schema and makes encoding/decoding easy, but I guess we really only need the tuple val in the plan 🤔


ProviderAddr addrs.AbsProviderConfig

Results cty.Value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metanote: because of the way things might change over time this may eventually become a list of structs in which one of the things that it might contain is the value. We might add some metadata about the query results (like you see in the ResourceInstanceChange for example.

This representation can change as it likes (as it is internal only) but eventually this will go into the jsonplan package which has to be more backwards compatible. At that point - I'd pre-emptively add this into a json object instead of just adding the value directly. This makes it easier to add metadata in the future, as it wouldn't be a breaking change.

You could also do that here as well, to keep the internal and external representations closer together. But, that is totally optional for here, but definitely something you should consider for the external representation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants