Skip to main content
MEDIUMIAMSecurity

IAM User Direct Policies

iam-user-direct-policies

What this rule checks

Detects IAM Users with policies attached directly (inline Policies or ManagedPolicyArns). CIS AWS Foundations 1.15 requires users to inherit permissions through groups.

How to fix it

  1. 1Create an IAM Group with the required policies
  2. 2Add the user to the group instead of attaching policies directly
  3. 3Remove Policies and ManagedPolicyArns from AWS::IAM::User resources
FlaggedThe managed policy is attached directly to the IAM user. CIS AWS Foundations 1.15 requires users to inherit permissions through groups so access can be managed centrally.
import { User, ManagedPolicy } from 'aws-cdk-lib/aws-iam';

new User(this, 'AppUser', {
  managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess')],
});
FixedThe policy is attached to a group, and the user inherits permissions by group membership. The user itself carries no inline or managed policies, satisfying CIS 1.15.
import { User, Group, ManagedPolicy } from 'aws-cdk-lib/aws-iam';

const group = new Group(this, 'ReadOnlyGroup', {
  managedPolicies: [ManagedPolicy.fromAwsManagedPolicyName('AmazonS3ReadOnlyAccess')],
});
new User(this, 'AppUser', { groups: [group] });

CDK Insights pinpoints the exact file and line in your CDK source for every finding, so you can jump straight to the fix.

Affected resource types

AWS::IAM::User

Compliance frameworks

SOC2HIPAAPCI-DSSCISNIST

AWS documentation

Read the AWS guidance

Intentional? Suppress this finding

Sometimes a flag is deliberate — a genuinely public endpoint, say. You can dismiss iam-user-direct-policies and the reason is kept in the report, not silently hidden.

In .cdk-insights.json:

{
  "ignoreRules": [
    { "id": "iam-user-direct-policies", "reason": "Why this is intentional" }
  ]
}

Or inline in your CDK code:

Validations.of(scope).acknowledge({
  id: 'cdk-insights::iam-user-direct-policies',
  reason: 'Why this is intentional',
});

Use the rule ID iam-user-direct-policies shown above — not the CDK-* ID from SARIF / GitHub code scanning. To dismiss every finding on one construct instead, use ignorePaths. Suppression docs →

Catch this in your stack

$ npx cdk-insights scan

CDK Insights runs this and 118+ other rules locally against your synthesised CDK app — free, no account, your code never leaves your machine.

More IAM rules