# Passing credentials for S3 snapshot repository in Terraform

**URL:** https://discuss.elastic.co/t/passing-credentials-for-s3-snapshot-repository-in-terraform/353924
**Category:** Elasticsearch
**Tags:** snapshot-and-restore
**Created:** [February 22, 2024, 8:45pm UTC](https://discuss.elastic.co/t/passing-credentials-for-s3-snapshot-repository-in-terraform/353924 "2024-02-22T20:45:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![acormier-spectrumai](https://avatars.discourse-cdn.com/v4/letter/a/4da419/32.png) [@acormier-spectrumai](https://discuss.elastic.co/u/acormier-spectrumai)
#### Post date: [February 22, 2024, 8:45pm UTC](https://discuss.elastic.co/t/passing-credentials-for-s3-snapshot-repository-in-terraform/353924/1 "2024-02-22T20:45:12Z")

</div>

Hello,

I am trying to setup a new ELK stack in Terraform, that also includes our configurations/settings/etc. One of the settings I would like to configure is snapshot lifecycle management, and a snapshot repository.

I plan to use an S3 bucket for the repository but am struggling to figure out how to fully configure this in terraform because it does not seem as though it is possible to provide an IAM access and secret key into the Terraform configuration.

I have been able to do this using the API with:

```auto
curl -X PUT "https://username:password@localhost:9200/_snapshot/s3_repository?pretty" -H 'Content-Type: application/json' -d'
{
  "type": "s3",
  "settings": {
    "bucket" : "logs",
    "access_key": "AWS_ACCESS_KEY_ID",
    "secret_key": "AWS_SECRET_ACCESS_KEY",
    "protocol": "https",
    "server_side_encryption": true
  }
}
'

```

though it did take some time to come to this because the `access_key` and `secret_key` fields weren't listed in the API docs I found.

Is there something I'm missing? The Kibana and ES hosts of our ELK stack are hosted outside of AWS, so I'm not able to apply an IAM policy to the host, or any other internal AWS method.

Thanks,  
Alex

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 21, 2024, 8:45pm UTC](https://discuss.elastic.co/t/passing-credentials-for-s3-snapshot-repository-in-terraform/353924/2 "2024-03-21T20:45:41Z")

</div>

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