Terraform provider reference / guides / object-storage
Object storage (S3)
An object storage project is a project of its own, with a token of its own. The provider manages what
the platform owns - buckets, S3 access keys, service accounts limited to one bucket, and the storage
reservation the project is billed for. What lives inside a bucket - objects, lifecycle rules, CORS,
the bucket policy, versioning - is S3 territory: manage it with the aws provider (or any S3 tool)
pointed at the storage endpoint.
1. A second provider configuration
A token belongs to ONE project of ONE product. A Virtual Data Center token does not reach the object
storage, and an object storage token does not reach servers: the platform answers not_found, and
the provider says that the token belongs to another product.
The FIBERAX_TOKEN environment variable is shared by every provider configuration, so the second
configuration needs its token written in its token field (from a variable, not as a literal in
a file you commit):
provider "fiberax" {
# the VDC project: token from FIBERAX_TOKEN
}
provider "fiberax" {
alias = "storage"
token = var.storage_token
}
variable "storage_token" {
type = string
sensitive = true
}
Every object storage resource and data source then carries provider = fiberax.storage.
2. Buckets, keys and service accounts
resource "fiberax_object_storage_bucket" "backups" {
provider = fiberax.storage
name = "acme-backups"
}
resource "fiberax_object_storage_access_key" "ci" {
provider = fiberax.storage
lifecycle {
create_before_destroy = true
}
}
resource "fiberax_object_storage_service_account" "app" {
provider = fiberax.storage
name = "app-writer"
bucket = fiberax_object_storage_bucket.backups.name
access = "readwrite"
}
- Bucket names are unique across the whole storage, not only within your project. A name taken by
another client is refused (
bucket_name_taken); a bucket you already have is offered for import. - On a storage with nothing reserved yet, creating needs a payment method. While
reserved_tbis 0, creating a bucket, a key or a service account is refused withclient_has_debt(unpaid invoices) orcard_verification_required(no verified card and no credit), as ordering storage is. Deleting is never refused for money. - Only an empty bucket is deleted. The platform does not delete objects for you: empty the bucket over S3 first - objects, old versions and delete markers. Objects under Object Lock retention cannot be deleted before it ends.
- Object Lock is chosen when a bucket is created. Changing
object_locklater is refused on the plan instead of replacing the bucket: switch Object Lock on over S3, then writeobject_lock = true. - The last S3 access key of a project is never deleted. Rotate keys with
create_before_destroy, as above:terraform apply -replacethen creates the new key first and deletes the old one after. - A service account cannot be changed: a new name, bucket or access level replaces it with a new key.
3. Secrets live in state
The platform returns a secret only once - in the answer that created the key or the service account.
The provider keeps it in the sensitive attribute secret_access_key, which is hidden in plan output,
but the state file holds it in the clear: keep the state where secrets may be kept.
After terraform import there is no secret. For an S3 access key the API action
POST /v1/object-storage/access-keys/{access_key_id}/actions/reveal-secret shows it again (the
provider has no actions); a service account has no such action, and the way to a secret is replacing
it.
If the answer to a create is lost (a dropped connection, a platform error), the provider checks what appeared anyway:
- An S3 access key that appeared meanwhile is named in the error, and nothing is put into state: it
may be a key made at the same moment in the client area, by another run or by a script on the same
token, and a key in state would be deleted by the next
terraform destroy. If the key is yours, take it withterraform import(the secret is shown by thereveal-secretAPI action); if not, do nothing - the next apply creates a new key. - A service account found by its name - a name only you chose - is kept in state as tainted, without a
secret, and the next
terraform applyreplaces it with one that has a secret.
4. The reservation is money
resource "fiberax_object_storage_reservation" "this" {
provider = fiberax.storage
reserved_tb = 2
}
The project is billed every hour for every reserved terabyte (1 TB = 2^40 bytes), whatever is stored.
Raising reserved_tb orders storage at once, and the reservation never goes down: not here, not in
the client area. The only way down is deleting the whole storage with its data in the client area. The
plan says how much the reservation grows - read it before you approve.
- A value equal to the current reservation orders nothing - also on an account with unpaid invoices. A
reservation that is not a whole number of terabytes (set by support) is read by its whole part: 1.5 TB
reads as
reserved_tb = 1, and that value keeps it as it is. - A value below the reservation is refused. If the reservation was raised outside Terraform (in the client area), the plan warns and names the number to write, and applying this resource is refused without asking the platform.
- Ordering needs a payment method (a verified card or credit) and no unpaid invoices.
- Removing the resource or
terraform destroychanges nothing on the platform: the reservation stays and keeps being billed. Import with the wordproject.
The bounds and step of an order are in reservation_limits of the fiberax_object_storage data source.
5. Objects with the aws provider
Keep the objects in a second configuration, not next to the key. The aws provider is configured
before anything is applied, so a key created in the same configuration is still unknown at that moment:
the first plan fails with "No valid credential sources found", and while such a block is present
terraform import of a fiberax resource fails with "depends on values that cannot be determined until
apply".
The storage configuration (sections 1-4) hands the key over as outputs:
output "s3_access_key_id" {
value = fiberax_object_storage_access_key.ci.access_key_id
}
output "s3_secret_access_key" {
value = fiberax_object_storage_access_key.ci.secret_access_key
sensitive = true
}
The objects configuration takes the endpoint and region from the data source - it is read during the plan, so the values are known - and the key from the environment:
data "fiberax_object_storage" "this" {
provider = fiberax.storage
}
provider "aws" {
region = data.fiberax_object_storage.this.region
s3_use_path_style = true
skip_credentials_validation = true
skip_region_validation = true
skip_requesting_account_id = true
endpoints {
s3 = data.fiberax_object_storage.this.endpoint
}
}
resource "aws_s3_object" "readme" {
bucket = "acme-backups"
key = "README.txt"
content = "kept by Terraform"
}
export AWS_ACCESS_KEY_ID="$(terraform -chdir=storage output -raw s3_access_key_id)" export AWS_SECRET_ACCESS_KEY="$(terraform -chdir=storage output -raw s3_secret_access_key)" export AWS_REQUEST_CHECKSUM_CALCULATION=when_required export AWS_RESPONSE_CHECKSUM_VALIDATION=when_required terraform -chdir=objects apply
- Path-style addressing (
s3_use_path_style = true) is required: bucket names are not served as subdomains. - The two
..._CHECKSUM_...=when_requiredvariables are needed with theawsprovider 6.x: without them it uploads objects in checksummed chunks, the storage keepscontent_encoding = "aws-chunked", and every later plan offers to change it back. - One configuration for both still works if the key is applied first -
terraform apply -target=fiberax_object_storage_access_key.ci, then the rest - but every run that has to create or import the key meets the same two errors again. Two configurations do not.
6. Pace
The platform takes one change of an object storage at a time, and the provider sends them one by one by itself. A plan with dozens of service accounts also meets the write limit of a token (20 writes a minute): the provider waits and repeats on its own, so such a run takes minutes rather than seconds.
Generated from the provider schema for version 0.11.0. How to install the provider: Terraform provider.