Rightshold™ Sign up

Answers · agent payments

How do I stop an AI agent with cloud credentials from running up a huge bill by launching GPU instances?

Last updated

TL;DR: Don't count on budget alerts. They are notifications, and the billing data behind them runs hours behind. Google Cloud says alerts-only budgets don't automatically stop usage, Azure says budgets don't affect resources or stop consumption, and AWS says billing data used by Budgets is updated at least once a day. Stop the spend before the resource exists instead. Give the agent its own account or project and a role that can only launch the instance types you allow (on AWS, an IAM or SCP deny on ec2:RunInstances when ec2:InstanceType isn't on your list). Keep GPU quotas at zero or small for that account. Make any create call that costs money go through a gate that asks a human above a set amount. Then add budget actions as a backstop: AWS Budgets actions can apply a deny policy or stop instances, and Google Cloud spend cap budgets pause some services (Gemini API, Vertex AI, Cloud Run and Cloud Run functions, not Compute Engine). Tag everything the agent launches and clean it up on a schedule, because a stopped instance's disks still cost money.

What should I check, step by step?

1. Give the agent its own AWS account, Google Cloud project or Azure subscription, so its spend, quotas and budgets are separate from production and can be cut off without touching anything else.

  1. Grant a role scoped to the task, not an admin key. On AWS, deny ec2:RunInstances unless ec2:InstanceType is on an allowlist (AWS's EC2 policy examples show this pattern for t2.micro and t2.small). Put the same deny in a service control policy so the agent can't attach a broader policy to itself.
  2. Keep GPU and accelerator quotas at zero, or as small as the task needs, in the agent's account. On AWS the default On-Demand vCPU quota for P, G and other accelerated families is 0, but AWS can raise quotas automatically based on usage, so check them and never let the agent's role request increases.
  3. Put a gate in front of every create call that costs money: estimate hourly cost times maximum runtime, and require a human approval above your threshold before the API call runs. Deny instance types or regions you didn't plan for.
  4. Set a maximum lifetime on everything the agent launches: tag it with the run id and an expiry time, and run a scheduled job that stops or terminates anything past its expiry. Delete orphaned volumes and snapshots too.
  5. Add budget actions as a backstop, not the main control. AWS Budgets actions can apply an IAM deny policy or SCP, or stop specific EC2 or RDS instances, automatically or after approval. Google Cloud can disable billing on a project from a budget Pub/Sub notification, which shuts down all its services.
  6. Use Google Cloud spend cap budgets where they apply (Gemini API, Vertex AI, Cloud Run, Cloud Run functions, one project and one service per budget). Compute Engine VMs aren't covered, and Google says enforcement isn't instant.
  7. Set budgets below the money you can actually afford, because reporting lags. Google recommends a budget below your available funds for this reason, and Azure says cost data is typically available within 8–24 hours.
  8. Watch for auto-recovery: AWS warns that if a budget action stops an instance in an Auto Scaling group, Auto Scaling restarts it or launches a replacement. Cap the group's maximum size too.

Why don't AWS, Google Cloud or Azure budget alerts stop an AI agent's runaway cloud spend?

An agent can launch a fleet of GPU instances in seconds, and they bill by the second or hour while the bill catches up. Cloud budgets are built on billing data that arrives later: AWS updates the data Budgets uses at least once a day, Google Cloud says there is a delay between use and costs reaching Cloud Billing, and Azure says cost data typically shows up within 8–24 hours.

How do I stop an AI agent from launching expensive GPU instances in the first place?

Permissions are checked when the API call is made, with no billing lag. An IAM or SCP deny on unapproved instance types, a zero GPU quota and a separate account for the agent stop the expensive launch from happening at all.

What do AWS Budgets actions and Google Cloud spend caps do when an agent overspends?

AWS Budgets actions can run automatically or after your approval when a threshold is crossed: apply a deny IAM policy or SCP so nothing new is provisioned, or target specific EC2 and RDS instances. From the management account you can apply an SCP to another account, but you can't target instances in another account.

How do I ask Rightshold about this (free, no key)?

Add the MCP server https://www.rightshold.com/mcp to Claude, Cursor, ChatGPT, Grok or VS Code, then ask: “My agent wants to launch 4 GPU instances for up to 6 hours, estimated $190. Ask me to approve that exact request before the agent calls the cloud API.”

One-click setup

{
  "tool": "request_human_approval",
  "arguments": {
    "action": {
      "provider": "aws",
      "api": "ec2:RunInstances",
      "region": "us-east-1",
      "instance_type": "<instance type>",
      "count": 4,
      "max_hours": 6,
      "estimated_cost_minor": 19000,
      "currency": "USD"
    },
    "summary": "Agent requests 4 GPU instances for up to 6 hours, est. $190",
    "credential_id": "crd_YOUR_AGENT_CREDENTIAL",
    "expires_in_minutes": 60
  }
}

Rightshold records approval requests, decisions and spending decisions on a hash-chained ledger. It doesn't hold your cloud credentials, call cloud APIs, read your bill or stop instances, so the IAM policies, quotas, budget actions and cleanup jobs described here run in your cloud account. Not financial advice.

What are the sources?

Related

Not legal advice. JSON · Markdown · All answers

Get a free API key in one call

No card and no email needed. 100 free credits; the license and policy checks stay free without a key.

curl -s -X POST https://www.rightshold.com/v1/accounts/signup -H "Content-Type: application/json" -d '{"accept_terms":true}'
export RIGHTSHOLD_API_KEY=rs_...   # the api_key from the reply (shown once)
curl -s https://www.rightshold.com/v1/licenses/check -H "Authorization: Bearer $RIGHTSHOLD_API_KEY" \
  -H "Content-Type: application/json" -d '{"license":"MIT","intended_use":{"commercial_use":true}}'