I have a NodeJS backend which relies on Prisma models, which I want to deploy to my production database. My CI/CD pipeline looks as follows: Github Actions builds the code using webpack, uploads the bundles to S3, and invokes AWS CodeDeploy.
AWS CodeDeploy then executes scripts on the EC2 servers the backend is deployed to, to install the bundles and configure everything. These EC2 servers are the only servers with access to the database, as the database disallows any connection not coming from the EC2 servers.
This means that I cannot execute yarn prisma migrate deploy
from Github Actions, as the database will disallow such a connection.
As I see it, I have three options:
- Whitelist IP-addresses of runners of Github Actions to the database. I would preferably not do this for security reasons.
- Download the full source code of my repository to the EC2 server, and subsequently run
yarn install
and thenyarn prisma migrate deploy
. Wouldn't want to do this because of security reasons, it introduces additional risks in the deployment, and it slows the deployment down. - Somehow compile the
yarn prisma migrate deploy
command into a bundle with theprisma
migration files, and execute it on the EC2 server.
What do you suggest? From the options above, my preference goes to option 3, but I haven't found a way to do it as I only found ways to compile the prisma client, but I don't think that is what I want.
Thank you in advance!