DEV Community

Thiago Arrais
Thiago Arrais

Posted on • Edited on

Storing your Terraform state in Ceph (2021)

This works with Terraform 1.5.x and earlier. If you're using 1.6 or beyond, try my newer post on this matter

If you've got access to a Ceph instance, you can use the S3 backend to store the Terraform state. The usage is pretty much the same as for S3 itself, we just need to make sure to set the following arguments:

  • endpoint
  • skip_credentials_validation
  • force_path_style

endpoint should be set to the hostname where your Ceph instance responds.

skip_credentials_validation controls if the backend validates credentials against Amazon STS. Since you can't count on STS to validate your Ceph credentials, this should be set to true.

force_path_style controls if bucket names are specified in subdomains (e.g. mybucket.myceph.myintranet) or in paths (e.g. myceph.myintranet/mybucket). The path style is more compatible with Ceph, so this also should be set to true.

Here is a copy-and-paste friendly version:

terraform {
  backend "s3" {
    bucket      = "your-bucket-name"
    key         = "a-key"
    region      = "us-east-1"
    endpoint    = "hostname.for.the.ceph.instance"
    access_key  = "your-access-key"
    secret_key  = "your-secret-key"

    skip_credentials_validation = true
    force_path_style            = true
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)