How to perform database schema migrations after deploying with AWS CDK?


I’m running an Aurora PostgreSQL (Serverless) cluster. After I deploy the infrastructure for the first time, and every time I re-deploy, I want to run database schema migrations (add tables, add columns).

How can I accomplish this?

Lambda is out of the question, as migrations may run for a long time.

Edit: clarified about schema migration



The correct way to migrate it would be through using the AWS Database Migration Service.

You could create the resources in the CDK for this, then once its complete either run manually or create a customResource that will trigger the job for you.

Leave a Reply