Review active IAM user access keys

Remove unnecessary IAM user access keys and use temporary credentials where possible.

Description

For each active IAM user access key, check its owner, purpose, and last use. Its active status alone does not establish that the key was disclosed.

Potential impact

A valid key ID and its secret can be used to perform actions allowed to the IAM user. Deactivating a key still in use can interrupt dependent services.

Remediation

  1. Use federation for people and IAM roles for automation to obtain temporary credentials. Avoid root access keys.
  2. For routine retirement, test replacement credentials, deactivate the old key, then delete it after verifying dependent services. If exposure is suspected, promptly deactivate and replace the key and investigate its use.
  3. Limit permissions on IAM users that still need keys. Keep the secret out of code, repositories, and logs.

Examples

Set iam_user_name and access_key_id to the actual user and a key belonging to that user. The Ansible module needs separate AWS authentication.

Before

yaml
- name: Enable a selected IAM user access key
  amazon.aws.iam_access_key:
    user_name: "{{ iam_user_name }}"
    id: "{{ access_key_id }}"
    state: present
    active: true

active: true enables the selected key.

After

yaml
- name: Disable a selected IAM user access key
  amazon.aws.iam_access_key:
    user_name: "{{ iam_user_name }}"
    id: "{{ access_key_id }}"
    state: present
    active: false

active: false deactivates the same key. It remains in IAM, so confirm its status and check its consumers.

References