From bfc7d9619a7afe8aea5e0def4ed4af758ca4805a Mon Sep 17 00:00:00 2001 From: Noah Meyerhans Date: Fri, 14 Jul 2023 16:52:57 +0000 Subject: [PATCH] ec2: handle base64 encoded metadata Experience has shown that there are a number of tools and common patterns that effectively doubly base64 encode userdata. This change replaces a patch previously carried by Amazon Linux that was incorrectly ported to cloud-init 22.2.2 in Amazon Linux 2023 add addresses https://github.com/amazonlinux/amazon-linux-2023/issues/401 Signed-off-by: Noah Meyerhans --- cloudinit/sources/DataSourceEc2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudinit/sources/DataSourceEc2.py b/cloudinit/sources/DataSourceEc2.py index 2143873afde0..16eb2397f3ef 100644 --- a/cloudinit/sources/DataSourceEc2.py +++ b/cloudinit/sources/DataSourceEc2.py @@ -567,13 +567,14 @@ def crawl_metadata(self): else: exc_cb = exc_cb_ud = skip_cb = None try: - crawled_metadata["user-data"] = ec2.get_instance_userdata( + raw_userdata = ec2.get_instance_userdata( api_version, self.metadata_address, headers_cb=self._get_headers, headers_redact=redact, exception_cb=exc_cb_ud, ) + crawled_metadata["user-data"] = util.maybe_b64decode(raw_userdata) crawled_metadata["meta-data"] = ec2.get_instance_metadata( api_version, self.metadata_address,