# Roles

Lenses IAM is role-based. Roles contain one or more policies. Each policy defines actions a user is allowed to perform on resources.

Roles are then assigned to groups.

## Role Policies

Policies are resource-based. They are YAML documents attached to a role.

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

```
service:operation
```

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](/latest/devx/6.1/user-guide/iam/iam-reference.md).

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

### Resource

Resources scope a policy to specific entities. For example, to only allow topics that start with `red`, use the `resource` field.

{% hint style="info" %}
For a full list of the actions see [Permission Reference](/latest/devx/6.1/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 a role, go to **IAM → Roles → New Role**.

<figure><img src="/files/qoM53umjsVxQq4oirien" alt=""><figcaption><p>Create a role and add permissions</p></figcaption></figure>

You can also manage roles via the CLI and YAML, for CI/CD automation.

{% 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.1/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.
