Skip to content

Commit 09bd58e

Browse files
authored
Merge pull request #119 from rishij39/fix-credentials-script
Adding TOKEN as header to curl command for INSTANCE_ROLE and Region
2 parents a5117a4 + 8a22809 commit 09bd58e

File tree

1 file changed

+2
-2
lines changed
  • static/files/dynamodb-opensearch-zetl/OpenSearchPipeline

1 file changed

+2
-2
lines changed

static/files/dynamodb-opensearch-zetl/OpenSearchPipeline/credentials.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
2-
INSTANCE_ROLE=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)
2+
INSTANCE_ROLE=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/)
33
RESULTS=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/security-credentials/${INSTANCE_ROLE})
44

55
AccessKeyId=$(echo $RESULTS | jq -r '.AccessKeyId')
66
SecretAccessKey=$(echo $RESULTS | jq -r '.SecretAccessKey')
7-
Region=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')
7+
Region=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/')
88
Token=$(echo $RESULTS | jq -r '.Token')
99
Role=$(aws sts get-caller-identity | jq -r '.Arn | sub("sts";"iam") | sub("assumed-role";"role") | sub("/i-[a-zA-Z0-9]+$";"")')
1010

0 commit comments

Comments
 (0)