# Using an IAM Role instead of IAM User?

**URL:** <https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206>\
**Category:** Grafana Loki\
**Tags:** loki, aws\
**Created:** [October 23, 2023, 5:16pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206 "2023-10-23T17:16:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwbcharboneau](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/gwbcharboneau/32/39067_2.png) [@gwbcharboneau](https://community.grafana.com/u/gwbcharboneau)\
**Post date:** [October 23, 2023, 5:16pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/1 "2023-10-23T17:16:28Z")

</div>

Is it possible when running OSS Loki on an AWS EC2 (or a host running AWS SSM Agent), to use an IAM Role (or instance profile) instead of IAM User for Loki to access S3?

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [October 23, 2023, 5:33pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/2 "2023-10-23T17:33:13Z")

</div>

Yes, no reason not to do that if you are running in AWS.

---

<div class="post-metadata">

**Author:** ![gwbcharboneau](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/gwbcharboneau/32/39067_2.png) [@gwbcharboneau](https://community.grafana.com/u/gwbcharboneau)\
**Post date:** [October 23, 2023, 5:36pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/3 "2023-10-23T17:36:33Z")

</div>

@ [tonyswumac](https://community.grafana.com/u/tonyswumac) so it will pickup from the Instance Profile role Environment vars?

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [October 23, 2023, 5:48pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/4 "2023-10-23T17:48:15Z")

</div>

You should not need to set instance profile if it’s attached to the instance. Please see [Using instance profiles - AWS Identity and Access Management](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html). Also this is not Loki related, I’d recommend you to ask AWS related questions in their forums.

---

<div class="post-metadata">

**Author:** ![gwbcharboneau](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/gwbcharboneau/32/39067_2.png) [@gwbcharboneau](https://community.grafana.com/u/gwbcharboneau)\
**Post date:** [October 23, 2023, 5:58pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/5 "2023-10-23T17:58:26Z")

</div>

it is Loki Related, as im asking for step 3 that talks to IAM User (Access Key/SecretKey) in this doc:  
[https://grafana.com/docs/loki/latest/setup/install/helm/install-monolithic/](https://grafana.com/docs/loki/latest/setup/install/helm/install-monolithic/)

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/a/a/aa8541438b060331aa1173481a4f281b1847a598.png)

---

<div class="post-metadata">

**Author:** ![freaman](https://avatars.discourse-cdn.com/v4/letter/f/ebca7d/32.png) [@freaman](https://community.grafana.com/u/freaman)\
**Post date:** [November 28, 2023, 12:57pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/6 "2023-11-28T12:57:46Z")

</div>

Hello,  
Looks like I’ve got the same issue.  
I installed a docker with Loki, in AWS, EC2 has a role-based access to S3. I’ve checked via AWS CLI - access-policy works fine. Nevertheless, if I try to start Loki-docker, I get an error:  
`msg="error running loki" err="NoCredentialProviders: no valid providers in chain. Deprecated.`  
Here I use config of Loki like this:

```auto
storage_config:
  aws:
    s3: s3://<my_region_here_goes>
    bucketnames: <my_s3_name_here_goes>
  tsdb_shipper:
    active_index_directory: /loki/tsdb-index
    cache_location: /loki/tsdb-cache
    shared_store: s3

```

if I modify line with s3 like this:  
s3: s3://\<ACCESS\_KEY\>/\<SECRET\_KEY\>@\<my\_region\_here\_goes\>  
it works fine. But I’d like not to use credentials, but via aws role like here is

 ![Loki_examle](https://us1.discourse-cdn.com/grafana/original/3X/b/e/be0e6776a5671c4cd8f8a25a5290ee44394c0124.png)  
and no matter how I apply a bucketname - as a separated parameter, or in one line with aws\_region, it doesn’t work.

Will appreciate any help  
Best regards

---

<div class="post-metadata">

**Author:** ![anarvaez](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@anarvaez](https://community.grafana.com/u/anarvaez)\
**Post date:** [January 30, 2024, 3:41pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/7 "2024-01-30T15:41:35Z")

</div>

I’m running into this same issue, did you ever find a solution to using aws roles instead of specifying the keys?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/grafana/original/2X/e/ef5308cc58c9e5a13187b5012eb99f406928462f.png) [@system](https://community.grafana.com/u/system)\
**Post date:** [January 29, 2025, 3:41pm UTC](https://community.grafana.com/t/using-an-iam-role-instead-of-iam-user/106206/8 "2025-01-29T15:41:46Z")

</div>

Closed on January 29, 2025, 3:41pm UTC

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
