A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.hashicorp.com/terraform/language/v1.10.x/functions/base64gzip below:

base64gzip function reference - Functions - Configuration Language | Terraform

base64gzip function reference

This topic provides reference information about the base64gzip function. The base64gzip function compresses an HCL string using gzip and then encodes the string using Base64 encoding.

You can use the base64gzip function to compress an HCL string and then encode it in the Base64 format. Terraform uses the standard Base64 alphabet that is defined in RFC 4648.

While HashiCorp does not recommend manipulating large, raw binary data in HCL, Base64 encoding can be an effective way to represent small binary objects in memory when you need to pass them as values, rather than referring to files on disk. For example, you could use the base64gzip function to compress a large JSON string so that you can upload it to S3.

Because HCL strings are sequences of unicode characters rather than bytes, base64gzip first encodes the characters in the string as UTF-8. Then it applies gzip compression and encodes the string using Base64 format.

Use the base64gzip function with the following syntax:

The argument is the string that you want to compress and encode.

In the following example, the function compresses the string at local.my_data and encodes it using the Base64 format.

base64gzip(local.my_data)

The following example defines a local value my_data that contains the string you want to compress and encode. The base64gzip function compresses and encodes the string, and then it is used to populate an S3 bucket.

resource "aws_s3_object" "example" {
  bucket = "my_bucket"
  key = "example.txt"
  content_base64 = base64gzip(local.my_data)
  content_encoding = "gzip"
}

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4