From 786bb1e9380e7076467d35050ef0e1cb457d1af9 Mon Sep 17 00:00:00 2001 From: Wouter Devriendt Date: Mon, 4 Nov 2024 22:51:11 -0800 Subject: [PATCH] upgrade metadata call to use IMDSv2, only supported version soon (#2532) Summary: Soon we will only support metadata fetching for EC2 instances via IMDSv2 - this upgrades the existing v1 call to a v2 call - no functional changes Pull Request resolved: https://github.com/pytorch/torchrec/pull/2532 Test Plan: testing if the release_build.yaml workflow correctly fetches the instance metadata NOTE: this workflow only runs on pypi release Reviewed By: wdvr Differential Revision: D65448148 Pulled By: PaulZhang12 fbshipit-source-id: ebc54fae3c0d27daac043ddc27d5e1ac17549dfc --- .github/workflows/release_build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml index 8be8ea628..1ea837d4b 100644 --- a/.github/workflows/release_build.yml +++ b/.github/workflows/release_build.yml @@ -132,7 +132,7 @@ jobs: # Pulled from instance metadata endpoint for EC2 # see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html category=$1 - curl -fsSL "http://169.254.169.254/latest/meta-data/${category}" + curl -H "X-aws-ec2-metadata-token: $(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 30")" -fsSL "http://169.254.169.254/latest/meta-data/${category}" } echo "ami-id: $(get_ec2_metadata ami-id)" echo "instance-id: $(get_ec2_metadata instance-id)"