> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Federated access

> Let a Devbox reach AWS, GCP, or any OIDC service with short-lived credentials instead of stored keys.

> [!NOTE]
>
> Every Devbox comes with [Namespace workload identity](https://namespace.so/docs/federation/index.md). The [`nsc` CLI](https://namespace.so/docs/reference/cli/installation) is installed and logged in on every Devbox, and uses it to get short-lived credentials.

Your agent can deploy to AWS, read a bucket, or call your own API without you storing a key or pasting one into its prompt. The Devbox proves who it is with a token Namespace signs, and gets back credentials that expire on their own, after one hour by default.

## Trust Namespace in your cloud

Set this up once in your cloud account: [AWS](https://namespace.so/docs/federation/aws.md#accessing-aws-resources-from-namespace) or [GCP](https://namespace.so/docs/federation/gcp.md#accessing-gcp-resources-from-namespace). The trust covers your whole workspace, so every Devbox in it, and every other Namespace machine, can use the role you allow.

## Get AWS credentials

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox exec my-devbox -- \
  nsc aws assume-role --role_arn ROLE_ARN --write_env aws.env
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
await devbox.exec([
  "nsc", "aws", "assume-role",
  "--role_arn", ROLE_ARN,
  "--write_env", "aws.env",
]);
```

This writes the credentials to `aws.env` as environment variables. Source it before running AWS tools.

## Get GCP credentials

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox exec my-devbox -- \
  nsc gcp impersonate \
    --service_account SERVICE_ACCOUNT \
    --workload_identity_provider PROVIDER \
    --write_creds /tmp/gcp-creds.json
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
await devbox.exec([
  "nsc", "gcp", "impersonate",
  "--service_account", SERVICE_ACCOUNT,
  "--workload_identity_provider", PROVIDER,
  "--write_creds", "/tmp/gcp-creds.json",
]);
```

Point `GOOGLE_APPLICATION_CREDENTIALS` at `/tmp/gcp-creds.json` so Google Cloud tools use it.

## Get a token for any OIDC service

```bash CLI theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
devbox exec my-devbox -- \
  nsc auth issue-id-token --audience https://api.example.com
```

```typescript TS SDK theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
const { stdout } = await devbox.exec([
  "nsc", "auth", "issue-id-token",
  "--audience", "https://api.example.com",
  "-o", "json",
]);

const { id_token } = JSON.parse(stdout);
```

The token is signed by `https://federation.namespaceapis.com`, so any service that accepts OIDC tokens can verify it. Set the audience to the value that service expects.

## Related

* [Workload federation](https://namespace.so/docs/federation/index.md) for the other direction: reaching Namespace from AWS, GCP, or CI.
* [Secrets](https://namespace.so/docs/devbox/secrets.md) for services that only accept an API key.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.