# Add connection role in project

`POST /v1/projects/{project}/connections/{connection}/roles`, operation `connections.AddConnectionRoleInProject`

Has an AWS connection assume another IAM role in the same AWS account after verifying trust. Returns the connection.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `project` | path | Yes | `string` | The project's ID. |
| `connection` | path | Yes | `string` | The connection's ID. |

## Request body

Content-Type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `displayName` | `string` | No | Name shown in user interfaces. Defaults to the role's name. |
| `roleArn` | `string` | Yes | The IAM role's ARN in the same AWS account as the connection's default role. Its trust policy must trust this connection's subject. |

## Responses

### 200

OK

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `availability` | `Availability` | Yes | For an organization's connection: the projects it is shared with. Choosing it for an access profile still takes connections.connections.use. A project's own connection serves that project alone, and is shared with none. |
| `availability.allProjects` | `boolean` | Yes | Every project, including those created later. |
| `availability.projects` | `string[]` | Yes | Projects, projects/{project_id}, when not all of them; at most 500. Past that, make the resource available to every project. |
| `config` | `map<string, string>` | Yes | Settings, as the type's configFields describe them. |
| `createTime` | `string (date-time)` | No | When the connection was created; unset on one that was only validated. |
| `displayName` | `string` | Yes | Name shown in user interfaces. Defaults to the type's name. |
| `name` | `string` | Yes | Resource name, organizations/{organization_id}/connections/{connection_id}, or projects/{project_id}/connections/{connection_id} for a project's own. |
| `roles` | `ConnectionRole[]` | No | For AWS, once set up: the IAM roles the connection assumes, its default one first. Each trusts the connection's identity subject. |
| `serviceAccounts` | `ConnectionServiceAccount[]` | No | For Google Cloud, once set up: the service accounts the connection acts as, its default one first. Each trusts the connection's identity, and its roles bound what its tokens can do. |
| `state` | `string` | Yes | Whether the service lets kosem act in the account: ACTIVE, it did when it was last verified; NEEDS_ATTENTION, it refused, or the connection isn't set up yet, and stateReason says why. Values: `ACTIVE`, `NEEDS_ATTENTION`. |
| `stateReason` | `string` | Yes | Why the connection needs attention. |
| `trust` | `ConnectionTrust` | No | What the service trusts of kosem for this connection, for a type connected by WORKLOAD_IDENTITY. |
| `trust.attributeCondition` | `string` | No | For Google Cloud: the attribute condition that the workload identity provider must have, which takes the identity tokens of this organization's connections, its projects' own among them, and of no environment. kosem's issuer is every customer's, so a provider without it trusts them all; each service account then lets one connection's subject act as it. |
| `trust.audience` | `string` | No | For AWS: the audience of kosem's identity tokens, sts.amazonaws.com, the client ID of the account's IAM OpenID Connect provider. |
| `trust.issuer` | `string` | Yes | kosem's issuer of identity tokens, whose keys it publishes at /.well-known/jwks.json. For AWS, the URL of the account's IAM OpenID Connect provider. |
| `trust.subject` | `string` | Yes | The subject of kosem's identity tokens for the connection: connection:{name}. Only kosem mints it, so trusting it trusts no other organization's connection and no environment. |
| `type` | `string` | Yes | The connection's type, such as connectionTypes/github. It never changes. |
| `updateTime` | `string (date-time)` | No | When the connection was last updated; unset on one that was only validated. |
| `verifyTime` | `string (date-time)` | Yes | When the service last let kosem act in the account, or refused. |

### default

Error

Base URL: `https://api.kosem.ai`. See [API conventions](https://docs.kosem.ai/reference/api-conventions.md) for authentication, pagination and errors, and [https://docs.kosem.ai/openapi.yaml](https://docs.kosem.ai/openapi.yaml) for the full OpenAPI document.