Review IAM user initial password settings

Generate a sufficiently long initial password and require a change at first sign-in.

Description

password_length on aws_iam_user_login_profile sets one user’s generated initial password length. Manage ongoing length and character rules in the IAM account password policy.

Potential impact

An initial password that stays in use can be misused if it was exposed during delivery.

Remediation

Choose a length that meets the account policy and set password_reset_required = true. AWS provider 6.0.0 replaces an existing login profile when either setting changes. Review the plan, deliver the new password securely and verify the user can change it.

Examples

The initial length increases from 13 to 15 characters. Supply the IAM user and the intended recipient’s public key for pgp_key.

Before

hcl
resource "aws_iam_user_login_profile" "example" {
  user    = aws_iam_user.example.name
  pgp_key = "keybase:some_person_that_exists"

  password_reset_required = false
  password_length         = 13
}

After

hcl
resource "aws_iam_user_login_profile" "example" {
  user    = aws_iam_user.example.name
  pgp_key = "keybase:some_person_that_exists"

  password_reset_required = true
  password_length         = 15
}

References