Remediation
Using AWS CloudFormationโ
- CloudFormation template (YAML):
AWSTemplateFormatVersion: '2010-09-09'
Description: Disable public accessibility on an existing RDS instance
Parameters:
DBInstanceIdentifier:
Type: String
Description: Identifier of the existing RDS DB instance
Resources:
SecureRdsInstance:
Type: AWS::RDS::DBInstance
Properties:
DBInstanceIdentifier: !Ref DBInstanceIdentifier
PubliclyAccessible: false
From Command Lineโ
- Run
describe-db-instancescommand to list all RDS database names identifiers, available in the selected AWS region:
aws rds describe-db-instances --region <region-name> --query 'DBInstances[*].DBInstanceIdentifier'
- The command output should return each database instance identifier.
- Run
modify-db-instancecommand to modify the selected RDS instance configuration. Then use the following command to disable thePublicly Accessibleflag for the selected RDS instances. This command use the apply-immediately flag. If you want to avoid any downtime--no-apply-immediatelyflag can be used:
aws rds modify-db-instance --region <region-name> --db-instance-identifier <db-name> --no-publicly-accessible --apply-immediately
- The command output should reveal the
PubliclyAccessibleconfiguration under pending values and should get applied at the specified time. - Updating the Internet Gateway Destination via AWS CLI is not currently supported To update information about Internet Gateway use the AWS Console Procedure.
- Repeat steps 1 to 5 for each RDS instance provisioned in the current region.
- Change the AWS region by using the
--regionfilter to repeat the process for other regions.
From Consoleโ
- Log in to the AWS management console and navigate to the RDS dashboard at https://console.aws.amazon.com/rds/.
- Under the navigation panel, On RDS Dashboard, click
Databases. - Select the RDS instance that you want to update.
- Click
Modifyfrom the dashboard top menu. - On the Modify DB Instance panel, under the
Connectivitysection, click onAdditional connectivity configurationand update the value forPublicly AccessibletoNot publicly accessibleto restrict public access. - Follow the below steps to update subnet configurations:
- Select the
Connectivity and securitytab, and click on the VPC attribute value inside theNetworkingsection. - Select the
Detailstab from the VPC dashboard bottom panel and click on Route table configuration attribute value. - On the Route table details page, select the Routes tab from the dashboard bottom panel and click on
Edit routes. - On the Edit routes page, update the Destination of Target which is set to
igw-xxxxxand click onSaveroutes.
- On the Modify DB Instance panel Click on
Continueand In the Scheduling of modifications section, perform one of the following actions based on your requirements:
- Select
Apply during the next scheduled maintenance windowto apply the changes automatically during the next scheduled maintenance window. - Select
Apply immediatelyto apply the changes right away. With this option, any pending modifications will be asynchronously applied as soon as possible, regardless of the maintenance window setting for this RDS database instance. Note that any changes available in the pending modifications queue are also applied. If any of the pending modifications require downtime, choosing this option can cause unexpected downtime for the application.
- Repeat steps 3 to 7 for each RDS instance available in the current region.
- Change the AWS region from the navigation bar to repeat the process for other regions.