By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Import existing Aurora Serverless Postgres Database into stack

0

I would like to reduce the number of Aurora Serverless instances. To do this, I would like to create a new stack that creates an Aurora Serverless Postgres database. Then I would like to import the Aurora database into the app stack. And also the secret. What is the best way to do this?

asked a month ago23 views
1 Answer
0

To reduce the number of Aurora Serverless instances and import an existing Aurora Serverless PostgreSQL database into a new stack, you can follow these steps:

  1. Create a new stack for your Aurora Serverless PostgreSQL database:

    • Use AWS CloudFormation or your preferred Infrastructure as Code (IaC) tool to define the new stack.
    • Include the Aurora Serverless PostgreSQL database resource in your stack definition.
  2. Export the existing database:

    • Use AWS Database Migration Service (DMS) or native PostgreSQL tools to export your existing database schema and data.
  3. Import the database into the new stack:

    • Once your new Aurora Serverless PostgreSQL database is created in the new stack, import the exported data and schema.
  4. Import the secret:

    • Use AWS Secrets Manager to manage your database credentials.
    • In your new stack, create a new secret or import the existing secret that contains the database credentials.
  5. Update your application stack:

    • Modify your application stack to reference the new Aurora Serverless PostgreSQL database in the new stack.
    • Update any necessary connection strings or environment variables to point to the new database.
  6. Test and validate:

    • Ensure your application works correctly with the imported database in the new stack.
  7. Decommission the old database:

    • Once everything is working as expected, you can safely remove the old Aurora Serverless instance.

When creating the new Aurora Serverless PostgreSQL database in your stack, you can use AWS CLI or AWS Management Console. For example, using AWS CLI:

aws rds create-db-cluster \
    --db-cluster-identifier your-new-cluster-name \
    --engine aurora-postgresql \
    --engine-version 13.9 \
    --engine-mode serverless \
    --scaling-configuration MinCapacity=2,MaxCapacity=64,AutoPause=true,SecondsUntilAutoPause=1000 \
    --master-username your-username \
    --master-user-password your-password

Remember to adjust the parameters such as engine version, scaling configuration, and credentials according to your specific requirements.

By following this approach, you can consolidate your Aurora Serverless PostgreSQL databases into a single stack, reducing the number of instances and improving manageability.
Sources
Creating an Aurora Serverless v1 DB cluster - Amazon Aurora
Serverless Database - Amazon Aurora Serverless - AWS

profile picture
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions