Last updated: Feb 26, 2024
Reading time·1 min

To validate a user's credentials with the AWS CLI, run the
sts get-caller-identity command. The command returns details about the user's
credentials if they are valid, otherwise, it throws an error.
Let's run the get-caller-identity command on the default profile:
aws sts get-caller-identity

The output of the command shows that the caller has been successfully identified, therefore their credentials are valid.
To validate the credentials of a named profile with AWS CLI, run the
sts get-caller-identity command passing it the --profile parameter.
aws sts get-caller-identity --profile YOUR_PROFILE

The output shows that the named profile also has valid credentials.
Let's now test the other scenario. I'll update the secret access key of the
default profile to be incorrect and then
I'll rerun the sts get-caller-identity command.
aws sts get-caller-identity

The get-caller-identity command was unable to identify the caller because the
configured secret access key is incorrect and we got a
SignatureDoesNotMatch error.