Review access keys for an IAM user named root

Distinguish an IAM user named root from the AWS account root user and verify the key’s actual owner, permissions and exposure.

Description

The user argument of aws_iam_access_key names an IAM user. With user = "root", the key belongs to an IAM user named root. Check the AWS account root user’s keys separately.

Potential impact

An active key alone is no evidence of a leak. If state files or deployment outputs disclose both a valid ID and its secret, someone can use the actions allowed to that IAM user.

Remediation

Check the owner and consumers, then move automation to temporary role credentials. Limit permissions for users that still need long-term keys, and restrict access to state and outputs. If a real key was exposed, deactivate it promptly, migrate its consumers, and investigate AWS activity. If the account root user has keys, check dependencies and remove them.

Examples

The target IAM user must already exist.

Before

hcl
resource "aws_iam_access_key" "example" {
  user   = "root"
  status = "Active"
}

The resource creates an Active key for the IAM user named root. That user’s policies determine its permissions.

After

hcl
resource "aws_iam_access_key" "example" {
  user = "some-user"
}

The target changes to some-user. The default status is Active, so the new key is active too.

References