Sub topic 14
Checking your baseline with the console and CLI
This chapter assumes you have already set up root MFA, avoided root access keys, created an admin identity for daily work, and created a budget. Here you confirm each of those settings. You use the console for a quick look and the AWS CLI for a result you can repeat. You also need the CLI installed and configured with your admin identity, not the root user.
What you are verifying
A baseline check answers four questions:
- Does the root user have MFA enabled?
- Does the root user have any access keys?
- Are you running CLI commands as the admin identity instead of root?
- Does a budget exist that will email you?
Check root MFA and access keys
The account summary reports both root settings as numbers. A value of 1 means true and 0 means false.
aws iam get-account-summary \
--query 'SummaryMap.{RootMFA:AccountMFAEnabled,RootAccessKeys:AccountAccessKeysPresent}'You want RootMFA to be 1 and RootAccessKeys to be 0. A result of RootMFA: 0 means the root user has no MFA device. A result of RootAccessKeys: 1 means at least one root access key exists. Delete it from the root user's security credentials page after you confirm nothing uses it.
Confirm who you are
Next, check which identity your CLI credentials belong to.
aws sts get-caller-identityThe output includes an Arn. If it ends in :root, stop and switch to your admin identity. An admin identity usually shows user/ or assumed-role/ in the ARN.
Check the budget
List budgets for your account. Replace the placeholder account ID with your own.
aws budgets describe-budgets --account-id 111122223333The output should include monthly-cost-budget if you used the earlier example. If you get an access error, your admin identity may lack billing permissions. Billing access for IAM identities has to be turned on by the root user first.
Cross-check with the credential report
The credential report lists every IAM user and the root user in one CSV file. It gives a second view of the same facts.
aws iam generate-credential-report
aws iam get-credential-report --query Content --output text | base64 --decodeThe first command starts the report. It can return a state of STARTED, so run the second command after a few seconds if it fails. Find the row whose first column is <root_account>. Its mfa_active column should be true. Its access_key_1_active and access_key_2_active columns should be false.
Console checks
The console confirms the same results visually.
| Check | Where to look |
|---|---|
| Root MFA | Security credentials page, Multi-factor authentication section |
| Root access keys | Security credentials page, Access keys section (should be empty) |
| Budget | Billing and Cost Management, Budgets |
| Admin identity | IAM, Users or IAM Identity Center |
Common errors
- AccessDenied on
get-account-summary: your identity lacksiam:GetAccountSummary. Admin permissions include it. A narrow policy may not. - AccessDenied on Budgets: billing access is not enabled for IAM, or the policy omits
budgets:ViewBudget. - Report is not ready: wait a few seconds and run
get-credential-reportagain. - Wrong account: compare the
Accountvalue fromget-caller-identitywith the account you meant to check.
Exercise
You run aws iam get-account-summary with the query from this chapter and see RootMFA: 1 and RootAccessKeys: 1. Which setting needs action, and where would you confirm it?
Show answer
The root access keys need action, because 1 means a root access key exists. Confirm it in the credential report, where the <root_account> row shows access_key_1_active or access_key_2_active as true, or in the root user's security credentials page. After you check that nothing depends on the key, delete it. Then rerun the summary and expect RootAccessKeys: 0.
Exercise
aws sts get-caller-identity returns an Arn ending in :root. What should you do before running further commands?
Show answer
Stop and switch to the admin identity, because the CLI is using root credentials. Root access keys should not exist. If these credentials came from a root key, delete that key after confirming nothing depends on it. Then configure the CLI with the admin identity and run the command again.