Description
pw_reuse_prevent sets how many previous IAM console passwords a user cannot reuse. The Ansible default, 0, allows reuse.
Potential impact
Reusing an exposed password can give someone who knows it access again. IAM checks the user’s own password history for exact matches. Similar passwords and passwords used elsewhere fall outside this check.
Remediation
Set a history of 1–24 passwords according to your requirements. password_reuse_prevent and prevent_reuse are aliases. Use one name in a task. Require sufficient length and MFA, and replace exposed passwords promptly.
Examples
The examples cover console passwords. Manage access keys separately.
Before
- name: Configure the IAM password policy
community.aws.iam_password_policy:
state: present
min_pw_length: 8
require_symbols: false
require_numbers: true
require_uppercase: true
require_lowercase: true
allow_pw_change: true
pw_max_age: 60
pw_expire: false
- name: Configure a second IAM password policy example
community.aws.iam_password_policy:
state: present
min_pw_length: 8
require_symbols: false
require_numbers: true
require_uppercase: true
require_lowercase: true
allow_pw_change: true
pw_max_age: 60
password_reuse_prevent: 0
pw_expire: false
After
- name: Configure the IAM password policy
community.aws.iam_password_policy:
state: present
min_pw_length: 8
require_symbols: false
require_numbers: true
require_uppercase: true
require_lowercase: true
allow_pw_change: true
pw_max_age: 60
pw_reuse_prevent: 5
pw_expire: false
The first two tasks omit the option or set it to 0. With pw_reuse_prevent: 5, the five most recent passwords cannot be reused.