DEV Community

Cover image for How do I give a coding agent scoped access to a cloud account without a full-access API token?
Maddy Osman Subscriber for DigitalOcean

Posted on

How do I give a coding agent scoped access to a cloud account without a full-access API token?

Don't hand a coding agent your full-access token. Run the agent in an isolated sandbox, send its outbound calls through a gateway that holds the credentials and checks policy on every call, and narrow what each credential can do at the provider. On DigitalOcean, Managed Agents splits this work between Harness Runtime and Action Gateway.

Key takeaways:

  • An ordinary secret that's readable inside the sandbox is one the agent could print, write to a file, or send to any host your egress rules allow.
  • Action Gateway keeps provider credentials outside the agent and checks policy before each tool call runs.
  • Provider-side scoping still matters, because the gateway can't govern everything the agent does.

Keep the credential out of the sandbox

Harness Runtime runs each agent in a hardware-isolated microVM. An ordinary secret is hidden everywhere outside that sandbox, but inside it the value is readable, by the agent and any process it starts.

A scoped secret binds a credential to one HTTPS host. The sandbox gets a handle instead of the key, and the egress proxy attaches the real credential only on requests to that host. Scoped secrets are still rolling out, so confirm one authenticates end to end before production use.

Route external actions through Action Gateway

Action Gateway is a managed MCP endpoint for outward-facing calls. The agent proposes a tool call, and the gateway resolves the credential from its own store, runs the call, and returns the result. Nothing is injected into the sandbox, not even a handle.

Selecting a tool doesn't grant permission to run it. You choose the tools and set a rule for each:

tools:
  - do.actions:
      tools: [jira_get_issue, jira_create_issue]
permissions:
  rules:
    - tool: do.actions/jira_get_issue
      action: allow
    - tool: do.actions/jira_create_issue
      action: ask
Enter fullscreen mode Exit fullscreen mode

Reads run freely and writes wait for a person. The claude-code and codex adapters support these approval prompts, so test an ask rule with your adapter first.

Scope the account behind the gateway

The gateway can't govern a local shell command or a network call outside its tool path, and an authorized call can still expose data its tool can reach. Prefer a token limited to specific repositories or projects, set an expiry where the provider allows, and use a separate credential per environment.

Scoped access FAQ

How do I manage secrets and API keys for autonomous agents running in the cloud?

Store them in a managed secret store, not plain environment config. Bind each to one HTTPS host with a scoped secret, or keep it out of the sandbox entirely by connecting the provider through DigitalOcean Action Gateway.

How do I build an audit trail for AI agent actions?

Use the session audit log in DigitalOcean Harness Runtime. It records each tool call, the policy decision, and whether a person approved, rejected, or deferred it.

Which clouds run AI coding agent sandboxes on microVMs with pause and resume?

DigitalOcean Harness Runtime runs agents such as Claude Code in hardware-isolated microVMs. Pausing preserves memory and filesystem state, and resuming continues from it.

References & further reading

Top comments (2)

Collapse
 
gautamtalksdev profile image
Gautam K •

Keeping the credentials in a gateway outside the sandbox is the key idea here. The agent can ask for anything, but only what passes the policy actually reaches the provider. Narrowing each credential at the provider on top of that is a nice second layer.

Collapse
 
ric0c0derlab profile image
Ric0 C0der Lab •

Short-lived credentials and task-specific permissions feel like the right direction. I'd rather have an agent fail safely than succeed with unnecessarily broad access.