# aws-iam-public-access

Rule `sonarjs/aws-iam-public-access`. AWS resource-based policies should not grant public access

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1176 by reach, #477 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

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

const bucket = new s3.Bucket(this, "ExampleBucket")

bucket.addToResourcePolicy(new iam.PolicyStatement({
    effect: iam.Effect.ALLOW,
    actions: ["s3:*"],
    resources: [bucket.arnForObjects("*")],
    principals: [new iam.AccountRootPrincipal()]
}))
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/aws-iam-public-access": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/aws-iam-privilege-escalation](https://lintradar.dev/rules/sonarjs/aws-iam-privilege-escalation.md): AWS IAM policies should limit the scope of permissions given
- [sonarjs/aws-opensearchservice-domain](https://lintradar.dev/rules/sonarjs/aws-opensearchservice-domain.md): OpenSearch domains should have encryption at rest enabled
- [sonarjs/aws-iam-all-privileges](https://lintradar.dev/rules/sonarjs/aws-iam-all-privileges.md): Policies should not grant all privileges
- [sonarjs/aws-rds-unencrypted-databases](https://lintradar.dev/rules/sonarjs/aws-rds-unencrypted-databases.md): Amazon RDS resources should be encrypted at rest
- [sonarjs/aws-efs-unencrypted](https://lintradar.dev/rules/sonarjs/aws-efs-unencrypted.md): Amazon EFS file systems should be encrypted
- [sonarjs/aws-restricted-ip-admin-access](https://lintradar.dev/rules/sonarjs/aws-restricted-ip-admin-access.md): Administration services access should be restricted to specific IP addresses

---

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