> For the complete documentation index, see [llms.txt](https://docs.datafy.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datafy.io/set-up-and-installation/datafy-installation/permissions-configuration.md).

# Permissions Configuration

Datafy requires basic AWS permissions to view the EC2 instances your volumes are attached to, and to control the creation and modification of EBS volumes.

You grant these permissions by creating a dedicated IAM role and providing its ARN to Datafy.

{% hint style="info" %}
Permissions are configured per AWS account. If you wish to install Datafy on multiple AWS accounts, the following steps need to be performed for each account.
{% endhint %}

## Configure IAM Role

{% stepper %}
{% step %}

#### Create IAM Role

We provide CloudFormation and Terraform templates for creating an IAM role. The template creates an IAM OIDC[^1] identity provider and an IAM role. The identity provider is used to authenticate that only Datafy uses the created role.

When creating the role, define the permissions level of the role according to the Datafy product you intend to install:

* **Sensor** **permissions** - the role provides read-only permissions. It lets Datafy retrieve data about EC2 instances and the volumes attached to them.
* **AutoScaler** **permissions** - the role includes all of the Sensor read-only permissions, and adds modification and creation permissions. The role allows creation, modification and deletion of EBS volumes, which are used to manage your EBS storage devices.

The role is scoped to your Datafy [account or organization](https://docs.datafy.io/set-up-and-installation/account-management.md). This protects your AWS account: only your own Datafy account or organization can assume the role, even if someone else knows its ARN.

* Use your **Organization ID** to allow any sub-account under that organization to use the role.
* Use a specific **Account ID** to restrict the role to a single sub-account.

Both IDs are shown on the [**Permissions** page](https://app.datafy.io/settings) in the Datafy app (see [#define-role-arn-in-datafy-account](#define-role-arn-in-datafy-account "mention") below). You can also read them through the [Datafy Terraform provider](https://registry.terraform.io/providers/datafy-io/datafy/latest/docs), as described in the **Terraform module** tab below.

{% tabs fullWidth="false" %}
{% tab title="CloudFormation template" %}
[Open the template in the AWS CloudFormation console](https://console.aws.amazon.com/cloudformation/home#/stacks/create/review?stackName=datafyio-iam\&templateURL=https://datafy-public-bucket.s3.amazonaws.com/cloudformation-templates/iam-role/cloudformation.yaml). The stack is created in the region currently selected in the console.

Alternatively, create a new CloudFormation stack and use the URL below as the template source (see screenshot).

{% code title="S3 URL" overflow="wrap" %}

```url
https://datafy-public-bucket.s3.amazonaws.com/cloudformation-templates/iam-role/cloudformation.yaml
```

{% endcode %}

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2Fgit-blob-e47a09ec568bb811d42c582aed246b4e54ea2166%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

In the Parameters section, choose the desired permissions level from the **Role Permissions Level** dropdown.

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2Fgit-blob-7f3258387aae8250ecb46df4f20ea8f6f4c23681%2Fimage%20(61).png?alt=media" alt=""><figcaption></figcaption></figure>

Paste the Organization ID or Account ID into the **Datafy Account ID** field under **Identity Configuration**. This field is required.

<figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2Fgit-blob-475fb5b549ad1efef6b0fefba8c185a0b9b411ae%2Fimage%20(60).png?alt=media" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Terraform module" %}
{% hint style="info" %}
The `iam-role` module has moved. It is now a submodule of the [datafy-io/modules/aws](https://registry.terraform.io/modules/datafy-io/modules/aws/latest) collection. The standalone `datafy-io/iam-role/datafy` module is deprecated and will receive no further updates.

The inputs are unchanged. To migrate, point `source` at the new location:

```hcl
module "datafy_role" {
  source  = "datafy-io/modules/aws//modules/iam-role"
  version = "~> 1.0"
}
```

{% endhint %}

Create the role using the [iam-role Terraform module](https://registry.terraform.io/modules/datafy-io/modules/aws/latest/submodules/iam-role?tab=inputs). The main inputs are:

* `permissions_level` — `Sensor` or `AutoScaler`.
* `permissions_scope` — `Global`, or `Regional` (with a `regions` list).
* `account_id` (required) — Datafy Organization ID or Account ID to scope the role.

If you manage your Datafy accounts with the [Datafy Terraform provider](https://registry.terraform.io/providers/datafy-io/datafy/latest/docs), you can read the ID from the [`datafy_account`](https://registry.terraform.io/providers/datafy-io/datafy/latest/docs/resources/account) resource or data source, using `.id` for a sub-account or `.parent_account_id` for the organization, and pass it to `account_id`.

See the [module documentation](https://registry.terraform.io/modules/datafy-io/modules/aws/latest/submodules/iam-role?tab=inputs) for the full list of inputs and examples.
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

#### Define Role ARN in Datafy Account

* In the Datafy app, go to the **Permissions** section of the [account settings](https://app.datafy.io/settings). An Admin role is required to access the settings panel.
* Fill in the ARN of the IAM role you just created.
* The IAM role associated with the ARN will be validated. If the ARN is incorrect, or the permissions in the associated role are incorrect, you will receive an error.

The Permissions page also displays the **Organization ID** at the top and the **Account ID** under each sub-account. Copy either to use as the `Datafy Account ID` parameter when creating the role.

{% hint style="info" %}
If the role cannot be validated, for example because your AWS account has an attached organizational [SCP](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html), you can skip the validation and insert the role anyway. Make sure your role has all of the necessary permissions for Datafy to work as expected.
{% endhint %}

<div data-with-frame="true"><figure><img src="https://771905169-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2lvi9EYpK4joSC6ZszEI%2Fuploads%2FniVMrB5SK5STTPyST5Ir%2FSingle%20Account%20-%20Without%20Sub%20Policies..png?alt=media&amp;token=17eb6fb2-f37b-4abd-ae4c-a36d301d5fff" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
The role ARN can also be registered programmatically using the [`datafy_role_arn`](https://registry.terraform.io/providers/datafy-io/datafy/latest/docs/resources/role_arn) resource from the Datafy Terraform provider.
{% endhint %}
{% endstep %}
{% endstepper %}

{% hint style="info" %}
If you're using custom encryption keys, ensure that the Datafy role isn't restricted by your KMS policy. Datafy needs to be able to create volumes that "inherit" the keys of the original source volume that is being auto-scaled
{% endhint %}

## Validate Configuration

After you've created and defined the IAM role, you can see all of the volumes in your account in the [Datafy app](https://app.datafy.io/fleet-manager).

At this stage, you can view the AWS attributes of each volume, including its provisioned size, but not the actual utilization. To view the utilization of each volume, continue with the installation process.

## Scope an Existing Role

Roles created with earlier versions of the template could be left unscoped, and keep working. To scope one, update it in place with your Organization ID or Account ID. The role ARN stays the same, so you don't need to change anything in the Datafy app.

Use the ID of the Datafy account the role is registered under, or of its organization. A role scoped to a different account can no longer be assumed by Datafy.

{% tabs fullWidth="false" %}
{% tab title="CloudFormation template" %}

1. In the AWS CloudFormation console, select the stack that created the role and choose **Update stack** > **Make a direct update**.
2. Choose **Replace existing template** and paste the S3 URL:

{% code title="S3 URL" overflow="wrap" %}

```url
https://datafy-public-bucket.s3.amazonaws.com/cloudformation-templates/iam-role/cloudformation.yaml
```

{% endcode %}

3. Paste the Organization ID or Account ID into the **Datafy Account ID** field. Keep the other parameters as they are.
4. Submit the update.
   {% endtab %}

{% tab title="Terraform module" %}

1. Set `account_id` on the `iam-role` module to your Organization ID or Account ID. If you register the role with the [`datafy_role_arn`](https://registry.terraform.io/providers/datafy-io/datafy/latest/docs/resources/role_arn) resource, use the same account it registers the role under, for example `datafy_account.<name>.id`, or that account's `parent_account_id`.
2. Run `terraform init -upgrade` to get the latest module version.
3. Run `terraform apply`. The plan updates the role's trust policy in place. The `datafy_role_arn` resource doesn't change.

{% hint style="info" %}
If `terraform plan` reports that the `account_id` variable has no value, your configuration has picked up the latest module version, which requires it. Set `account_id` as described above.
{% endhint %}
{% endtab %}
{% endtabs %}

[^1]: OpenID Connect


---

# 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.datafy.io/set-up-and-installation/datafy-installation/permissions-configuration.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.
