> For the complete documentation index, see [llms.txt](https://docs.firefly.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.firefly.ai/detailed-guides/oidc-provider/aws.md). Agents can also search and read this documentation through its [MCP server](https://docs.firefly.ai/~gitbook/mcp).

# Amazon Web Services (AWS)

This guide will walk you through configuring OpenID Connect (OIDC) authentication between Firefly and AWS. OIDC allows Firefly to securely access your AWS resources without the need for long-lived static credentials.

## Configure Firefly as an Identity Provider

You need to set up Firefly as a valid identity provider for your AWS account. This is done by creating an OpenID Connect identity provider in AWS. Configuration is done via the AWS console:

### Step 1: Access AWS IAM

1. Go to the AWS console and select the IAM service.
2. Click **Identity providers** in the left-hand menu.
3. Click **Add provider** in the top bar.

### Step 2: Configure the Provider

1. Select **OpenID Connect** as the provider type.
2. Enter the following details:
   * **Provider URL:** the Firefly issuer for your region (see the table below)
   * **Audience:** `sts.amazonaws.com`
3. Once created, the identity provider will be listed in the "Identity providers" table.

| Firefly region | Provider URL                   |
| -------------- | ------------------------------ |
| US             | `https://api.gofirefly.io/v2`  |
| EU             | `https://api.eu.firefly.ai/v2` |

> **Include the `/v2` suffix.** It is part of the issuer Firefly puts in the token. The provider URL also determines the condition keys in the trust policy: `api.gofirefly.io/v2:sub` in the US, `api.eu.firefly.ai/v2:sub` in the EU.

### Step 3: Add Firefly OIDC as the Role Provider

You can click on the provider name to see the details. From here, you will assign an IAM role to this new identity provider:

1. Click **Assign role**, and choose to create a new role.
2. Click **Web identity** and select the new Firefly OIDC provider as the trusted entity.

   ![AWS IAM Create Role - Web Identity Selection](https://292727710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkD89Ravlokn4JL0Be27O%2Fuploads%2Fgit-blob-1694bf82d531ebe8129a6c06a9401ccf8599633e%2Foidc-aws-web-identity-selection.png?alt=media)
3. Select the audience from the dropdown (there should only be one option).

   ![AWS IAM Create Role - Web Identity Configuration](https://292727710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkD89Ravlokn4JL0Be27O%2Fuploads%2FozNup28Zclz8LEKKeJE3%2F1.png?alt=media\&token=ee317515-112a-45e0-83dd-97401ba21efb)
4. Add a condition for `:sub` where the value is `account:FIREFLY_ACCOUNT_ID` (replace `FIREFLY_ACCOUNT_ID` with your actual Firefly account ID).

   ![AWS IAM Create Role - Web Identity Condition Configuration](https://292727710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkD89Ravlokn4JL0Be27O%2Fuploads%2FLHKlihj0Rp8TXkyw0a2W%2F2.png?alt=media\&token=772f5e2c-cf2a-4f74-8953-46349a07b77c)
5. The rest of the process is the same as for any other role creation. Select the policies you want to attach to the role, and add tags and a description.

   ![AWS IAM Create Role - Add Permissions](https://292727710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkD89Ravlokn4JL0Be27O%2Fuploads%2F6cOE8VyVUgux9N1M0zZf%2F3.png?alt=media\&token=a1943782-e9c8-4358-8341-619492212a1a)
6. Once you're done, click **Create role**.

**Example policy (US region; in the EU replace `api.gofirefly.io/v2` with `api.eu.firefly.ai/v2` everywhere):**

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::123456789:oidc-provider/api.gofirefly.io/v2"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "api.gofirefly.io/v2:sub": "account:123456789",
                    "api.gofirefly.io/v2:aud": "sts.amazonaws.com"
                }
            }
        }
    ]
}
```

![AWS IAM Role Created - Permissions Summary](https://292727710-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkD89Ravlokn4JL0Be27O%2Fuploads%2FwhB8cEXAlreLKAZLZLE4%2F4.png?alt=media\&token=d9a9d887-a07a-48f3-9a03-2edde3d0c426)

## Terraform Configuration

Once OIDC is enabled on a project or workspace in Firefly (see [Configuring OIDC in Firefly](#configuring-oidc-in-firefly)), Firefly provides the role and the web identity token to every run. Configure your code in **one** of the two ways below.

> **Don't set `web_identity_token_file`** in the provider or the backend. If your configuration has `web_identity_token_file = var.aws_web_identity_token_file`, remove it and use Option A or Option B.

### Option A (recommended): No OIDC configuration in code

Leave authentication out of your code entirely. The AWS provider and the S3 backend pick up the role and the token automatically.

```hcl
terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "path/to/terraform.tfstate"
    region = "us-east-1"
  }
}

provider "aws" {
  region = "us-east-1"
}
```

This works the same with Terraform and OpenTofu, and nothing needs to change in code when the role changes in Firefly.

### Option B: Set the role explicitly

If you want the role to be visible in code, set only `role_arn` in `assume_role_with_web_identity`.

Declare the variable that Firefly fills in:

```hcl
variable "aws_role_arn" {
  description = "ARN of the IAM role to assume with web identity"
  type        = string
}
```

Provider:

```hcl
provider "aws" {
  assume_role_with_web_identity {
    role_arn = var.aws_role_arn
  }
}
```

S3 backend: Terraform does not allow variables in a `backend` block, so put the role ARN in directly. With OpenTofu you can use `role_arn = var.aws_role_arn` instead.

```hcl
terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "path/to/terraform.tfstate"
    region = "us-east-1"

    assume_role_with_web_identity = {
      role_arn = "arn:aws:iam::123456789012:role/firefly-oidc-role"
    }
  }
}
```

### State Backend Permissions

With either option, the role needs read and write access to the state object, and to the lock file (`<key>.tflock`) if you use S3 native locking.

### Alternative: Integration-level OIDC

With Firefly-managed runners, you can save the OIDC role on the AWS Integration instead (**Write access → OIDC role**) and bind workspaces to it. No Terraform variables or `assume_role_with_web_identity` configuration are needed. See [Cloud Credentials for Workflows](https://docs.firefly.ai/detailed-guides/workflows/cloud-credentials.md).

## Configuring OIDC in Firefly

Once the identity provider and role exist in AWS, enable OIDC in Firefly on a **project** or on a **workspace**. In both places the setting looks the same:

1. Check **Enable OIDC authentication**.
2. Under **Cloud provider**, select **AWS**.
3. Firefly shows the **Provider URL**, **Audience** and **Condition on :sub** values to use in AWS, with copy buttons. They should match what you configured above.
4. Enter the **Role ARN** of the role you created (e.g., `arn:aws:iam::123456789012:role/firefly-oidc-role`).

### How project and workspace settings combine

* **Project level applies to everything below it.** OIDC set on a project is inherited by all of its sub-projects and their workspaces. If several projects in the chain have OIDC set, the nearest one to the workspace wins.
* **Workspace level is for one workspace.** Set OIDC on a workspace when it isn't under an OIDC-enabled project, or to use a different role than the one it inherits. A workspace's own Role ARN takes precedence over the inherited one.
* **Inherited OIDC can't be turned off per workspace.** Clearing the checkbox on a workspace removes only the workspace's own setting; the project's setting still applies. To stop using OIDC, disable it on the project that sets it, or move the workspace to a project without OIDC.
* **New workspaces start from the project's setting.** When you create a workspace in an OIDC-enabled project, the OIDC fields are pre-filled from that project. You can change the Role ARN there.
* **Integrations take precedence.** A workspace bound to an AWS Integration with write credentials uses the Integration's credentials, and the OIDC setting is unavailable for it. See [Alternative: Integration-level OIDC](#alternative-integration-level-oidc).

### At the project level

* **New project:** **Workflows → Projects & Variables → New Project**, then enable OIDC as described above.
* **Existing project:** in **Workflows → Projects & Variables**, open the project's actions and choose **Edit**, then enable OIDC as described above.

### At the workspace level

* **New workspace:** in the **New Workspace** wizard, go to the **Configuration** step. Under **Runner Configuration**, enable OIDC as described above.
* **Existing workspace:** open the workspace and choose **Edit Workspace** (the workspace's **Configuration** tab is view-only). Go to the **Configuration** step. Under **Runner Configuration**, enable OIDC as described above.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.firefly.ai/detailed-guides/oidc-provider/aws.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
