How do I configure a provisioned Amazon Aurora DB cluster to be publicly accessible?

5 minute read
0

I have a provisioned Amazon Aurora DB cluster, and I want to configure it to be publicly accessible. Also, I want to secure my Aurora DB cluster from outside connections. How can I do this?

Short description

To connect to an Aurora DB cluster from outside the Amazon Virtual Private Cloud (Amazon VPC), the instances in the cluster must meet the following requirements:

  • The DB instance has a public IP address.
  • The DB instance is run in a publicly accessible subnet.

In addition to configuring your DB instance to be connected from outside a VPC, you can secure the connections using Transport Layer Security (TLS).

Resolution

Set Publicly Accessible setting of DB instance to Yes

The Publicly Accessible setting for an Amazon Relational Database Service (Amazon RDS) DB instance controls the assignment of a public IP address to the DB instance.

  • If this is set to No, then the DB instance does not have a public IP address.
  • If this is set to Yes, then the DB instance has both public and private IP addresses.

To change the Publicly Accessible setting of the DB instance to Yes, follow these steps:

  1. Open the Amazon RDS console.
  2. Choose Databases from the navigation pane, and then choose the DB instance.
  3. Choose Modify.
  4. Under Connectivity, extend the Additional configuration section, and then choose Publicly accessible.
  5. Choose Continue.
  6. Choose Modify DB Instance

Note: You don't need to choose Apply Immediately. For more information about how Apply Immediately can affect downtime, see Using the Apply Immediately parameter.

Run DB instance in a public subnet

A public subnet is a subnet that is associated with a route table that has a route to internet gateway, typically the default route, 0.0.0.0/0. This route turns on the DB instances in a subnet to communicate with resources outside the VPC.

For Aurora DB instances, you can't choose a specific subnet. Instead, choose a DB subnet group when you create the instance.

A DB subnet group is a collection of subnets that belong to a VPC. When it creates the underlying host, Amazon RDS randomly chooses a subnet from the DB subnet group. Typically, a VPC has both public and private subnets. If the DB subnet group contains public and private subnets, then launch the underlying host in a public subnet or a private subnet. You can't connect to the DB instance from outside of the VPC if the underlying host is launched in a private subnet.

Instead, create a DB subnet group with subnets of similar network configuration. For example, create a DB subnet group for public subnets and a second DB subnet group for private subnets. For more information, see Working with a DB instance in a subnet group.

Follow these steps to make sure that the subnet used by your DB instance has internet access:

  1. Verify that your VPC has an internet gateway attached to it.
  2. Verify that all the subnets in the DB subnet group use a route table with Internet Gateway.
    • If the subnet uses the main route table of the VPC, then add the route for Internet Gateway (Destination is 0.0.0.0/0).
    • If required, create a custom route table with route to Internet Gateway and associate it to the subnet.
  3. Add the source public IP address that you want to connect to the DB instance from in the inbound rules for the security group.
  4. For rule Type, choose MySQL/Aurora or PostgreSQL, depending on your engine type.
  5. For Source, enter the CIDR range manually, or choose My IP to connect to the DB instance from the same workstation.

Secure the DB cluster from connections from outside the VPC

You can use TLS to encrypt connections that come from outside a VPC because the data transfer happens over the internet. To confirm that you're using the highest level of security, use the ssl-ca parameter to pass the CA certificate, and then turn on hostname validation. Use the following example commands for TLS connections, depending on the version of Aurora that you are using.

Amazon Aurora MySQL-Compatible Edition 5.6 and later:

mysql -h test-aurora-56.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -u master_user --ssl-ca=rds-combined-ca-bundle.pem --ssl-verify-server-cert

Aurora MySQL-Compatible 5.7 and later:

mysql -h test-aurora-57.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -u master_user --ssl-ca=rds-combined-ca-bundle.pem --ssl-mode=VERIFY_IDENTITY

Amazon Aurora PostgreSQL-Compatible Edition:

psql -h test-aurora-pg.cluster-xxxxxxxxxxxx.us-east-1.rds.amazonaws.com -p 5432 "dbname=postgres user=master_user sslrootcert=rds-combined-ca-bundle.pem sslmode=verify-full"

Note: You can also enforce TLS for DB clusters. For Aurora MySQL, you must enforce TLS at the database user level. For Aurora PostgreSQL-Compatible, set the parameter rds.force_ssl to 1.


Related information

Using SSL/TLS with Aurora MySQL DB clusters

Securing Aurora PostgreSQL data with SSL

How can I connect to my Amazon RDS DB instance using a bastion host from my Linux/macOS machine?

How can I configure private and public Aurora endpoints in the Amazon RDS console?

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago