aws sts get-caller-identity

From wikieduonline
Jump to navigation Jump to search

aws sts get-caller-identity command outputs three pieces of information including the ARN.


  • aws sts get-caller-identity
  • aws sts get-caller-identity --profile XXXXX
  • aws sts get-caller-identity --output text --query 'Account'
  • ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account')


aws sts get-caller-identity
    "Account": "09876543212",
    "Arn": "arn:aws:iam::09876543212:user/your_user"
    "UserId": "AROASTNMATSFIGC3RFZFC:martin.oscar",
    "Account": "09876543212",
    "Arn": "arn:aws:sts::09876543212:assumed-role/AWSReservedSSO_AdministratorAccess_111111111/your-username"


aws sts get-caller-identity
Unable to locate credentials. You can configure credentials by running "aws configure".
aws sts get-caller-identity
An error ocurred (InvalidClientTokenId) when calling the GetCallerIdentity operation: The security token included in the request is invalid
Traceback (most recent call last):
 File "/usr/local/bin/aws", line 19, in <module>
   import awscli.clidriver
 File "/usr/local/lib/python3.6/site-packages/awscli/", line 17, in <module>
   import botocore.session
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 29, in <module>
   import botocore.credentials
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 35, in <module>
   from botocore.config import Config
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 16, in <module>
   from botocore.endpoint import DEFAULT_TIMEOUT, MAX_POOL_CONNECTIONS
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 24, in <module>
   from botocore.awsrequest import create_request_object
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 24, in <module>
   import botocore.utils
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 32, in <module>
   import botocore.httpsession
 File "/usr/local/lib/python3.6/site-packages/botocore/", line 10, in <module>
   from urllib3.util.ssl_ import (
ImportError: cannot import name 'PROTOCOL_TLS'


See also[edit]