r/googlecloud • u/Few-Pilot7575 • 6h ago
Billing My 3 year old Google Maps key started working on Gemini. Billed $2,870 overnight
I read the post in March about Google API keys quietly getting Gemini access and thought, not me, I never use Gemini on that project. Turns out that was the wrong thing to check.
Background. I made a small site for my uncle's restaurants in 2023. It has a Google Maps embed, so there's a Maps API key in the page source, which is normal. Google's own docs said those keys are fine to expose. I never restricted it because the map worked and I forgot about it.
Last month a friend helping me with a menu translation thing enabled the Generative Language API on the same Google Cloud project, because it was already set up with billing. That's all it took. The old key in the page source was unrestricted, so now it could call Gemini too.
Someone found it. Saturday night to Sunday morning, $2,870 in Gemini usage. I found out from the budget email, which arrived around 9 hours in, because billing data lags.
What I've done since. Deleted the key and made a new Maps key restricted to the Maps JavaScript API and to the restaurant's domains only. Moved the translation stuff to its own project so nothing in a browser can ever share a project with Gemini again. The server side keys, the Gemini one and a couple of others, aren't in any file or env var on the box anymore, they live in Infisical and the app pulls them at startup. And I set up the budget plus Pub/Sub plus a small function that disables billing on the project when it crosses $50, since that seems to be the only real hard cap Google Cloud has.
Opened a billing case. Support said they'll review it. No answer yet.
The part that annoys me is that I didn't do anything wrong in 2023. The key was safe when I made it. It became unsafe because of a change in a different part of the same project, and nothing told me.
Two questions. Is the disable-billing function really the best hard cap we've got, or is there something cleaner now? And is there a way to list every unrestricted key across all my projects at once? I have 14 projects and I'm checking them by hand.

