Using Credential created by AWS SSO for Terraform

@Heeseok-82, yes from what I can tell it is having an issue parsing the cached JSON files and the expiration timestamps. The error was showing the timestamp from the ~/.aws/sso/cached JSON file that has the SSO access token. Because of that error, it never appeared that it attempted to read the ~/.aws/cli/cached JSON file to get the access key id, secret access key and session token. I’m not sure exactly how the filename is generated but I assume it’s a hash of some data.

For now, you could write a script that runs the ~/.aws/cli/cached JSON file through jq and parses the .Credentials and exports them.

export AWS_ACCESS_KEY_ID=$(cat ~/.aws/cli/cached/[hash].json |jq .Credentials.AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(cat ~/.aws/cli/cached/[hash].json |jq .Credentials.SecretAccessKey)
export AWS_SESSION_TOKEN=$(cat ~/.aws/cli/cached/[hash].json |jq .Credentials.SessionToken)
1 Like