
Lately I’ve been playing around a lot with what I can rapidly build with AI. I need a new workbench for my garage with some weirdly specific dimension requirements? Sure, Gemini can totally handle that complete with awesome cut-sheet and step by step DIY instructions (even though it started off talking to me like I was a cabinet maker and had to have it dumb it down for me). Recreating arcade games from my youth that were obscure enough that no one made it a ROM? Yup, no problem at all. But when it comes to an online application, or game you want to make, how do you know it’s doing the right thing that won’t cause you a headache later?
Most applications require some kind of state. It has to remember what it’s doing, normally past just while it’s running, so now we’re talking about a data store of some kind. Likely a database, but what will AI create for you if you’re not specific about it? That’s a whole other topic! In THIS case, I want to see how it handles something that should be relatively straight forward, a simple Cloud SQL instance to back my application. I was thinking of a simple web-based game that needs to store some state.
My prompt just to have Gemini create an environment for me:
“I want to build a web game. It’s going to need a Cloud Run instance to serve the game, and a Cloud SQL database. Please create the infrastructure in the currently logged in project `gweiss-fun-game` and create some basic hello world code I can deploy as a starting place.”
I ran this a few times, using Antigravity (AGY), different models (both Gemini and Opus just to see how different things got). I tried it with the Data Agent Kit (DAK), and without. In almost every instance it was pretty close to the same. In some cases, it asked me what flavor of Cloud SQL I wanted, MySQL or PostgreSQL (never asked me about SQL Server even though that’s an option too), in the case of Gemini Carbon + DAK it was good enough to ask me what version of PostgreSQL I wanted (when it didn’t ask it defaulted to 16, not 18). And with AGY + DAK it actually asked me what size instance I wanted it to create. The rest of the time it created a micro instance. Basically the smallest it could.
But the biggest concern I had, because I know better, is how did it actually configure the DB? Did it follow what I’d consider best practices? Here’s the things that you really need to check when using AI to set up your database:

Connectivity
By default, Cloud SQL comes with public IP enabled and private IP disabled. This is. Well, it’s risky. Thankfully in every case I ran, it didn’t authorize any IPs. So while it did have a public IP enabled, there’s at least no way to connect to it directly from the outside. The bigger issue here is one of performance. When you don’t have private IP enabled, it means that you’re not just using Google’s internal networking, which means connections between services are slower, and of course, you’ve got a potential attack surface.
The part that got me here, is that the hello world code that it wrote to deploy to Cloud Run uses the Python Cloud SQL connector which, if you take a peek at the sample code there, has this beauty:
ip_type = IPTypes.PRIVATE if os.environ.get(“PRIVATE_IP”) else IPTypes.PUBLIC
It directly supports private IP connectivity. The only thing I could think of is that there’s enough discussion around making local development easier with public IP, that’s why the agent set that up. But, I’d still argue that when doing this for real, you should have both enabled, and have a switch in code that uses private IP when it’s available like it implicitly suggests in the Python connector sample code.

Database and user creation
Interestingly, rather than create a separate database for my game, in each case, the model just created a separate namespace in the postgres database. I personally don’t like this at all, as I like to keep things isolated more than that, especially when I’m not going to be doing any shenanigans around the system tables in the instance for any reason. It DID at least create a least-privileged user for the DB. But then it did something which on the surface SOUNDS good, which is it created the database user’s credentials in Secret Manager and accesses the secret from the code. This is actually a security risk! The agent that’s building out this infrastructure has my level of credentials in the project. It needed that in order to create the infra I wanted. That’s fine, but here’s where this is a problem: It created the secret. Which means it generated what the password for the user is. “But Gabe, why’s that a problem? It didn’t hardcode it or put it into an environment variable, it stored it as a secret!” Yes…but agents log their actions. They have memory, they store markdown files of their work. If they’re doing that, it means that likely, somewhere, you now have a log with that generated password in it. There’s a totally right way to do this, several actually, but that’s probably a whole blog post on its own. For now, for a system like this, it’s better to create the secret yourself, then just tell the initial prompt what the secret’s ID is and tell it to use that for the database user’s credentials so the agent never actually gets its hands on the secret itself.

Right sizing
I had called out that in most of the cases I ran this, it created a micro instance for me (1 vCPU and 1GB RAM specifically). This is…fine for me playing around, but also depending on what the game ends up doing, this is going to creak around the edges VERY fast. Not just from a performance standpoint, as unless you’re making something with a huge player base at once, the number of operations per second isn’t likely to really hit things too hard, but something a lot of folks don’t realize about micro instances is that they also limit your network throughput. So the network is actually slower on micro instances than larger ones. Depending on the web game, that might be fine, but it’s something to keep an eye on, that if you’re experiencing slower connections than you think you should be, it might be the instance size. You can see it when you create a new instance, it’ll show you the network throughput in the summary over on the right.

Security
This was the biggest place IMO that AI fell down. It set up the Cloud SQL instance allowing unencrypted connections. How much tolerance you have for this depends a lot on your environment of course. If your database is running in an airgapped system alongside the application and there’s no external access? Probably fine (probably!). But when you’re telling AI that your intention is to be creating a web game? There IS a performance consideration to requiring secure connection of course. On initial connection, there’s an extra round trip (sometimes two depending) over the network for the handshaking. But that can be mitigated with connection pooling, making sure your application is in the same zone as the database (not just region, but zone) so the network latency is minimized. Optimizing code to use transactions rather than per query connections, etc etc.
So unencrypted connections was the biggie, but there’s also nitpicks too. Logging for connections wasn’t turned on, which in ye olde days was super noisy in logs, but with Postgres 18 there’s granular controls over what parts get logged so it’s not bad, and is a good debugging tool if something starts going haywire, or your system comes under attack.
Finishing up
So that’s really it! I have to say, I’m having a ton of fun with how fast idea to deployed infrastructure and hands on prototyping is coming along with this current batch of models. AI’s at the point where it can set up your infra nice and quickly for you, and hopefully this post helps you keep an eye on what it did so that when you deploy your creation, you can feel confident the database is configured how you need it.
And if your application needs to do some AI magic itself, I can’t recommend AlloyDB Express enough. AlloyDB is the strongest AI-native, PostgreSQL-compatible offering out there, and with Express, it’s removed so many of the pain points. Scales to zero, just dealing with a database, not the rest of the infrastructure. If you don’t know where you’d want to start, check out this codelab which also walks through the new AlloyDB for Agents functionality where you have a sandbox version of your data just for your agents so it won’t do bad things to your production database!
How well can AI create your database? was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/how-well-can-ai-create-your-database-6f10983aee47?source=rss—-e52cf94d98af—4
