# Manage Terraform

Simple Object Storage (or SOS) is S3 compatible. You can use the
[Terraform AWS provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
to manage your SOS resources.


## Provider configuration
In the provider configuration, you need to skip some AWS-specific validations:

```hcl-terraform
locals {
  zone = "ch-gva-2"
}

provider "aws" {

  endpoints {
    s3 = "https://sos-${local.zone}.exo.io"
  }

  region     = local.zone

  # access_key = "my-access-key"
  # secret_key = "my-secret-key"

  # Disable AWS-specific features
  skip_credentials_validation = true
  skip_region_validation      = true
  skip_requesting_account_id  = true
}
```

You can also set your credentials with these environment variables:

```bash
export AWS_ACCESS_KEY_ID="anaccesskey"
export AWS_SECRET_ACCESS_KEY="asecretkey"

```

To manage the buckets in multiple zones, you need to create
[multiple provider configurations](https://www.terraform.io/language/providers/configuration#alias-multiple-provider-configurations), each with a different `alias`.

You can check Terraform's [provider configuration](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#provider-configuration) documentation for more information.


## Manage your buckets

### Create a bucket
```hcl-terraform
resource "aws_s3_bucket" "my_bucket" {
  bucket   = "my-terraform-bucket"
}
```

### Manage ACL
```hcl-terraform
resource "aws_s3_bucket_acl" "example_bucket_acl" {
  bucket = aws_s3_bucket.my_bucket.id
  acl    = "private"
}
```

### Enable bucket versioning
```hcl-terraform
resource "aws_s3_bucket_versioning" "my_bucket_versioning" {
  bucket = aws_s3_bucket.my_bucket.id
  versioning_configuration {
    status = "Enabled"
  }
}
```

### Upload a file
```hcl-terraform
resource "aws_s3_object" "object" {
  bucket = aws_s3_bucket.my_bucket.id
  key    = "new_object"
  source = "myfile"
  acl = "public-read"
  etag = filemd5("myfile")
}
```

You can find [more S3 resources](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket),
but there is a chance we do not support certain features at this time. 
Make sure to check our list of [S3 unsupported features]({{< ref "/product/storage/object-storage/overview/#s3-unsupported-features" >}}).

