# Roles

Lenses IAM is built around Roles. Roles contain policies and each policy defines a set of actions a user is allow to take.

Roles are then assigned to groups.

## Role Policies

The Lenses policies are resource based. They are YAML based documents attached to a resource.

Each policy has:

1. Action
2. Resource
3. Effect

{% hint style="warning" %}
The resource is the **name** of the resource. This is defined by the creator of the resource.
{% endhint %}

### Action

The action describes the action or verb that a user can perform. The format of the action is

```
[entity type]:action
```

For example to list topics in Kafka

```yaml
policy
  - action:
    - kafka:ListTopics
```

{% hint style="info" %}
For a full list of the actions see [Permission Reference](https://github.com/lensesio-dev/docs/blob/release/6.0/user-guide/identity-and-access-management/permission-reference.md).

To allow all actions set '**\*'**
{% endhint %}

### Resource

To restrict access to resources, for example, only list topics being with ***red*** we can used use the **resource** field.

{% hint style="info" %}
For a full list of the actions see [Permission Reference](/latest/devx/6.0/user-guide/iam/iam-reference.md).

To allow all actions set '**\*'**
{% endhint %}

### Effect

Effect is either allow the action on the resource or deny. If allow is not set the action will be denied and if any policy for a resource has a deny effect it takes precedence.

## Create a Role

To Create Service Account go to **IAM->Roles->New Role.**

<figure><img src="/files/P3cSMtxiOnpI1qnqprUx" alt=""><figcaption><p>Create a roles &#x26; add permissions</p></figcaption></figure>

You can also manage Users via the CLI and YAML, for integration in your CI/CD pipelines.

{% code title="terminal" %}

```bash
➜  lenses roles
Manage Roles.

Usage:
  lenses roles [command]

Available Commands:
  create      Creates a new role.
  delete      Deletes a role.
  get         Returns a specific role.
  list        Returns all roles.
  metadata    Manages role metadata.
  update      Updates a role.
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.lenses.io/latest/devx/6.0/user-guide/iam/roles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
