Creating a Bucket via MinIO Terraform Provider

To create a Bucket via Terraform, this example will use the aminueza/minio Terraform Provider.

  1. Install Terraform

    Before you start, make sure Terraform is installed and you have S3 credentials:

  2. Setup your files

    Create a new directory for your project and add the files minio.tf and terraform.tfvars.

    You should end up with a directory tree that looks like this:

    terraform/
    ├── minio.tf
    └── terraform.tfvars
  3. 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.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"
          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 of private.

    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.

  4. Setup your variables

    Edit terraform.tfvars with a text editor of your choice and add the following content:

    Replace YOUR_ACCESS_KEY and YOUR_SECRET_KEY with your actual keys.

    access_key = "YOUR_ACCESS_KEY"
    secret_key = "YOUR_SECRET_KEY"
  5. 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 version

    To change the MinIO version after the first initialization, edit minio.tf and run terraform init again.

    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.

  • 0 Uživatelům pomohlo
Byla tato odpověď nápomocná?

Související články

Generating S3 keys

To generate S3 credentials on your Cloud Console account, please open your project and do the...

Using S3 compatible API tools

Create your credentials For a step-by-step guide, see the getting started article...

Using curl

Create your credentials For a step-by-step guide, see the getting started article...

Creating a Bucket

To create a new Bucket on your Cloud Console, please open your project and do the following:...

Using libraries

In general, all the AWS SDKs should work well with our Object Storage. Below, you can find a few...

Powered by WHMCompleteSolution