File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,8 @@ exec_with_fulljitter_retry() {
97
97
# Writes to STDOUT the AWS region as known by the local instance.
98
98
get_instance_region () {
99
99
if [ -z " $AWS_REGION " ]; then
100
- AWS_REGION=$( curl -s http://169.254.169.254/latest/dynamic/instance-identity/document \
101
- | grep -i region \
102
- | awk -F\" ' {print $4}' )
100
+ TOKEN=$( curl -X PUT " http://169.254.169.254/latest/api/token" -H " X-aws-ec2-metadata-token-ttl-seconds: 21600" )
101
+ AWS_REGION=$( curl -H " X-aws-ec2-metadata-token: $TOKEN " -s http://169.254.169.254/latest/meta-data/placement/region)
103
102
fi
104
103
105
104
echo $AWS_REGION
@@ -706,6 +705,7 @@ error_exit() {
706
705
# Writes to STDOUT the EC2 instance ID for the local instance. Returns non-zero if the local
707
706
# instance metadata URL is inaccessible.
708
707
get_instance_id () {
709
- curl -s http://169.254.169.254/latest/meta-data/instance-id
708
+ TOKEN=$( curl -X PUT " http://169.254.169.254/latest/api/token" -H " X-aws-ec2-metadata-token-ttl-seconds: 21600" )
709
+ curl -H " X-aws-ec2-metadata-token: $TOKEN " -s http://169.254.169.254/latest/meta-data/instance-id
710
710
return $?
711
711
}
You can’t perform that action at this time.
0 commit comments