Skip to main content

cloider_bucket_regions data source (Terraform)

The cloider_bucket_regions data source lists the regions a cloider_bucket can be created in, with each region's code, name and S3 endpoint. The default region, the one a bucket gets when you don't set region, comes first.

At a glance​

ArgumentsNone
Returnsregions, a list of code, name, endpoint
Changes anything?No, it only reads
APIGET /api/buckets/regions, see Bucket endpoints
CLI equivalentcloider bucket regions

Example usage​

List the regions​

main.tf
data "cloider_bucket_regions" "all" {}

output "bucket_regions" {
value = { for r in data.cloider_bucket_regions.all.regions : r.code => r.name }
}
Output
bucket_regions = {
"eu-central-2" = "Europe"
}

Create a bucket in a region by code, and output its endpoint​

main.tf
data "cloider_bucket_regions" "all" {}

locals {
regions = { for r in data.cloider_bucket_regions.all.regions : r.code => r }
}

resource "cloider_bucket" "assets" {
name = "acme-assets"
region = local.regions["eu-central-2"].code
}

output "assets_endpoint" {
value = local.regions["eu-central-2"].endpoint
}

Indexing the map by a code that doesn't exist fails at plan time, which is a cheap check that the region is still offered.

Use the default region's endpoint for an S3 client​

main.tf
data "cloider_bucket_regions" "all" {}

provider "aws" {
alias = "cloider"
# ... see the object storage guide for the full provider block
endpoints {
s3 = data.cloider_bucket_regions.all.regions[0].endpoint
}
}

The object storage guide has the complete aws provider configuration.

Attribute reference​

AttributeTypeDescription
regionsList of ObjectThe regions, the default one first
regions[*].codeStringThe code cloider_bucket's region takes, such as eu-central-2
regions[*].nameStringThe region's name, such as Europe
regions[*].endpointStringThe S3 endpoint of the region's buckets, such as https://s3.eu-central-2.cloider.com

Frequently asked questions

Which regions can a Cloider bucket be created in?

The cloider_bucket_regions data source lists them, with the default region first. The same list comes from cloider bucket regions and GET /api/buckets/regions.

What is the S3 endpoint of a Cloider bucket?

Each region has one, in the endpoint attribute of cloider_bucket_regions and of the cloider_bucket resource, such as https://s3.eu-central-2.cloider.com.