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
EC2 tags, that have a space, cause ohai ec2 to return empty data during its run. We are currently using SSM to patch our EC2 instances and we are required (by AWS) to use the tag 'Patch Group' to utilize the SSM patching process. Due to this, ohai ec2 returns empty data on instances with this tag. The issue is that the metadata_get method is not creating the path (used in http_client.get) with %20 for tags with spaces.
Example: The tag 'Patch Group' will have a path of /2021-07-15/meta-data/tags/instance/Patch Group and that will create an invalid URL. A path of /2021-07-15/meta-data/tags/instance/Patch%20Group is valid and will return data.
Software Version
ohai 17.9.0 on Windows 2016/2019 hosts and soon centos hosts.
Replication Case
Find/create an EC2 Windows instance to test with
Disable 'Allow tags in instance metadata'
Add 'Patch Group' as a tag and enter any value
RDP to the host and open an elevated cmd prompt and execute ohai ec2
The output of the command will be empty
Possible Solution
The way I found to fix this issue was to update the ec2_metadata.rbmetadata_get method by adding id = id.gsub(" ", "%20") right after the line def metadata_get(id, api_version). I am sure there is a better way of performing this fix, but this was a quick fix for me. Let me know if you need any additional information. Thank you
The text was updated successfully, but these errors were encountered:
Describe the problem
EC2 tags, that have a space, cause
ohai ec2
to return empty data during its run. We are currently using SSM to patch our EC2 instances and we are required (by AWS) to use the tag 'Patch Group' to utilize the SSM patching process. Due to this,ohai ec2
returns empty data on instances with this tag. The issue is that themetadata_get
method is not creating thepath
(used in http_client.get) with %20 for tags with spaces.Example: The tag 'Patch Group' will have a path of
/2021-07-15/meta-data/tags/instance/Patch Group
and that will create an invalid URL. A path of/2021-07-15/meta-data/tags/instance/Patch%20Group
is valid and will return data.Software Version
ohai 17.9.0 on Windows 2016/2019 hosts and soon centos hosts.
Replication Case
ohai ec2
Possible Solution
The way I found to fix this issue was to update the
ec2_metadata.rb
metadata_get
method by addingid = id.gsub(" ", "%20")
right after the linedef metadata_get(id, api_version)
. I am sure there is a better way of performing this fix, but this was a quick fix for me. Let me know if you need any additional information. Thank youThe text was updated successfully, but these errors were encountered: