-
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
Feature request: gunzip function #22568
Comments
Hi @jeffb4! Thanks for sharing this feature request. The Terraform language does not include raw binary buffers, so base64 strings are the standard way to represent small binary objects in memory in situations where you need to pass them around as values, rather than referring to files on disk. Therefore while we could potentially offer this functionality, it would have some constraints:
Doing this many encoding/decoding steps directly in Terraform configuration seems rather unfortunate, but we're assuming you're stuck doing this because Kubernetes wants a base64-encoded uncompressed object while your Parameter Store value is a base64-encoded compressed object, and neither of those services itself has enough information to know how to handle this compression difference. |
That is indeed precisely the case. For my case the result of the gunzip is a PEM-encoded certificate so the UTF-8 bytestream constraint is not problematic, although of course it would be great if tf could handle non-UTF-8 bytestreams in variables. Not that I have a use-case for the latter functionality. |
There's also value in using such a In my scenario, we use a module to generate user data and it gzips and base64 encodes the user data as an output. If the calling module could take this and decode/unzip the value, that would be really nice. |
Still need this. Its common sense that if you offer the |
bump--For us too it would be very helpful for debugging cloudinit files that are larger than the 16k max. Right now we have to wrap terraform in a script that grabs the json output of a tf plan, parses it, gunzipb64decode's it, runs it through diff, and presents it to the user so we can easily see the diff between what is there and what is being changed, since once you pass the gzip into user_data it is no longer human readable. Thanks! |
This is a valid use case for storing more data in aws parameter store and reading it back to used it in terraform. |
@apparentlymart @jbardin Is there any way to get this feature on the roadmap? Specifically, I am looking for the inverse function of |
If you are using the
instead of using the |
Thank you for your continued interest in this issue. Terraform version 1.8 launches with support of provider-defined functions. It is now possible to implement your own functions! We would love to see this implemented as a provider-defined function. Please see the provider-defined functions documentation to learn how to implement functions in your providers. If you are new to provider development, learn how to create a new provider with the Terraform Plugin Framework. If you have any questions, please visit the Terraform Plugin Development category in our official forum. We hope this feature unblocks future function development and provides more flexibility for the Terraform community. Thank you for your continued support of Terraform! |
This comment was marked as off-topic.
This comment was marked as off-topic.
Marking the comment "off-topic" as that is a question best asked in their repo / forums. |
Closing as not planned because you haven't done anything with this issue in 5 years. |
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. |
Current Terraform Version
Use-cases
I am using base64gzip to compress and store certificates in AWS Secrets Manager. Later I am (using Terraform) reading those secrets and injecting into Helm values as Kubernetes secrets resources. It would be useful for me to base64decode the retrieved secret, gunzip it, then base64encode it so that no further processing is needed in my Kubernetes pod to deal with the secret.
I am compressing with gzip to get around AWS Secrets Manager size limitations, so using base64encode to it instead is not a viable option.
Attempted Solutions
Within Terraform a current solution would look like writing the gzip data out to temporary files, running gunzip with a provisioner, and then reading the data back in with
file()
Proposal
a
gunzip()
function or possiblybase64gunzip()
(the latter mirrorsbase64gzip()
directly)References
The text was updated successfully, but these errors were encountered: