⚠️ Object Storage is currently in Beta test. For more information see this FAQ: Object Storage » Beta test
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.tf
andterraform.tfvars
.You should end up with a directory tree that looks like this:
terraform/ ├── minio.tf └── terraform.tfvars
-
Setup the Terraform configuration
Edit
minio.tf
with a text editor of your choice and add the following content:Replace
fsn1
with your preferred location.terraform { required_providers { minio = { source = "aminueza/minio" } } } 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_locking
from "false" to "true".You can find the complete documentation about the MinIO Terraform provider in the Terraform documentation.
-
Setup your variables
Edit
terraform.tfvars
with a text editor of your choice and add the following content:Replace
YOUR_ACCESS_KEY
andYOUR_SECRET_KEY
with 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 apply
In Cloud 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: