Description
An IAM user can have up to two access keys. If both are present, check whether they are in use during rotation or an unused key remains.
Potential impact
An unnecessary active key can be misused if exposed. Unknown consumers make it harder to revoke it.
Remediation
Prefer temporary credentials from a role. If rotating a long-term key, move each consumer to the new key and test it. Deactivate the old key, confirm normal operation, then remove it from the stack.
Examples
These examples configure API access keys for myuser. Console sign-in is configured separately.
Before
yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
myuser:
Type: AWS::IAM::User
Properties:
Path: "/"
firstKey:
Type: AWS::IAM::AccessKey
Properties:
UserName: !Ref myuser
secondKey:
Type: AWS::IAM::AccessKey
Properties:
UserName: !Ref myuser
firstKey and secondKey are issued to the same user.
After
yaml
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
myuser:
Type: AWS::IAM::User
Properties:
Path: "/"
firstKey:
Type: AWS::IAM::AccessKey
Properties:
UserName:
Ref: myuser
Only firstKey remains. Protect its secret and track its consumers.