From 2cea235a1865f571fe134712b9fffb21aa2d64b8 Mon Sep 17 00:00:00 2001 From: Keith Gable Date: Tue, 17 Dec 2024 13:12:40 -0800 Subject: [PATCH 1/7] Add --aws-domain option to ec2-metadata to get the top level service domain name --- ec2-metadata | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ec2-metadata b/ec2-metadata index 8405682..d6564dc 100755 --- a/ec2-metadata +++ b/ec2-metadata @@ -8,7 +8,7 @@ function print_help() { -echo "ec2-metadata v0.1.4 +echo "ec2-metadata v0.1.5 Use to retrieve EC2 instance metadata from within a running EC2 instance. e.g. to retrieve instance id: ec2-metadata -i to retrieve ami id: ec2-metadata -a @@ -23,6 +23,7 @@ Options: -l/--ami-launch-index The index of this instance in the reservation (per AMI). -m/--ami-manifest-path The manifest path of the AMI with which the instance was launched. -n/--ancestor-ami-ids The AMI IDs of any instances that were rebundled to create this AMI. +-D/--aws-domain The root domain name that AWS uses in this region -b/--block-device-mapping Defines native device names to use when exposing virtual devices. -i/--instance-id The ID of this instance -t/--instance-type The type of instance to launch. For more information, see Instance Types. @@ -136,6 +137,7 @@ function print_all() print_normal_metric ami-launch-index meta-data/ami-launch-index print_normal_metric ami-manifest-path meta-data/ami-manifest-path print_normal_metric ancestor-ami-ids meta-data/ancestor-ami-ids + print_normal_metric aws-domain meta-data/services/domain print_block-device-mapping print_normal_metric instance-id meta-data/instance-id print_normal_metric instance-type meta-data/instance-type @@ -165,8 +167,8 @@ if [ "$#" -eq 0 ]; then fi declare -a actions -shortopts=almnbithokzPcpvuresdgR -longopts=(ami-id ami-launch-index ami-manifest-path ancestor-ami-ids block-device-mapping +shortopts=almnDbithokzPcpvuresdgR +longopts=(ami-id ami-launch-index ami-manifest-path ancestor-ami-ids aws-domain block-device-mapping instance-id instance-type local-hostname local-ipv4 kernel-id availability-zone partition product-codes public-hostname public-ipv4 public-keys ramdisk-id reservation-id security-groups user-data tags region help all quiet) @@ -214,6 +216,7 @@ for action in "${actions[@]}"; do -l | --ami-launch-index ) print_normal_metric ami-launch-index meta-data/ami-launch-index ;; -m | --ami-manifest-path ) print_normal_metric ami-manifest-path meta-data/ami-manifest-path ;; -n | --ancestor-ami-ids ) print_normal_metric ancestor-ami-ids meta-data/ancestor-ami-ids ;; + -D | --aws-domain ) print_normal_metric aws-domain meta-data/services/domain ;; -b | --block-device-mapping ) print_block-device-mapping ;; -i | --instance-id ) print_normal_metric instance-id meta-data/instance-id ;; -t | --instance-type ) print_normal_metric instance-type meta-data/instance-type ;; From 5f058b97d07024a3504128c3e4a5e796fc2bf27a Mon Sep 17 00:00:00 2001 From: Keith Gable Date: Tue, 17 Dec 2024 13:14:31 -0800 Subject: [PATCH 2/7] Use the same indentation --- ec2-metadata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ec2-metadata b/ec2-metadata index d6564dc..564c3c4 100755 --- a/ec2-metadata +++ b/ec2-metadata @@ -216,7 +216,7 @@ for action in "${actions[@]}"; do -l | --ami-launch-index ) print_normal_metric ami-launch-index meta-data/ami-launch-index ;; -m | --ami-manifest-path ) print_normal_metric ami-manifest-path meta-data/ami-manifest-path ;; -n | --ancestor-ami-ids ) print_normal_metric ancestor-ami-ids meta-data/ancestor-ami-ids ;; - -D | --aws-domain ) print_normal_metric aws-domain meta-data/services/domain ;; + -D | --aws-domain ) print_normal_metric aws-domain meta-data/services/domain ;; -b | --block-device-mapping ) print_block-device-mapping ;; -i | --instance-id ) print_normal_metric instance-id meta-data/instance-id ;; -t | --instance-type ) print_normal_metric instance-type meta-data/instance-type ;; From 58f596f29833a5b6eaa37f25d792824989c68ee7 Mon Sep 17 00:00:00 2001 From: Keith Gable Date: Tue, 17 Dec 2024 14:27:14 -0800 Subject: [PATCH 3/7] Add spec entry --- amazon-ec2-utils.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amazon-ec2-utils.spec b/amazon-ec2-utils.spec index 0a22509..0dee95e 100644 --- a/amazon-ec2-utils.spec +++ b/amazon-ec2-utils.spec @@ -1,6 +1,6 @@ Name: amazon-ec2-utils Summary: A set of tools for running in EC2 -Version: 2.2.0 +Version: 2.2.1 Release: 1%{?dist} License: MIT Group: System Tools @@ -78,6 +78,9 @@ rm -rf $RPM_BUILD_ROOT /etc/udev/rules.d/60-cdrom_id.rules %changelog +* Tue Dec 17 2024 Keith Gable - 2.2.1-1 +- Add support for --aws-domain to ec2-metadata + * Wed May 29 2024 Kuniyuki Iwashima - 2.2.1 - Add symlink for ENA PTP device. From 9d6389a94d14e1e5dc5228b5dbbe889aee256872 Mon Sep 17 00:00:00 2001 From: Ziggy Gable Date: Mon, 25 Aug 2025 14:16:48 -0700 Subject: [PATCH 4/7] Bump the version number --- ec2-metadata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ec2-metadata b/ec2-metadata index ca2e50d..57798fc 100755 --- a/ec2-metadata +++ b/ec2-metadata @@ -8,7 +8,7 @@ function print_help() { -echo "ec2-metadata v0.1.5 +echo "ec2-metadata v0.1.6 Use to retrieve EC2 instance metadata from within a running EC2 instance. e.g. to retrieve instance id: ec2-metadata -i to retrieve ami id: ec2-metadata -a From 1bd9fc4c8125c0b85592d5409551eb6dc4901dd8 Mon Sep 17 00:00:00 2001 From: Ziggy Gable Date: Mon, 25 Aug 2025 14:32:19 -0700 Subject: [PATCH 5/7] Stop hard-coding the version number in the help output --- ec2-metadata | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ec2-metadata b/ec2-metadata index 57798fc..4c8ae4a 100755 --- a/ec2-metadata +++ b/ec2-metadata @@ -8,7 +8,7 @@ function print_help() { -echo "ec2-metadata v0.1.6 +echo "ec2-metadata v%EC2_METADATA_VERSION% Use to retrieve EC2 instance metadata from within a running EC2 instance. e.g. to retrieve instance id: ec2-metadata -i to retrieve ami id: ec2-metadata -a From cc1a1fb1cac90f5391ec7ff5ac8774a6e861489f Mon Sep 17 00:00:00 2001 From: Ziggy Gable Date: Mon, 25 Aug 2025 14:33:03 -0700 Subject: [PATCH 6/7] Ensure the ec2-metadata script uses the version number of the RPM --- amazon-ec2-utils.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amazon-ec2-utils.spec b/amazon-ec2-utils.spec index 8666dca..ac526e5 100644 --- a/amazon-ec2-utils.spec +++ b/amazon-ec2-utils.spec @@ -25,6 +25,7 @@ Provides: ec2-metadata = %{version}-%{release} Obsoletes: ec2-metadata <= 0.1.3 Requires: curl Requires: python3 +BuildRequires: sed BuildRequires: python3-devel BuildRequires: systemd-rpm-macros BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) @@ -35,6 +36,7 @@ amazon-ec2-utils contains a set of utilities for running in ec2. %prep %build +sed "s/%EC2_METADATA_VERSION%/%version/" %{SOURCE0} > ec2-metadata %install rm -rf $RPM_BUILD_ROOT @@ -44,7 +46,7 @@ mkdir -p $RPM_BUILD_ROOT%{_sbindir} mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/ mkdir -p $RPM_BUILD_ROOT%{_mandir}/man8/ -install -m755 %{SOURCE0} $RPM_BUILD_ROOT%{_bindir} +install -m755 ec2-metadata $RPM_BUILD_ROOT%{_bindir} install -m755 %{SOURCE1} $RPM_BUILD_ROOT%{_sbindir} install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_udevrulesdir} install -m755 %{SOURCE24} $RPM_BUILD_ROOT%{_sbindir} From 7854f8293061d853609df0724e8a6b31935dad01 Mon Sep 17 00:00:00 2001 From: Ziggy Gable Date: Mon, 25 Aug 2025 14:33:53 -0700 Subject: [PATCH 7/7] Update changelog --- amazon-ec2-utils.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/amazon-ec2-utils.spec b/amazon-ec2-utils.spec index ac526e5..da374fd 100644 --- a/amazon-ec2-utils.spec +++ b/amazon-ec2-utils.spec @@ -83,13 +83,13 @@ rm -rf $RPM_BUILD_ROOT /etc/udev/rules.d/60-cdrom_id.rules %changelog -* Tue Dec 17 2024 Keith Gable - 2.2.1-1 +* Mon Aug 25 2025 Ziggy Gable - 2.2.1-1 - Add support for --aws-domain to ec2-metadata * Wed May 29 2024 Kuniyuki Iwashima - 2.2.1 - Add symlink for ENA PTP device. -* Thu Jan 18 2024 Keith Gable - 2.2.0-1 +* Thu Jan 18 2024 Ziggy Gable - 2.2.0-1 - Corrected issue where an ec2-metadata error was written to stdout - Change ec2nvme-nsid to use Bash string manipulation to improve performance and reliability