# How to assing permission to generate CSV in Terraform

**URL:** <https://discuss.elastic.co/t/how-to-assing-permission-to-generate-csv-in-terraform/362224>\
**Category:** Terraform\
**Created:** [June 28, 2024, 6:38pm UTC](https://discuss.elastic.co/t/how-to-assing-permission-to-generate-csv-in-terraform/362224 "2024-06-28T18:38:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pi314](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@pi314](https://discuss.elastic.co/u/pi314)\
**Post date:** [June 28, 2024, 6:38pm UTC](https://discuss.elastic.co/t/how-to-assing-permission-to-generate-csv-in-terraform/362224/1 "2024-06-28T18:38:04Z")

</div>

Hello everyone, I use Elastic Cloud. I have created the following role in terraform.

```auto
resource "elasticstack_elasticsearch_security_role" "users_analyst" {
  name = "users-analyst"
  cluster = ["monitor_watcher"]

  indices {
    allow_restricted_indices = false
    names = ["logs-*", "metrics-*"]
    privileges = ["read"]
    query = jsonencode(
      {
        "bool" : {
          "should" : [
            { "match_phrase" : { "data_stream.namespace" : "stage" } },
            { "match_phrase" : { "data_stream.namespace" : "production" } },
            { "match_phrase" : { "data_stream.namespace" : "development" } }
          ]
        }
      }
    )
    field_security {
      except = []
      grant = ["*"]
    }
  }

  applications {
    application = "kibana"
    privileges = ["read"]
    resources = ["*"]
  }

  applications {
    application = "kibana-.kibana"
    privileges = [
      "feature_canvas.all",
      "feature_dashboard.all",
      "feature_discover.all",
      "feature_graph.all",
      "feature_maps.all",
      "feature_visualize.all"
    ]
    resources = ["*"]
  }

}

```

For security I need that users can only generate a CSV report from the option "Shared" \> "CSV Reports" is possible?

When I try to do so I see this error message

# Unable to create report

```auto
Error
    at fetch_Fetch.fetchResponse (https://x.kb.vpce.us-east-1.aws.elastic-cloud.com/66491/bundles/core/core.entry.js:1:290551)
    at async https://x.kb.vpce.us-east-1.aws.elastic-cloud.com/66491/bundles/core/core.entry.js:1:288484
    at async https://x.kb.vpce.us-east-1.aws.elastic-cloud.com/66491/bundles/core/core.entry.js:1:288441

```

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![pi314](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@pi314](https://discuss.elastic.co/u/pi314)\
**Post date:** [June 28, 2024, 6:38pm UTC](https://discuss.elastic.co/t/how-to-assing-permission-to-generate-csv-in-terraform/362224/2 "2024-06-28T18:38:35Z")

</div>

Removed #elastic-cloud
