Jack
Jack

Reputation: 1076

Continuous Integration with AWS CDK, ECS, and Prisma

I'm working with CDK and working to set up CI/CD. My stack looks like so:

L2: AppStack: 2 ECS Services

L1: StorageStack: RDS Database

L0: SharedInfrastructure: Networks

How to set up CI is not exactly clear. For example, because I'm using Prisma, I'm unsure if migrations should happen in AppStack or StorageStack. Additionally, how should I do these migrations? Does it make sense to set up a Serverless function that is then hit on a change is detected? But then this function needs to be updated every time the Prisma schema is updated. What happens if there is a potential data loss?

I could be missing something generally but hoping someone might give me some insight. Thanks!

Upvotes: 0

Views: 405

Answers (1)

carlos_technogi
carlos_technogi

Reputation: 198

I don' think it should go in any of your stacks. Depending on what are you using to implement your CI this could go in a separate CI Stack (in case you are using AWS DevOps Stack) or inside something lake github actions or bitbucket pipelines.

A simple flow would be:

  • Upload the code to git
  • Then the CI mechanisms
    • Tests
    • Apply prisma migrations (it is a good practice to avoid migrations that brakes retrocompatibilitaty, so if your deployment fails, the old version of the application can keep un running with the DB changes).
    • builds docker image
    • uploads the image to ECR
    • tell ECS to download the new image (you may or may not need to redeploy de while ECS Task, depending on your flow)
    • wait for the actual deployment

Upvotes: 1

Related Questions