# azure


09/25/2023, 8:12 PM
šŸ‘‹ Hello everybody, I wish to automate database, user, and grant resource provisioning on a PSQL Flex Server with VirtualNetwork integration. The DB instance is thus deployed on a delegated subnet, which means that automation with pulumi would require either: 1. To create Network Security Groups and Firewalls to allow access from outside the VNET. 2. To run pulumi inside the VNET. 3. To run a job inside a k8s cluster deployed in the same vnet (which is supposed to use PSQL Flex Server for persistence). 4. Some other solution Iā€™m not aware of? Your ideas will be appreciated. Many thanks šŸ™‚


09/27/2023, 7:15 AM
I've had to do exactly that. In my situation, I want to run database provisioning (setting up user accounts for example), but also do database schema migrations. I've 'solved' it by having a separate container app job. This container app runs once before the rest of the deployment. Challenge is, now I have to much more orchestration of my deployment. (first deploy / run the container with the new initialization scripts, then deploy the actual app once it's completed successfully). I've been told you could do something similar with container initialization jobs, but haven't had a chance to look into that too much.
I know @fresh-summer-65887 took a different route, where he containerized the pulumi application deployment and runs it inside the vnet.


10/02/2023, 3:06 PM
Solutions I've done in the past revolved around having CD "deployment" agents running connected to the VNET. e.g. a self-hosted GitHub Action agent. These deployment agents would be authorized to do deployment only activities (which would include database/data migration tasks). Never CI build jobs. They'd be locked down with very limited internet access (perhaps just back to GitHub actions), not directly addressable over internet etc. I also typically design my VNETs / VPCs such that there is an "ops VNET" upon which such hosts live and have peering to the various environment VNETs/VPCs.