- The OpenTofu Language
- Functions
- base64gzip
base64gzip Function
base64gzip compresses a string with gzip and then encodes the result in
Base64 encoding.
OpenTofu uses the "standard" Base64 alphabet as defined in RFC 4648 section 4.
Strings in the OpenTofu language are sequences of unicode characters rather than bytes, so this function will first encode the characters from the string as UTF-8, then apply gzip compression, and then finally apply Base64 encoding.
While we do not recommend manipulating large, raw binary data in the OpenTofu language, this function can be used to compress reasonably sized text strings generated within the OpenTofu language. For example, the result of this function can be used to create a compressed object in Amazon S3 as part of an S3 website.
The implementation of this function changed between the OpenTofu v1.12 and v1.13 series. The result for any given input is equivalent but not byte-for-byte identical between the two releases, and so resource configuration arguments defined with this function will propose changes when upgrading across that version boundary.
If you cannot apply the proposed changes immediately then consider using
the ignore_changes meta-argument
to cause OpenTofu to temporarily ignore the different function result, which
you can then remove once you're ready to switch to the new encoding.
Related Functions​
base64encodeapplies Base64 encoding without gzip compression.filebase64reads a file from the local filesystem and returns its raw bytes with Base64 encoding.