feature(remote): improved tfe service discovery#254
feature(remote): improved tfe service discovery#254gringolito wants to merge 2 commits intofujiwara:mainfrom
Conversation
This commit enhances the `tfstateremote` support by implementing proper service discovery using Terraform's disco package to initialize the TFE client. This adds supports for all implementations of the Terraform Remote Backend (such as JFrog's Artifactory) and follows HashiCorp's service discovery patterns. Signed-off-by: Filipe Utzig <filipe@gringolito.com>
1f899af to
38fd428
Compare
|
@fujiwara Just checking in to see if you’ve had a chance to review the PR. I’d appreciate any feedback or thoughts you might have when you have a moment. |
|
@gringolito Thanks for the PR! I’m a bit busy at the moment, but I’ll take a look and provide feedback this weekend. |
|
First, this PR seems to work fine on my environment(Terraform Cloud). But I don't have other environment like Terraform Enterprise or JFrog's Artifactory. Second, This is not good because tfstate-lookup a library embedded into other products, for example ecspresso, helmfile/vals and etc. Once these issues are resolved, I'm planning to accept this PR. |
|
Thanks for the review. I've noticed the debug logs here too, but thought that was something that I had enabled locally, since this library is used by the Terraform project, let me find out how to disable them (on the Terraform binary this message is not printed to the stdout by default). About the Artifactory test, let me find if I can setup a bucket anywhere public where you can verify it yourself, but so far I've been using it successfully with Artifactory and Terraform Remote backend. |
|
I’ve been exploring a few options to address the logging behavior in the svchost package, and I’d really appreciate your input:
I'm currently leaning toward option 3, but I’d like to hear your thoughts before moving forward. |
|
Thank you for exploring the options. While switching to opentofu/svchost would solve the logging issue, I have concerns about using it
The service discovery feature itself is valuable, but we need a more stable solution for the logging issue. Options to consider:
|
|
I did some digging and verified that Terraform handles log redirection by setting its writer at initialization time. This means it delegates the responsibility of suppressing or redirecting CLI logs to the application rather than the libraries. As a result, the Terraform-provided libraries don’t try to control or silence log output, they assume the consuming application will handle it. You can see this behavior in the logging initialization code here: Adding log output directly within the library may not align with what current consumers are expecting. That said, it might make more sense for the consuming applications to configure their own logging infrastructure instead of relying on, or assuming, that all libraries will enforce the same logging behavior by default. |
I see. But, all products using tfstate-lookup as a library will be surprised when it update to a new version. I'll plan to workaround to hide debug logs. Thank you! |
|
@gringolito By the way, #254
How about this? |
So, I have to no choice but to do a dirty hack like Conclusion, This is problematic code as a library. |
This commit enhances the
remotesupport by implementing proper service discovery using Terraform's disco package to initialize the TFE client. This adds supports for all implementations of the Terraform Remote Backend (such as JFrog's Artifactory) and follows HashiCorp's service discovery patterns.