Active IAM user access key needs review

Verify access-key ownership and use, then disable and remove unnecessary long-term keys. Review root-user credentials separately.

Description

amazon.aws.iam_access_key manages keys for a named IAM user. Even when the name contains root, that user’s policies determine its permissions. Review the actual AWS account root user separately.

Potential impact

A valid key ID and its secret can be used for actions allowed to the user. Disabling a key still in use can interrupt services that depend on it.

Remediation

  1. Check the key’s owner, status, and last use. If using a credential report, check when it was generated and obtain the current status if needed.
  2. Move automation to temporary credentials from a least-privilege role and test it. Deactivate the identified key, verify dependent workloads, then delete the unused key.
  3. Review root sign-in protection and root keys separately. Avoid creating root access keys.

Examples

Set iam_user_name and access_key_id to the target user and a key it owns. Authenticate the module using separate AWS administration credentials.

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 IAM user 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 and leaves it in IAM.

References