terraform-provider-cloudinit
terraform-provider-cloudinit copied to clipboard
Support non-ASCII encoded parts
Terraform CLI and Provider Versions
terraform version
:
Terraform v1.4.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.2
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/hetznercloud/hcloud v1.42.1
+ provider registry.terraform.io/integrations/github v5.34.0
+ provider registry.terraform.io/tenstad/remote v0.1.2
Your version of Terraform is out of date! The latest version
is 1.5.6. You can update by downloading from https://www.terraform.io/downloads.html
Use Cases or Problem Statement
The cloud-init provider sets Content-Transfer-Encoding
to 7bit
and doesn't make that configurable. This prevent users from having non-ASCII encoded payloads, such as UTF-8 encoded text with characters above the 0x7F code point.
Proposal
There are two encodings that "officially" allow non-ASCII characters in MIME body: quoted-printable and base64. Terraform does not provide a built-in way to escape a string with the quoted-printable style, as defined in RFC 2045, which leave the base64 encoding, which is provided by the textencodebase64 function. This is why I lean towards using base64 encoding rather than quoted-printable escaping.
I suggest we let the user decide a value for Content-Transfer-Encoding
in part
blocks, with a default of 7bit
. This way the cloud-init provider can stay dumb (the user is responsible for providing sensible values to the arguments (this is already the case as of today)) and there are no retro-compatibility issues.
Otherwise, we could do the "smart" thing automatically: If we detect bytes greater than 0x7F in content
, we automatically encode the content to base64 and we set Content-Transfer-Encoding
to base64
. This is a simple behavior that should always work, if we believe the RFCs. This shouldn't break retro-compatibility because cloud-init is unable to read MIME that have Content-Transfer-Encoding
set to 7bit
and a body with characters greater than 0x7F. The error looks like this:
cloud-init[929]: 2023-09-05 12:00:00,000 - util.py[WARNING]: Failed loading yaml blob. unacceptable character #xdce9: special characters are not allowed in "<unicode string>", position 6783
cloud-init[929]: 2023-09-05 12:00:00,000 - cloud_config.py[WARNING]: Failed at merging in cloud config part from init.cfg: empty cloud config
Working configurations will keep working. Broken configurations will at best start working and at worst stay broken.
How much impact is this issue causing?
Medium
Additional Information
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Hello @austinvalle, I'm sorry to ping you, but I'd like to bring your attention to this three months old issue, which have a small pull request (https://github.com/hashicorp/terraform-provider-cloudinit/pull/170) waiting. It seems to me that you are the only maintainer for this provider currently.