• HashiCorp Developer

  • HashiCorp Cloud Platform
  • Terraform
  • Packer
  • Consul
  • Vault
  • Boundary
  • Nomad
  • Waypoint
  • Vagrant
Terraform
  • Install
  • Tutorials
    • About the Docs
    • Configuration Language
    • Terraform CLI
    • Terraform Cloud
    • Terraform Enterprise
    • CDK for Terraform
    • Provider Use
    • Plugin Development
    • Registry Publishing
    • Integration Program
  • Registry(opens in new tab)
  • Try Cloud(opens in new tab)
  • Sign up
Terraform Home

Configuration Language

Skip to main content
  • Configuration Language
  • Data Sources
    • Overview
      • base64decode
      • base64encode
      • base64gzip
      • csvdecode
      • jsondecode
      • jsonencode
      • textdecodebase64
      • textencodebase64
      • urlencode
      • yamldecode
      • yamlencode
  • Upgrading to Terraform v1.3
  • v1.x Compatibility Promises

  • Terraform Internals

  • Resources

  • Tutorial Library
  • Certifications
  • Community Forum
    (opens in new tab)
  • Support
    (opens in new tab)
  • GitHub
    (opens in new tab)
  • Terraform Registry
    (opens in new tab)
  1. Developer
  2. Terraform
  3. Configuration Language
  4. Functions
  5. base64decode
  • Terraform
  • v1.2.x
  • v1.1 and earlier

ยปbase64decode Function

base64decode takes a string containing a Base64 character sequence and returns the original string.

Terraform uses the "standard" Base64 alphabet as defined in RFC 4648 section 4.

Strings in the Terraform language are sequences of unicode characters rather than bytes, so this function will also interpret the resulting bytes as UTF-8. If the bytes after Base64 decoding are not valid UTF-8, this function produces an error.

While we do not recommend manipulating large, raw binary data in the Terraform language, Base64 encoding is the standard way to represent arbitrary byte sequences, and so resource types that accept or return binary data will use Base64 themselves, which avoids the need to encode or decode it directly in most cases. Various other functions with names containing "base64" can generate or manipulate Base64 data directly.

base64decode is, in effect, a shorthand for calling textdecodebase64 with the encoding name set to UTF-8.

Examples

> base64decode("SGVsbG8gV29ybGQ=")
Hello World

Related Functions

  • base64encode performs the opposite operation, encoding the UTF-8 bytes for a string as Base64.
  • textdecodebase64 is a more general function that supports character encodings other than UTF-8.
  • base64gzip applies gzip compression to a string and returns the result with Base64 encoding.
  • filebase64 reads a file from the local filesystem and returns its raw bytes with Base64 encoding.
Edit this page on GitHub

On this page

  1. base64decode Function
  2. Examples
  3. Related Functions
Give Feedback(opens in new tab)
  • Certifications
  • System Status
  • Terms of Use
  • Security
  • Privacy
  • Trademark Policy
  • Trade Controls
  • Give Feedback(opens in new tab)