To create a Bucket via Terraform, this example will use the aminueza/minio Terraform Provider.
- 
Install Terraform
Before you start, make sure Terraform is installed and you have S3 credentials:
 - 
Setup your files
Create a new directory for your project and add the files
minio.tfandterraform.tfvars.You should end up with a directory tree that looks like this:
terraform/ ├── minio.tf └── terraform.tfvars - 
Setup the Terraform configuration
At the time of writing, the latest version of the Terraform provider for MinIO is
3.3.0. You can find a full list of all available versions here.Edit
minio.tfwith a text editor of your choice and add the following content:Replace
fsn1with your preferred location.terraform { required_providers { minio = { source = "aminueza/minio" version = "3.3.0" } } } variable "access_key" {} variable "secret_key" {} provider "minio" { minio_server = "fsn1.your-objectstorage.com" minio_user = "${var.access_key}" minio_password = "${var.secret_key}" minio_region = "fsn1" minio_ssl = true } resource "random_uuid" "id" {} resource "minio_s3_bucket" "bucket" { bucket = random_uuid.id.result acl = "private" object_locking = false }This will create a new Bucket with a random name (
random_uuid) and a visibility setting ofprivate.To enable object locking, change the value of
object_lockingfrom "false" to "true".You can find the complete documentation about the MinIO Terraform provider in the Terraform documentation.
 - 
Setup your variables
Edit
terraform.tfvarswith a text editor of your choice and add the following content:Replace
YOUR_ACCESS_KEYandYOUR_SECRET_KEYwith your actual keys.access_key = "YOUR_ACCESS_KEY" secret_key = "YOUR_SECRET_KEY" - 
Create the Bucket
Make sure you're in the same directory as the files you just created and run the following command to create a new Bucket:
terraform init terraform versionTo change the MinIO version after the first initialization, edit
minio.tfand runterraform initagain.terraform apply 
In Hetzner Console, you should now also see the new Bucket. To remove the Bucket you just created, you can run terraform destroy in the same directory in which you just ran terraform apply.
Next: