RDS instance has public access enabled

Review RDS public-access settings, omitted-value defaults, and the network conditions required for a connection.

Description

With publicly_accessible: true, the RDS endpoint resolves to a public IP address from outside the VPC. If you omit the option when creating an instance, the AWS default depends on the engine and DB subnet group.

Potential impact

An internet route and a permissive security group can let external clients reach the database. Access to data still depends on authentication and database privileges.

Remediation

  • For an internal database, prepare private routes for applications and administrators and set publicly_accessible: false.
  • Check when the change takes effect, then verify the applied setting, subnet routes, security groups and client connections. The flag leaves the instance in its existing subnet.

Examples

The tasks use different engines and instance settings. Check module and instance-class support and supply the variables for each task. The second task also requires an existing Aurora cluster.

Before

yaml
- name: create public db instance
  community.aws.rds_instance:
    id: test-encrypted-db
    state: present
    engine: mariadb
    storage_encrypted: true
    db_instance_class: db.t2.medium
    username: "{{ username }}"
    password: "{{ password }}"
    allocated_storage: "{{ allocated_storage }}"
    publicly_accessible: true

After

yaml
- name: create private db instance
  community.aws.rds_instance:
    engine: aurora
    db_instance_identifier: ansible-test-aurora-db-instance
    instance_type: db.t2.small
    password: "{{ password }}"
    username: "{{ username }}"
    cluster_id: ansible-test-cluster
    publicly_accessible: false

Explanation:

  • Before: The MariaDB instance requests a public address. storage_encrypted: true protects stored data.
  • After: The Aurora instance requests private addressing. Verify that the required clients can still connect.

References