How can I create an Aurora PostgreSQL-Compatible global database?

7 minute read
0

I want to create an Amazon Aurora PostgreSQL-Compatible Edition global database.

Short description

Aurora global databases are used for globally distributed applications. These databases can span multiple AWS Regions, which allows you to have a read-only secondary DB cluster located in another Region to support local reads. Aurora global databases also provide a fast recovery mechanism in the case of an AWS Region failure.

Use these methods to create an Aurora PostgreSQL-Compatible global database:

  • Create an Aurora PostgreSQL-Compatible global database using the AWS Console
  • Create an Aurora PostgreSQL-Compatible global database using an existing Aurora Cluster
  • Migrate an Amazon Relational Database Service (Amazon RDS) for PostgreSQL snapshot to an Aurora PostgreSQL-Compatible global database
  • Migrate an Amazon RDS for PostgreSQL database to an Aurora PostgreSQL-Compatible global database

Resolution

Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

Before creating an Aurora PostgreSQL-Compatible global database:

Create an Aurora PostgreSQL-Compatible global database using the AWS Console

  1. Open the Amazon RDS console in your primary Region.
  2. Choose Create database.
  3. For Database creation method, choose Standard create.
  4. For Engine type, choose Amazon Aurora.
  5. For Edition, choose Amazon Aurora PostgreSQL-Compatible Edition.
  6. Under filters, turn on Show versions that support the global database feature.
  7. In the Available versions dropdown list, choose the version of PostgreSQL that you want to use.
  8. Depending on your use case, for Templates, choose Production or Dev/Test.
  9. In the Settings section, for DB cluster identifier, enter the name of your primary DB cluster. For Master user name, enter the default master user for PostgreSQL or enter your own user name.
  10. In the Instance configuration section, choose a DB instance class.
  11. In the Availability durability section, it's a best practice that you choose to create an Aurora replica in a different AZ. If you don't choose that option, you can create the read replica at a later stage.
  12. In the Connectivity section, choose the options that you want to use. Also select the VPC, DB Subnet group, and VPC Security group that you want to use.
  13. Under Additional configuration you can specify the database port. The default port is 5432.
  14. Under Database authentication, by default password authentication is used. You can optionally turn on IAM database authentication, Kerberos authentication, or both for your database.
  15. In the Database options section, enter the Initial Database name. Choose the DB cluster parameter group, DB parameter group, and Failover priority. Review the Backup, Encryption, Maintenance, and Deletion Protection options.
  16. Choose Create database. When the cluster is ready to use, the status of the cluster, writer, and replica nodes change to Available.
  17. An Aurora PostgreSQL global database needs at least one secondary Aurora DB cluster in a different AWS Region than the primary Aurora DB cluster. You can attach up to five secondary DB clusters to your Aurora PostgreSQL global database. Choose the Aurora PostgreSQL database that you created. From the Actions dropdown list, choose Add AWS Region.
  18. On the Add a Region page, enter the name for your global database, and choose the secondary Region. Review and complete the rest of the information for the Aurora cluster in the new Region.
    Note: The names you choose for each of your Aurora DB clusters must be unique, across all AWS Regions. You can't use the same name for different Aurora DB clusters even though they're in different Regions.
  19. Click on the Add Region button.

Create an Aurora PostgreSQL-Compatible global database using an existing Aurora Cluster

  1. Open the Amazon RDS console in your primary Region.
  2. In the Resources section, choose DB Instances.
  3. Choose the existing Aurora PostgreSQL cluster that you want to use.
  4. From the Actions dropdown list, choose Add AWS Region.
  5. On the Add a Region page, enter the name for your global database, and then choose the secondary Region.
  6. Choose Add Region.

Migrate an RDS for PostgreSQL snapshot to an Aurora PostgreSQL-Compatible global database

  1. Open the Amazon RDS console in your primary Region.
  2. From the navigation pane, choose Snapshots.
  3. Choose the RDS for PostgreSQL snapshot that you want to migrate.
  4. Choose Actions, and from the dropdown list choose Migrate Snapshot.
  5. On the Migrate database page, for Migrate to DB engine choose aurora-postgresql.
  6. Choose the Migrate button. This creates an Aurora PostgreSQL-Compatible cluster from the RDS for PostgreSQL snapshot.
  7. After the Aurora PostgreSQL-Compatible cluster is created, from the navigation pane, choose Databases.
  8. Choose the migrated Aurora PostgreSQL-Compatible cluster.
  9. From the Actions dropdown list, choose Add AWS Region.
  10. On the Add a Region page, enter the name for your global database, and then choose the secondary Region.
  11. Choose Add Region.

Migrate an RDS for PostgreSQL database to an Aurora PostgreSQL-Compatible global database

  1. Open the Amazon RDS console in your primary Region.
  2. From the navigation pane, choose Databases.
  3. Choose the RDS for PostgreSQL database that you want to convert.
  4. From the Actions dropdown list, choose Create Aurora read replica.
  5. On the Create Aurora read replica page review and complete all fields, and then choose Create read replica.
  6. After creating the Aurora read replica, you can now promote the Aurora read replica.
  7. Note: Before promoting the replica, make sure that the RDS for PostgreSQL database doesn't have any activity. Confirm also that the replica lag is zero.
  8. Choose the Aurora read replica that you created.
  9. From the Actions dropdown list, choose promote.
  10. After the promotion process, the Aurora replica cluster becomes a Regional Aurora DB cluster with a writer instance. Choose the newly promoted Regional Aurora DB cluster.
  11. From the Actions dropdown list, choose Add AWS Region.
  12. On the Add a Region page, enter the name for your global database, and then choose the secondary Region.
  13. Choose Add Region.

Create a headless Aurora DB Cluster in a secondary Region

Aurora global databases require at least one secondary Aurora DB Cluster in a different AWS Region. To reduce compute costs, you can create a headless secondary Aurora DB Cluster. By doing this, you are charged only for the storage. While this setup method can incur a higher recovery time objective (RTO), it can reduce the cost of your disaster recover (DR) setup.

For PostgreSQL, use the AWS CLI to create the headless Aurora DB Cluster. See this example of a Linux/MacOS AWS CLI command that is used to create a headless Aurora DB Cluster.

Note: Replace the <> place holders in this command with actual values before running the command.

For a list of options that you can use with this command, see the create-db-cluster reference documentation.

aws rds --region <target_region> \
  create-db-cluster \
     --db-cluster-identifier <value> \
     --global-cluster-identifier <value>  \
     --engine aurora-postgresql \
     --kms-key-id <value> \
     --engine-version <value> \
     --db-cluster-parameter-group-name <value>\
     --db-subnet-group-name <value> \
     --vpc-security-group-ids <value> \
     --backup-retention-period <value>

Related information

Amazon Aurora Global databases

AWS OFFICIAL
AWS OFFICIALUpdated a year ago