Description
0.0.0.0/0 and ::/0 are possible route destinations, but neither is a valid AWS subnet address range. A subnet is public when its route table has a direct route to an internet gateway, even if its own addresses are private.
Potential impact
An invalid subnet prevents deployment. A valid private CIDR can still leave an external path if RDS public addressing, routes and security groups allow it.
Remediation
- Choose nonoverlapping subnet CIDRs within the VPC range. For internal RDS, check every subnet in the DB subnet group for direct internet-gateway routes and meet the Availability Zone requirements for your configuration.
- Set
publicly_accessiblefor the intended access, restrict security groups to the required clients, and test application connectivity.
Examples
Both excerpts omit the second subnet definition and routes. The Aurora cluster determines the DB subnet group. If you supply db_subnet_group_name for a member instance, it must match the existing cluster’s group. Check the legacy Ansible module names, resource IDs and RDS settings.
Before
- name: create minimal aurora 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
db_subnet_group_name: my_subnet_group
- name: Add or change a subnet group
community.aws.rds_subnet_group:
state: present
name: my_subnet_group
description: My Fancy Ex Parrot Subnet Group
subnets:
- "{{ subnet1.subnet.id }}"
- "{{ subnet2.subnet.id }}"
- name: Create subnet for database servers
amazon.aws.ec2_vpc_subnet:
state: present
vpc_id: vpc-123456
cidr: 0.0.0.0/0
register: subnet1
After
- name: create minimal aurora 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
db_subnet_group_name: my_private_subnet_group
- name: add private subnet group
community.aws.rds_subnet_group:
state: present
name: my_private_subnet_group
description: private database subnets
subnets:
- "{{ subnet_private_a.subnet.id }}"
- "{{ subnet_private_b.subnet.id }}"
- name: create private subnet
amazon.aws.ec2_vpc_subnet:
state: present
vpc_id: vpc-123456
cidr: 10.0.1.16/28
register: subnet_private_a
Explanation:
- Before: The subnet’s
0.0.0.0/0address range prevents creation. - After:
10.0.1.16/28is usable if it fits the VPC and does not overlap another subnet. Check the route table even when the subnet name saysprivate.