Managing SOS with Terraform
Simple Object Storage (or SOS) is S3 compatible. You can use the Terraform AWS provider to manage your SOS resources.
Provider configuration
In the provider configuration, you need to skip some AWS-specific validations:
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"
# Skip AWS validations
skip_credentials_validation = true
skip_requesting_account_id = true
skip_metadata_api_check = true
skip_region_validation = true
}
You can also set your credentials with these environment variables:
$ 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, each with a different alias
.
You can check Terraform’s provider configuration documentation for more information.
Manage your buckets
Create a bucket
resource "aws_s3_bucket" "my_bucket" {
bucket = "my-terraform-bucket"
Manage ACL
resource "aws_s3_bucket_acl" "example_bucket_acl" {
bucket = aws_s3_bucket.my_bucket.id
acl = "private"
}
Enable buckert versioning
resource "aws_s3_bucket_versioning" "my_bucket_versioning" {
bucket = aws_s3_bucket.my_bucket.id
versioning_configuration {
status = "Enabled"
}
}
Upload a file
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, but there is a chance we do not support certain features at this time. Make sure to check our list of S3 unsupported features.