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

# AWS

> Give tasks AWS credentials through an IAM role that trusts Niteshift-issued OIDC tokens.

Niteshift obtains and refreshes credentials for AWS tools and libraries using OIDC.

> [!TIP]
>
> Ask the agent in a task to connect AWS. It writes the configuration, walks you through the
> cloud-side setup below, and verifies access. See the [quick
> start](https://docs.niteshift.dev/integrations/overview.md#quick-start).

Within Niteshift, the configuration lives within `settings.yaml`. You can declare each AWS profile that you want to configure:

```yaml settings.yaml theme={"dark"}
version: 1
integrations:
  aws:
    - profile: default
      roleArn: arn:aws:iam::111122223333:role/NiteshiftDevelopment
      audience: sts.amazonaws.com
      region: us-east-2
    - profile: analytics
      roleArn: arn:aws:iam::444455556666:role/NiteshiftAnalytics
      audience: sts.amazonaws.com
      region: eu-west-1
```

You need to have at least one `default` profile.

For each AWS profile, run `ns oidc-token --inspect --audience '<configured-audience>'` in the
Niteshift terminal tab with that profile's `audience` (for example, `sts.amazonaws.com`). This
shows the exact `iss`, `aud`, and environment-specific `sub` without printing the token.

In each role's AWS account, configure an OIDC identity provider using the inspected `iss` and
register the inspected `aud` as an allowed audience. Each role's trust policy should require
**both the exact inspected `aud` and `sub`**, as shown in the example below. Trusting only the shared
issuer and audience does not restrict access to your Niteshift environment.

Use this trust policy, replacing
`<role-account-id>` with the role's AWS account ID and `<inspected-aud>` and `<inspected-sub>`
with the exact inspected values. The `sub` has the form `org:<org_id>:environment:<environment_id>`;
copy the entire inspected value without wildcards.

```json theme={"dark"}
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::<role-account-id>:oidc-provider/identity.niteshift.dev"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "identity.niteshift.dev:aud": "<inspected-aud>",
          "identity.niteshift.dev:sub": "<inspected-sub>"
        }
      }
    }
  ]
}
```

Repeat this setup for every configured role
and account. [AWS's OIDC role guide](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html)
covers trust and separate role permissions policies.


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