Platform/OS
Linux, macOS, Windows
Category
Infrastructure as Code
Terraform
Terraform is a simple tool that lets you describe exactly what your cloud setup should look like using plain text files. It acts like a smart recipe book that automatically builds, changes, or tears down your servers, databases, and networks so you don't have to click around in dashboards. It keeps a record of what it built and stores that important record in S3-compatible object storage so everyone on the team can see the same up-to-date picture. By saving these records and shared files in S3, Terraform makes sure no one accidentally overwrites someone else's work and that you can safely roll back if something breaks. This practical use of cheap, reliable S3 storage turns chaotic infrastructure management into a calm, repeatable process that saves time and prevents costly mistakes. HashiCorp Terraform is an IaC tool. It has native S3 backend for encrypted state files, locking, versioning, and team collaboration using any S3-compatible storage.
Connection / Setup
- Create an account and log in to DiskSpace
- Click I'm ready to set up my storage
- Enter Bucket Name following the instructions
- Click Create Bucket and wait for it to be generated
- Find your Endpoint URL, Access Key, and Secret Key in the S3 Client Configuration section for use below
Connecting DiskSpace.sh to Terraform
DiskSpace.sh is a fully S3-compatible object storage service. Follow the steps below to configure Terraform to use DiskSpace.sh as your S3 backend or with the AWS provider.
Connection Steps
- Log in to your DiskSpace.sh account and create a new bucket if you haven't already.
- Navigate to the Access Keys section and generate a new Access Key ID and Secret Access Key.
- Use the following configuration in your Terraform files.
Required Credentials
Endpoint URL:
https://s3.diskspace.sh
https://s3.diskspace.sh
Access Key ID:
Your DiskSpace.sh Access Key
Your DiskSpace.sh Access Key
Secret Access Key:
Your DiskSpace.sh Secret Key
Your DiskSpace.sh Secret Key
Region: Can be left empty or set to
us-east-1
Path Style Requests (Required)
DiskSpace.sh requires path-style requests. This means the bucket name must appear in the URL path, not in the hostname.
Correct format: https://s3.diskspace.sh/bucket-name/key
Incorrect (virtual-hosted): https://bucket-name.s3.diskspace.sh/key
Incorrect (virtual-hosted): https://bucket-name.s3.diskspace.sh/key
Terraform Configuration Example
terraform {
backend "s3" {
bucket = "your-bucket-name"
key = "terraform.tfstate"
region = "us-east-1"
endpoint = "https://s3.diskspace.sh"
access_key = "YOUR_ACCESS_KEY_ID"
secret_key = "YOUR_SECRET_ACCESS_KEY"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
force_path_style = true
}
}
Using with AWS Provider
provider "aws" {
access_key = "YOUR_ACCESS_KEY_ID"
secret_key = "YOUR_SECRET_ACCESS_KEY"
region = "us-east-1"
endpoints {
s3 = "https://s3.diskspace.sh"
}
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
s3_use_path_style = true
}
Troubleshooting
- Error "Invalid endpoint" → Ensure you are using
force_path_style = true(ors3_use_path_style = true) - Permission errors → Verify your Access Key has the correct IAM-like permissions on the target bucket
- Connection refused → Confirm you are using the exact endpoint:
https://s3.diskspace.sh - Region errors → Set region to
us-east-1or leave it empty