You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support Base64 encoding of raw MD5 digest bytes #39436
AWS WAF byte match rules can apply an MD5 text transformation to a request component before comparing it with SearchString. Writing such a rule requires the comparison value to be the Base64 encoding of the raw 16-byte MD5 digest.
Terraform's md5 function returns a hexadecimal string. base64encode(md5(value)) encodes the ASCII hexadecimal representation, not the raw digest bytes. The existing base64sha256 and base64sha512 functions provide the required behavior for their respective algorithms, but there is no MD5 equivalent or general conversion function.
This differs from converting between two provider arguments. The value is derived from arbitrary input and must match a transformation performed by the remote service.
Attempted Solutions
The closest expression using built-in functions is:
base64encode(md5(var.value))
This Base64-encodes the hexadecimal digest rather than the raw digest bytes.
A shell workaround is:
printf'%s'"$INPUT"| openssl dgst -md5 -binary | openssl base64 -A
Using this from Terraform requires an external data source, provider-defined function, or another out-of-process step. This adds dependencies and execution overhead for a deterministic transformation.
Proposal
Provide a built-in way to return the Base64 encoding of raw MD5 digest bytes.
One option is a base64md5 function, consistent with base64sha256 and base64sha512:
base64md5("hello world")
Alternatively, a general function that directly transcodes hexadecimal data to Base64 would allow composition without introducing binary strings:
base64_from_hex(md5("hello world"))
The exact API name is open for discussion. In either form, the result would be:
Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!
Activity
crw commentedon Oct 22, 2026
Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!
crw commentedon Oct 22, 2026
You might also file this in the AWS provider repo, and they could add a provider function to solve this problem. https://github.com/hashicorp/terraform-provider-aws/issues/new/choose