Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

Commit 00a62f9

Browse files
Alexander TarasovAlexander Tarasov
Alexander Tarasov
and
Alexander Tarasov
authored
Add support for AWS IMDSv2 (#158)
Co-authored-by: Alexander Tarasov <[email protected]>
1 parent 1196ff4 commit 00a62f9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

import_users.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ fi
6161
: ${USERDEL_ARGS:="--force --remove"}
6262

6363
# Initizalize INSTANCE variable
64-
INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
65-
REGION=$(curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
64+
METADATA_TOKEN=$(curl -s -X PUT -H 'x-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token)
65+
INSTANCE_ID=$(curl -s -H "x-aws-ec2-metadata-token: ${METADATA_TOKEN}" http://169.254.169.254/latest/meta-data/instance-id)
66+
REGION=$(curl -s -H "x-aws-ec2-metadata-token: ${METADATA_TOKEN}" http://169.254.169.254/latest/dynamic/instance-identity/document | grep region | awk -F\" '{print $4}')
6667

6768
function setup_aws_credentials() {
6869
local stscredentials

0 commit comments

Comments
 (0)