For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/cloudformation-aws-iam-policies-without-groups.md.
A documentation index is available at /llms.txt.
Attaching IAM policies directly to individual users reduces centralized control and increases the risk of privilege sprawl, orphaned permissions, and inconsistent access management. This rule flags AWS CloudFormation AWS::IAM::Policy resources that define a non-empty Properties.Policies[].Users entry. Policies should be assigned to groups instead using the Groups property (or attached as managed policies to roles or groups) so permissions can be managed and audited centrally. Resources with Resources.<name>.Properties.Policies[].Users present and non-empty will be flagged. Replace user-level policy attachments with Groups (provide group names or !Ref to group resources) or use managed policy attachments for better lifecycle control.
Secure configuration example assigning the policy to a group: