i have aws access key and secret key with me. i wanted session token to be updated in aws credential file (~/.aws/credentials), how will i get it?
I want them to be generated in command line.
i have aws access key and secret key with me. i wanted session token to be updated in aws credential file (~/.aws/credentials), how will i get it?
I want them to be generated in command line.
$aws sts get-session-token --duration-seconds 129600
Here 129600 can be any time you want to specify after which the keys will expire. This command will give the output like below.
{
"Credentials": {
"SecretAccessKey": "Sb5pXXXXXQY3/qPoL/jUjMyXXXXXuev/0j3vXs",
"SessionToken": "FQoGZXIvYXdzENv//////////wEaDEeLj11xTbnBk6azRCKsAacCiJK85DSXExJ81GtHrkEyev8eedQcFY4EoM00PsD1FAEMOfzQclVEFsoh9Y4ZHUjgGmCPRUnYCLNc2NnHkadvmI+MT7jRRa1Mo2HA/HYStOOwEyfXFYG91MNj9rVXXXXXXXXA6+7FF6jcxj3cr1U9CDB9hjW+jGq4UgjxXXXXXXXCoIidDjl4Z911zIzP/Q+FYA1R2CUz5Y32EUaMzR+bQvmheUolLOq3wU=",
"Expiration": "2018-11-14T21:29:56Z",
"AccessKeyId": "ASIXXXXXXXXZ27X"
}
}
You don't.
AWS_SESSION_TOKEN is not used when you have IAM User access and secret keys.
It's only needed when you use IAM Role - either through Cross-account access, or EC2 instance role, etc.
You can use get-session-token with below parameters.
get-session-token
[--duration-seconds <value>]
[--serial-number <value>]
[--token-code <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]
https://docs.aws.amazon.com/cli/latest/reference/sts/get-session-token.html