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
- 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.
- 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.
- 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.