summaryrefslogtreecommitdiff
path: root/bin/03_sts
blob: 737f42715ff314217e58c08951117100ffb45ebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

set -e
cd "$(dirname "$0")/.."
HOST="${HOST:-http://localhost:8282}"

if [ $# -eq 0 ]; then
  echo "Usage:"
  echo "$0 <id_token> <role_arn>"
  exit 1
fi

ID_TOKEN="${1}"
ROLE_ARN="${2}"

echo "$ID_TOKEN" | ruby -rjson -rbase64 -e "puts Base64.decode64(STDIN.read.split('.')[1])" | jq '.'

aws sts assume-role-with-web-identity \
  --role-arn "${ROLE_ARN}" \
  --role-session-name="example-1" \
  --duration-seconds 900 \
  --web-identity-token="${ID_TOKEN}" \
  --output json | cat