How to test your AWS CLI credentials

To test ability to connect to AWS with newly created Access Key ID and Secret Access Key you need to use the following command:

aws sts get-caller-identity

This command will utilize GetCallerIdentity API call.

You may need to provide additional parameters like –profile my_new_profile, if you created AWS security key pair for additional account.

Unlike other API/CLI calls it will always work, regardless of your IAM permissions.

You will get the output in the following format if everything is OK:

{
  "Account": "000654207548",
  "UserId": "AIDAJID6SZSGMUGC5T3YA",
  "Arn": "arn:aws:iam::000654207548:user/k8s"
}

Authors


Author avatar
Andrei Maksimov

I’m a passionate Cloud Infrastructure Architect with more than 15 years of experience in IT.

Let’s discuss your AWS questions if you still have them.

This post represents my personal experience and opinion about the topic.