# aws-iam-all-resources-accessible

Rule `sonarjs/aws-iam-all-resources-accessible`. IAM policies should not grant access to all account resources

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2121 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/aws-iam-all-resources-accessible` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-6304/) |

## Code examples

### Incorrect: the rule reports this

```js
import { aws_iam as iam } from 'aws-cdk-lib'

new iam.PolicyDocument({
    statements: [
        new iam.PolicyStatement({
            effect: iam.Effect.ALLOW,
            actions: ["iam:CreatePolicyVersion"],
            resources: ["*"] // Sensitive
        })
    ]
})
```

### Correct: the rule accepts this

```js
import { aws_iam as iam } from 'aws-cdk-lib'

new iam.PolicyDocument({
    statements: [
        new iam.PolicyStatement({
            effect: iam.Effect.ALLOW,
            actions: ["iam:CreatePolicyVersion"],
            resources: ["arn:aws:iam:::policy/team1/*"]
        })
    ]
})
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/aws-iam-all-resources-accessible": "error",
    },
  },
];
```

## Related rules

- [sonarjs/arrow-function-convention](https://lintradar.dev/rules/sonarjs/arrow-function-convention.md): Braces and parentheses should be used consistently with arrow functions
- [sonarjs/bool-param-default](https://lintradar.dev/rules/sonarjs/bool-param-default.md): Optional boolean parameters should have default value
- [sonarjs/array-constructor](https://lintradar.dev/rules/sonarjs/array-constructor.md): Array constructors should not be used
- [sonarjs/class-prototype](https://lintradar.dev/rules/sonarjs/class-prototype.md): Class methods should be used instead of "prototype" assignments
- [sonarjs/arguments-usage](https://lintradar.dev/rules/sonarjs/arguments-usage.md): "arguments" should not be accessed directly
- [sonarjs/comment-regex](https://lintradar.dev/rules/sonarjs/comment-regex.md): Track comments matching a regular expression

---

Web page: https://lintradar.dev/rules/sonarjs/aws-iam-all-resources-accessible. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
