Skip to content

Commit bf6b5eb

Browse files
Print ec2-metadata error to stderr. Closes #28.
1 parent a1acb70 commit bf6b5eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

amazon-ec2-utils.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ rm -rf $RPM_BUILD_ROOT
7575
/etc/udev/rules.d/60-cdrom_id.rules
7676

7777
%changelog
78+
* Thu Jan 18 2024 Keith Gable <gablk@amazon.com> - 2.2.0-1
79+
- Corrected issue where an ec2-metadata error was written to stdout
80+
7881
* Mon Jun 5 2023 Guillaume Delacour <delacoug@amazon.com> - 2.2.0-1
7982
- Add `--quiet` option to `ec2-metadata --help` output
8083
- Add `-R`/`--region` option to `ec2-metadata` to discover the EC2 instance's region

ec2-metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
function print_help()
1010
{
11-
echo "ec2-metadata v0.1.3
11+
echo "ec2-metadata v0.1.4
1212
Use to retrieve EC2 instance metadata from within a running EC2 instance.
1313
e.g. to retrieve instance id: ec2-metadata -i
1414
to retrieve ami id: ec2-metadata -a
@@ -53,7 +53,7 @@ function set_imds_token()
5353
if [ -z "${IMDS_TOKEN}" ];then
5454
IMDS_TOKEN=$(curl -s -f -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 900" ${METADATA_BASEURL}/${METADATA_TOKEN_PATH})
5555
if [ "${?}" -gt 0 ] || [ -z "${IMDS_TOKEN}" ]; then
56-
echo '[ERROR] Could not get IMDSv2 token. Instance Metadata might have been disabled or this is not an EC2 instance.'
56+
echo '[ERROR] Could not get IMDSv2 token. Instance Metadata might have been disabled or this is not an EC2 instance.' >&2
5757
exit 1
5858
fi
5959
fi

0 commit comments

Comments
 (0)