Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _get_metadata(metadata_path):
:return the metadata value.
"""
try:
metadata_value = requests.get("http://169.254.169.254/latest/meta-data/{0}".format(metadata_path)).text
metadata_value = requests.get("https://169.254.169.254/latest/meta-data/{0}".format(metadata_path)).text
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.

Do not hardcode IP addresses because they aren't always static and might change. It also makes them vulnerable to attacks like denial of service and IP spoofing to bypass security checks. We recommend that you use environment variables or configuration files to make the IP address configurable.

Learn more

except Exception as e:
error_msg = "Unable to get {0} metadata. Failed with exception: {1}".format(metadata_path, e)
log.critical(error_msg)
Expand Down