# aws-ec2-rds-dms-public

Rule `sonarjs/aws-ec2-rds-dms-public`. Public network access to cloud resources should be disabled

- 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: #1171 by reach, #472 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

```js
import {aws_ec2 as ec2} from 'aws-cdk-lib'

new ec2.Instance(
    this,
    "example", {
    instanceType: nanoT2,
    machineImage: ec2.MachineImage.latestAmazonLinux(),
    vpc: vpc,
    vpcSubnets: {subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS}
})
```

```js
import {aws_ec2 as ec2} from 'aws-cdk-lib'

new ec2.CfnInstance(this, "example", {
    instanceType: "t2.micro",
    imageId: "ami-0ea0f26a6d50850c5",
    networkInterfaces: [
        {
            deviceIndex: "0",
            associatePublicIpAddress: false,
            deleteOnTermination: true,
            subnetId: vpc.selectSubnets({subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS}).subnetIds[0]
        }
    ]
})
```

```js
import {aws_ec2 as ec2} from 'aws-cdk-lib'

new dms.CfnReplicationInstance(
    this, "example", {
    replicationInstanceClass: "dms.t2.micro",
    allocatedStorage: 5,
    publiclyAccessible: false,
    replicationSubnetGroupIdentifier: subnetGroup.replicationSubnetGroupIdentifier,
    vpcSecurityGroupIds: [vpc.vpcDefaultSecurityGroup]
})
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/aws-ec2-rds-dms-public": "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-apigateway-public-api](https://lintradar.dev/rules/sonarjs/aws-apigateway-public-api.md): AWS API Gateway should require authentication
- [sonarjs/aws-ec2-unencrypted-ebs-volume](https://lintradar.dev/rules/sonarjs/aws-ec2-unencrypted-ebs-volume.md): EBS volumes should be encrypted
- [sonarjs/avoid-mutating-nested-properties-of-shallow-clones](https://lintradar.dev/rules/sonarjs/avoid-mutating-nested-properties-of-shallow-clones.md): Nested properties of Lodash and Underscore.js clone results should not be mutated
- [sonarjs/aws-efs-unencrypted](https://lintradar.dev/rules/sonarjs/aws-efs-unencrypted.md): Amazon EFS file systems should be encrypted
- [sonarjs/async-test-assertions](https://lintradar.dev/rules/sonarjs/async-test-assertions.md): Async test assertions should be awaited or returned
- [sonarjs/aws-iam-all-privileges](https://lintradar.dev/rules/sonarjs/aws-iam-all-privileges.md): Policies should not grant all privileges

---

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