### Get help for configuration keys with mc admin config set Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Shows help for setting the 'api' and 'notify_webhook' configuration keys. ```bash # Get help for API configuration mc admin config set myminio api # Get help for webhook notifications mc admin config set myminio notify_webhook ``` -------------------------------- ### View current MinIO configuration with mc admin config get Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Displays all or specific configuration keys. The first command shows all settings; the subsequent commands show the 'api' and 'notify_webhook:production' keys. ```bash # View all configuration mc admin config get myminio # View specific configuration key mc admin config get myminio api mc admin config get myminio notify_webhook:production ``` -------------------------------- ### Build and install provider from source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Runs the Task command to build and install the provider from source. The plugin is placed in the correct local plugins directory for your operating system automatically. ```sh task install ``` -------------------------------- ### Initialize Terraform Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Initializes the Terraform working directory for the MinIO configuration example. ```bash terraform init ``` -------------------------------- ### Project directory structure Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Shows the layout of the repository, including main.go, the minio/ package with provider code, tests, templates, docs, examples, and docker-compose.yml for the test environment. ```text ├── main.go # Provider entry point ├── minio/ # Core provider code │ ├── provider.go # Provider definition and resource registration │ ├── resource_minio_*.go # Resource implementations │ ├── data_source_*.go # Data source implementations │ ├── *_test.go # Acceptance tests │ ├── check_config.go # Configuration helpers │ ├── error.go # Error handling utilities │ ├── utils.go # Common utilities and helpers │ └── new_client.go # MinIO client creation ├── templates/ # Documentation templates (.md.tmpl) ├── docs/ # Generated documentation (do not edit directly) ├── examples/ # Example Terraform configurations └── docker-compose.yml # Test environment with multiple MinIO instances ``` -------------------------------- ### Verify configuration after restart Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Verifies a specific configuration key after applying changes and restarting if needed. ```bash mc admin config get myminio ``` -------------------------------- ### Apply configuration with terraform apply Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Applies the Terraform configuration to the MinIO server. ```bash terraform apply ``` -------------------------------- ### List and get help for MinIO configuration keys with mc Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/config.md Shows two mc admin config set commands: one lists all configuration keys for a MinIO server, and the other gets help for a specific subsystem (e.g., 'api'). Use these to discover available configuration keys. ```bash # List all configuration keys mc admin config set myminio/ # Get help for a specific subsystem mc admin config set myminio/ api ``` -------------------------------- ### Integer Conversion Safety - Correct Example Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/ai-coding-standards.md Demonstrates safe conversion with overflow checks using math.MaxInt and SafeUint64ToInt64, returning an error on overflow. ```go import "math" validityInt := int(*validity) if *validity > uint(math.MaxInt) { validityInt = math.MaxInt } val64, ok := SafeUint64ToInt64(myUint64) if !ok { return NewResourceError("converting value", d.Id(), fmt.Errorf("uint64 overflows int64: %d", myUint64)) } ``` -------------------------------- ### Review planned changes with terraform plan Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Shows the changes that Terraform will apply to the MinIO configuration. ```bash terraform plan ``` -------------------------------- ### Initialize and apply Terraform configuration Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/ldap/README.md Runs Terraform init, plan, and apply to deploy the MinIO LDAP resources. Requires the environment variables set in the previous step. ```bash terraform init terraform plan terraform apply ``` -------------------------------- ### Example Usage: minio_server_info data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/server_info.md Reads MinIO server information including version, deployment ID, region, and detailed metrics about each server and drive in the cluster. The example defines outputs for version, region, deployment ID, storage summary, servers list, and an alltrue check that all servers are online. ```terraform data "minio_server_info" "current" {} output "minio_version" { value = data.minio_server_info.current.version } output "minio_region" { value = data.minio_server_info.current.region } output "deployment_id" { value = data.minio_server_info.current.deployment_id } output "storage_summary" { value = { total_servers = length(data.minio_server_info.current.servers) } } output "servers" { value = data.minio_server_info.current.servers } output "all_servers_online" { value = alltrue([ for server in data.minio_server_info.current.servers : server.state == "online" ]) } ``` -------------------------------- ### Integer Conversion Safety - Wrong Example Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/ai-coding-standards.md Shows unsafe integer conversions that can overflow when converting between uint/int/uint64/int64. ```go days := int(*validity) val := int64(myUint64) ``` -------------------------------- ### Example Usage: minio_kms_status data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/kms_status.md Retrieves status and connectivity information about the KMS configured on the MinIO server. The example outputs the key store reachability and the default key ID. ```terraform data "minio_kms_status" "current" {} output "kms_reachable" { value = data.minio_kms_status.current.state[0].key_store_reachable } output "kms_default_key" { value = data.minio_kms_status.current.default_key_id } ``` -------------------------------- ### minio_batch_jobs data source examples Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/batch_jobs.md Lists active MinIO batch jobs. The first example retrieves all jobs; the second filters by job_type 'expire'. Optional filters include job_type (replicate, expire, keyrotate) and status (started, completed, failed). ```terraform data "minio_batch_jobs" "all" {} data "minio_batch_jobs" "expire" { job_type = "expire" } ``` -------------------------------- ### Example Usage: minio_ilm_tiers data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/ilm_tiers.md Lists all configured ILM remote storage tiers. The example declares the data source and outputs the names of all tiers. ```terraform data "minio_ilm_tiers" "available" {} output "tier_names" { value = data.minio_ilm_tiers.available.tiers[*].name } ``` -------------------------------- ### Restart MinIO service with mc admin service restart Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Restarts the MinIO server if any configuration change requires it, as indicated by the restart_required output. ```bash mc admin service restart myminio ``` -------------------------------- ### Kafka notification configuration Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Defines a MinIO config resource for Kafka notification with brokers and topic. ```hcl resource "minio_config" "kafka_notification" { key = "notify_kafka:events" value = "brokers=kafka1:9092,kafka2:9092 topic=minio-events" } ``` -------------------------------- ### Redis notification with authentication Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Defines a MinIO config resource for Redis notification with address, key, password, and format. ```hcl resource "minio_config" "redis_notification" { key = "notify_redis:cache" value = "address=127.0.0.1:6379 key=bucketevents password=secret format=namespace" } ``` -------------------------------- ### Install Claude Code skill Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Copies the terraform-minio skill to the user-level skills directory for use in every project, or scoped to this repository. ```sh # Available in every project: cp -R skills/terraform-minio ~/.claude/skills/ # Or scoped to this repo: mkdir -p .claude/skills && cp -R skills/terraform-minio .claude/skills/ ``` -------------------------------- ### API configuration with root access control Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/config/README.md Defines a MinIO config resource for API throttling with requests_max and root_access settings. ```hcl resource "minio_config" "api_secure" { key = "api" value = "requests_max=2000 root_access=off" } ``` -------------------------------- ### Set Terraform variables for MinIO Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/ldap/README.md Exports environment variables for the MinIO server address and admin credentials. These are used by the Terraform provider to connect to MinIO. ```bash export TF_VAR_minio_server="minio.example.com:9000" export TF_VAR_minio_access_key="minioadmin" export TF_VAR_minio_secret_key="minioadmin" ``` -------------------------------- ### Triggers Example: minio_s3_incomplete_upload_cleanup Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/s3_incomplete_upload_cleanup.md Shows how to set the triggers map to re-run cleanup by changing the value. This is a standalone example from the Notes section. ```hcl triggers = { run = "2024-06-01" } ``` -------------------------------- ### minio_data_usage Data Source Example Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/data_usage.md Use this data source to retrieve cluster-wide data usage statistics. The example declares the data source with no required arguments; all attributes are read-only and include buckets_count, buckets_usage, last_update, total_objects, and total_size. ```terraform data "minio_data_usage" "current" {} ``` -------------------------------- ### Import IAM group policy attachment Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/iam_group_policy_attachment.md Imports an existing IAM group policy attachment using the format group-name/policy-name. The example uses the resource name 'example'. ```shell # IAM group policy attachments can be imported using the format: group-name/policy-name terraform import minio_iam_group_policy_attachment.example group-name/policy-name ``` -------------------------------- ### Run specific tests (bash) Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Commands to run a single acceptance test via Docker Compose, run tests directly with Go (requires TF_ACC=1), and run all package tests. ```bash # Run single test TEST_PATTERN=TestAccMinioS3Bucket docker compose run --rm test # Run tests with go directly (requires TF_ACC=1) TF_ACC=1 go test -v ./minio -run TestAccMinioS3Bucket_basic # Run package tests go test ./minio/... ``` -------------------------------- ### Import etcd configuration resource Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/server_config_etcd.md Imports an existing MinIO etcd configuration into Terraform state using the resource address and an example ID. The import command is `terraform import minio_server_config_etcd.example example-id`. ```shell terraform import minio_server_config_etcd.example example-id ``` -------------------------------- ### Configure MinIO LDAP with mc admin config Source: https://github.com/aminueza/terraform-provider-minio/blob/main/examples/ldap/README.md Sets up LDAP authentication on MinIO using the mc admin config command. Requires an LDAP server with users and groups, and MinIO admin credentials. The command specifies server address, bind credentials, search bases and filters, and TLS verification. ```bash mc admin config set myminio identity_ldap \ server_addr="ldap.example.com:636" \ lookup_bind_dn="cn=admin,dc=example,dc=com" \ lookup_bind_password="admin-password" \ user_dn_search_base_dn="ou=users,dc=example,dc=com" \ user_dn_search_filter="(uid=%s)" \ group_search_base_dn="ou=groups,dc=example,dc=com" \ group_search_filter="(&(objectclass=groupOfNames)(member=%d))" \ tls_skip_verify="off" ``` -------------------------------- ### Run ILM all-versions-expiration test against AIStor Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/testing-environment.md Starts a single-node MinIO AIStor container on port 9100 with a license file, then runs the acceptance test that requires MINIO_AISTOR. The test skips unless MINIO_AISTOR is set; CI never sets it. The server denies S3 requests without a license. ```bash docker run -d --name aistor -p 9100:9000 \ -v "$PWD/minio.license:/minio.license:ro" \ -e MINIO_ROOT_USER=minio -e MINIO_ROOT_PASSWORD=minio123 \ quay.io/minio/aistor/minio:RELEASE.2026-09-19T17-05-25Z minio server /data --license /minio.license # Export the variables listed above, then: MINIO_ENDPOINT=localhost:9100 MINIO_AISTOR=1 TF_ACC=1 \ go test -v -count=1 ./minio -run '^TestAccILMPolicy_allVersionsExpiration$' ``` -------------------------------- ### Retrieve MinIO license information with minio_license_info Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/license_info.md Use this data source to fetch MinIO license details such as plan, organization, and expiration. The example declares the data source and outputs the license plan. ```terraform data "minio_license_info" "current" {} output "license_plan" { value = data.minio_license_info.current.plan } ``` -------------------------------- ### Safe integer conversion with SafeUint64ToInt64 Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Use this pattern for safe uint64 to int64 conversions. It returns a boolean indicating success and handles overflow errors. ```go val64, ok := SafeUint64ToInt64(myUint64) if !ok { return NewResourceError("converting value", d.Id(), fmt.Errorf("uint64 overflows int64: %d", myUint64)) } ``` -------------------------------- ### Complete Prometheus Configuration Example Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/prometheus_scrape_config.md Generates scrape configs for all metric types and combines them into a single Prometheus configuration using a local value. ```terraform # Generate scrape configs for all metric types data "minio_prometheus_scrape_config" "cluster" { metric_type = "cluster" alias = "minio-cluster" } data "minio_prometheus_scrape_config" "node" { metric_type = "node" alias = "minio-nodes" } data "minio_prometheus_scrape_config" "bucket" { metric_type = "bucket" alias = "minio-buckets" } data "minio_prometheus_scrape_config" "resource" { metric_type = "resource" alias = "minio-resources" } # Combine all scrape configs locals { prometheus_config = <<-EOT ${data.minio_prometheus_scrape_config.cluster.scrape_config} ${data.minio_prometheus_scrape_config.node.scrape_config} ${data.minio_prometheus_scrape_config.bucket.scrape_config} ${data.minio_prometheus_scrape_config.resource.scrape_config} EOT } output "complete_prometheus_config" { value = local.prometheus_config } ``` -------------------------------- ### Resource Implementation Pattern with CRUD Functions Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/ai-coding-standards.md Defines a Terraform resource with Create, Read, Update, Delete, and Importer functions. The Create function extracts config, logs debug messages, applies the operation, sets the resource ID after success, and calls Read. Follow the CRUD structure: extract config, log DEBUG start, validate, apply with NewResourceError, set ID (Create) or clear ID (Delete), log DEBUG end, and return Read (Create/Update) or nil (Delete). Always call Read after Create/Update (except when restart_required=true), clear ID when Read finds the resource missing, set ID after API success, and make Delete idempotent. ```go func resourceMinioX() *schema.Resource { return &schema.Resource{ CreateContext: minioCreateX, ReadContext: minioReadX, UpdateContext: minioUpdateX, DeleteContext: minioDeleteX, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, Schema: map[string]*schema.Schema{ // Define schema here }, } } func minioCreateX(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { config := XConfig(d, meta) tflog.Debug(ctx, "Creating X", map[string]interface{}{"name": config.MinioXName}) if err := applyX(ctx, config); err != nil { return NewResourceError("creating X", config.MinioXName, err) } d.SetId(config.MinioXName) tflog.Debug(ctx, "Created X", map[string]interface{}{"name": config.MinioXName}) return minioReadX(ctx, d, meta) } ``` -------------------------------- ### List all S3 buckets with minio_s3_buckets Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/s3_buckets.md Use this data source to list all S3 buckets. The example outputs the bucket names using the `buckets[*].name` attribute. ```terraform data "minio_s3_buckets" "all" {} output "bucket_names" { value = data.minio_s3_buckets.all.buckets[*].name } ``` -------------------------------- ### Example Usage: minio_s3_incomplete_upload_cleanup Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/s3_incomplete_upload_cleanup.md Creates a bucket and a cleanup resource that aborts incomplete multipart uploads on first apply. The prefix is optional to filter uploads. A second resource shows how to re-run cleanup by changing the triggers map value. ```terraform resource "minio_s3_bucket" "example" { bucket = "my-bucket" } # Clean up once on first apply resource "minio_s3_incomplete_upload_cleanup" "cleanup" { bucket = minio_s3_bucket.example.bucket prefix = "uploads/" # Optional: only clean up uploads with this prefix } # Re-run cleanup by changing the trigger value (e.g. via -var or a local) resource "minio_s3_incomplete_upload_cleanup" "scheduled" { bucket = minio_s3_bucket.example.bucket triggers = { run = "2024-01-01" # Change this value to trigger a new cleanup run } } ``` -------------------------------- ### minio_service_action restart example Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/service_action.md Performs a one-shot MinIO service control operation. The 'stop' action shuts down the cluster and will not restart on its own; subsequent terraform plan/apply runs will fail until MinIO is started out-of-band. ```terraform resource "minio_service_action" "restart" { action = "restart" triggers = { when = "manual-trigger" } } ``` -------------------------------- ### Initialize and apply Terraform Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Run terraform init and terraform apply to create the resources defined in the configuration. ```sh terraform init terraform apply ``` -------------------------------- ### Create MinIO access keys with various configurations Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/accesskey.md Example usage for the minio_accesskey resource, showing creation of a user and multiple access keys with default settings, custom credentials, write-only secret, disabled status, description, and attached policy. Includes constraints: access_key must be 8-20 characters, secret_key at least 8 characters, and secret_key_version for change detection. ```terraform ephemeral "vault_kv_secret_v2" "access_key_password" { mount = "secret" name = "minio/accesskey/custom-key-write-only" } # Create a user first resource "minio_iam_user" "example_user" { name = "example-user" } # Create an access key with default settings (auto-generated keys, enabled) resource "minio_accesskey" "example" { user = minio_iam_user.example_user.name } # Create an access key with custom credentials resource "minio_accesskey" "custom_key" { user = minio_iam_user.example_user.name access_key = "MINIO_ACCESS_KEY" # Must be 8-20 characters secret_key = "mySuperSecretKey" # Must be at least 8 characters secret_key_version = "v1" # Version identifier for change detection status = "enabled" } # Create an access key with write-only secret resource "minio_accesskey" "custom_key_write_only" { user = minio_iam_user.example_user.name access_key = "MINIO_ACCESS_KEY2" secret_key_wo = tostring(ephemeral.vault_kv_secret_v2.access_key_password.data.secret_key) secret_key_wo_version = 1 status = "enabled" } # Create a disabled access key resource "minio_accesskey" "disabled_key" { user = minio_iam_user.example_user.name status = "disabled" } # Create an access key with a description resource "minio_accesskey" "with_description" { user = minio_iam_user.example_user.name description = "CI/CD deployment key" } # Create an access key and attach a policy directly (policy JSON) resource "minio_accesskey" "with_policy" { user = minio_iam_user.example_user.name access_key = "EXAMPLEKEY1" secret_key = "mySuperSecretKey" secret_key_version = "v1" status = "enabled" policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = ["s3:GetObject"] Resource = ["arn:aws:s3:::my-bucket/*"] } ] }) } ``` -------------------------------- ### Import minio_site_replication by name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/site_replication.md Imports an existing site replication configuration using its name. ```shell terraform import minio_site_replication.primary my-cluster-replication ``` -------------------------------- ### Use minio_iam_user_policies data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/iam_user_policies.md Retrieves all effective IAM policies for a user, including direct and group-inherited policies. The example declares the data source and outputs the deduplicated all_policies list and the group_policies list. ```terraform data "minio_iam_user_policies" "audit" { name = "app-user" } output "all_effective_policies" { value = data.minio_iam_user_policies.audit.all_policies } output "inherited_from_groups" { value = data.minio_iam_user_policies.audit.group_policies } ``` -------------------------------- ### Template structure for resource documentation Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/documentation-workflow.md Shows the required layout for `*.md.tmpl` templates, including frontmatter, description, example usage via `{{ tffile ... }}`, schema markdown, and import section. Edit templates in `templates/`, not `docs/`, and run `task generate-docs` after changes. ```tmpl --- page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" subcategory: "" description: |- {{ .Description | plainmarkdown | trimspace | prefixlines " " }} --- # {{.Name}} ({{.Type}}) {{ .Description | trimspace }} ## Example Usage ```terraform {{ tffile "examples/resources//resource.tf" }} ``` {{ .SchemaMarkdown | trimspace }} ## Import ... ``` -------------------------------- ### Example Usage: minio_notify_redis data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/notify_redis.md Fetches the Redis notification target configuration by name and outputs its key. The data source requires the target name and exposes read-only attributes such as address, format, and queue settings. ```terraform data "minio_notify_redis" "example" { name = "my-redis" } output "redis_key" { value = data.minio_notify_redis.example.key } ``` -------------------------------- ### Register resource in provider.go Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/ai-coding-standards.md Add new resources to the ResourcesMap in minio/provider.go. Replace {resource_name} and {ResourceName} with the actual resource name. ```go ResourcesMap: map[string]*schema.Resource{ "minio_{resource_name}": resourceMinio{ResourceName}(), }, ``` -------------------------------- ### Generate Prometheus scrape configurations for different metric types Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/prometheus_scrape_config.md Creates data sources for cluster, node, bucket, and resource metrics. The bucket example uses metrics_version v2, and the resource example includes a bearer token. ```terraform # Generate scrape configuration for cluster metrics data "minio_prometheus_scrape_config" "cluster" { metric_type = "cluster" alias = "minio-cluster" } # Generate scrape configuration for node metrics data "minio_prometheus_scrape_config" "node" { metric_type = "node" alias = "minio-nodes" } # Generate scrape configuration for bucket metrics with v2 metrics data "minio_prometheus_scrape_config" "bucket" { metric_type = "bucket" alias = "minio-buckets" metrics_version = "v2" } # Generate scrape configuration for resource metrics with bearer token data "minio_prometheus_scrape_config" "resource" { metric_type = "resource" alias = "minio-resources" bearer_token = "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Configure Terraform MinIO provider (aminueza/minio) Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/SKILL.md Declares the required provider source and version, then configures the provider with endpoint, region, credentials, and TLS settings. The server must be a bare host:port without a scheme; TLS is controlled by minio_ssl. Credentials can be supplied via variables or MINIO_* environment variables. ```hcl terraform { required_providers { minio = { source = "aminueza/minio" version = ">= 3.0.0" } } } provider "minio" { minio_server = "localhost:9000" # host:port, no scheme; env: MINIO_ENDPOINT minio_region = "us-east-1" # signing region (matters for S3-compat) minio_user = var.minio_user # access key; env: MINIO_USER minio_password = var.minio_password # secret key; env: MINIO_PASSWORD (sensitive) minio_ssl = false # env: MINIO_ENABLE_HTTPS } ``` -------------------------------- ### Build MinIO servers from a specific release Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/testing-environment.md Builds the MinIO servers from a specified release tag for all six services at once. Set MINIO_VERSION to the desired release tag. ```bash # Build the MinIO servers from another release, for every MinIO service at once MINIO_VERSION=RELEASE.2025-10-15T17-29-55Z docker compose run --rm test ``` -------------------------------- ### List service accounts for an IAM user Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/iam_service_accounts.md Use this data source to retrieve all service accounts (access keys) for a specific IAM user. The example declares the data source with the required `user` attribute and then outputs the list of access keys using the `service_accounts[*].access_key` attribute. ```terraform data "minio_iam_service_accounts" "app" { user = "app-user" } output "service_account_keys" { value = data.minio_iam_service_accounts.app.service_accounts[*].access_key } ``` -------------------------------- ### Development tasks Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Lists the Task commands for compiling, linting, testing, and regenerating documentation. ```sh task build # compile the provider task lint # run golangci-lint task test # run acceptance tests (Docker required) task generate-docs # regenerate docs/ from templates/ and schema ``` -------------------------------- ### Mandatory payload configuration pattern Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Use this pattern to create the configuration payload for a resource. It is required for all resources. ```go config := ResourceNameConfig(d, meta) ``` -------------------------------- ### Create read-only IAM policy and attach to user Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/SKILL.md Builds an IAM policy document with the minio_iam_policy_document data source, creates a minio_iam_policy, a minio_iam_user, and attaches the policy to the user. Requires two resource ARNs: the bucket itself and 'bucket/*' for object actions. For machine credentials, prefer a minio_iam_service_account over embedding the user's secret. ```hcl data "minio_iam_policy_document" "backups_ro" { statement { sid = "ReadBackups" actions = ["s3:GetObject", "s3:ListBucket"] resources = ["arn:aws:s3:::backups", "arn:aws:s3:::backups/*"] } } resource "minio_iam_policy" "backups_ro" { name = "backups-read-only" policy = data.minio_iam_policy_document.backups_ro.json } resource "minio_iam_user" "app" { name = "backups-reader" } resource "minio_iam_user_policy_attachment" "app_backups_ro" { user_name = minio_iam_user.app.id # note: user_name / policy_name policy_name = minio_iam_policy.backups_ro.id } ``` -------------------------------- ### CLI import commands for one-offs Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/recipes.md Use `terraform import` for one-off imports. Import IDs for every resource are tabulated in `resources.md` → *Import syntax*. After importing, run `terraform plan` and reconcile any diff; some resources (e.g., objects and lifecycle) only read partial state on import. ```bash terraform import minio_iam_user.alice alice terraform import minio_iam_user_policy_attachment.x alice/reports-read-only # user/policy terraform import minio_s3_object.f my-bucket/path/file.txt # bucket/object ``` -------------------------------- ### Run acceptance tests with Docker Compose Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Runs acceptance tests against real MinIO instances via Docker Compose. Supports running a subset by name with TEST_PATTERN and rebuilding the MinIO servers from another release with MINIO_VERSION. ```sh docker compose run --rm test # Run a subset by name: TEST_PATTERN=TestAccMinioS3Bucket_basic docker compose run --rm test # Build the MinIO servers from another release. This rebuilds the image for # every MinIO service at once: MINIO_VERSION=RELEASE.2025-10-15T17-29-55Z task test ``` -------------------------------- ### Debug commands for site replication Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/site_replication.md Commands to check status, remove, and test connectivity for site replication using the MinIO client (mc). ```bash # Check current site replication status mc admin replicate info # Remove existing site replication (if needed) mc admin replicate remove --all # Test connectivity between sites mc admin replicate add --access-key --secret-key --dry-run ``` -------------------------------- ### List all IAM groups Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/iam_groups.md Use this data source to retrieve all IAM groups. The example outputs the names of all groups. ```terraform data "minio_iam_groups" "all" {} output "group_names" { value = data.minio_iam_groups.all.groups[*].name } ``` -------------------------------- ### Create minio_site_replication with three sites Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/site_replication.md Defines a primary site replication resource with three sites. Requires at least 2 sites. Credentials are stored in state but not returned by the API. ```hcl resource "minio_site_replication" "primary" { name = "my-cluster-replication" site { name = "site1" endpoint = "https://minio1.example.com" access_key = "minioadmin" secret_key = "minio123" } site { name = "site2" endpoint = "https://minio2.example.com" access_key = "minioadmin" secret_key = "minio456" } site { name = "site3" endpoint = "https://minio3.example.com" access_key = "minioadmin" secret_key = "minio789" } } ``` -------------------------------- ### Check d.Set errors Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Always check errors from d.Set calls. Use NewResourceError to wrap the error with context. ```go if err := d.Set("field", value); err != nil { return NewResourceError("setting field", d.Id(), err) } ``` -------------------------------- ### Configure MinIO provider with s3_compat_mode for S3-compatible backends Source: https://github.com/aminueza/terraform-provider-minio/blob/main/README.md Use this provider block when targeting an S3-compatible backend that does not implement every S3 feature. Setting s3_compat_mode = true keeps resources in state on reads of unsupported features (with a warning), but create/update of such features still fails with an error naming the feature and the flag. ```hcl provider "minio" { minio_server = "fsn1.your-objectstorage.com" minio_user = var.access_key minio_password = var.secret_key minio_ssl = true s3_compat_mode = true } ``` -------------------------------- ### Schema field patterns Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Common schema field definitions for Terraform resources. Shows required, optional with default, and computed fields. ```go "name": { Type: schema.TypeString, Required: true, ForceNew: true, Description: "Name" }, "enabled": { Type: schema.TypeBool, Optional: true, Default: true, Description: "Enable/disable" }, "id": { Type: schema.TypeString, Computed: true, Description: "Server-generated ID" }, ``` -------------------------------- ### Provider bootstrap (versions.tf, variables.tf, provider.tf) Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/recipes.md Sets up the MinIO Terraform provider with required version, sensitive variables, and provider configuration. Feed credentials via environment variables (TF_VAR_minio_server, TF_VAR_minio_user, TF_VAR_minio_password) or let the provider read MINIO_ENDPOINT / MINIO_USER / MINIO_PASSWORD. ```hcl # versions.tf terraform { required_version = ">= 1.5" required_providers { minio = { source = "aminueza/minio" version = ">= 3.0.0" } } } # variables.tf variable "minio_server" { type = string } variable "minio_user" { type = string sensitive = true } variable "minio_password" { type = string sensitive = true } # provider.tf provider "minio" { minio_server = var.minio_server # host:port, no scheme minio_region = "us-east-1" minio_user = var.minio_user minio_password = var.minio_password minio_ssl = true } ``` ```bash export TF_VAR_minio_server="minio.example.com:9000" export TF_VAR_minio_user="$MINIO_ROOT_USER" export TF_VAR_minio_password="$MINIO_ROOT_PASSWORD" # (or skip the vars entirely and let the provider read MINIO_ENDPOINT / MINIO_USER / MINIO_PASSWORD) ``` -------------------------------- ### Forbidden error return patterns Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md These patterns are explicitly forbidden. Never use them in resource/data source CRUD; always use NewResourceError instead. ```go return diag.FromErr(err) return diag.Errorf("error: %v", err) ``` -------------------------------- ### Import minio_iam_user by user name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the user name as the import ID for minio_iam_user resources. ```hcl ... minio_iam_user.u alice ``` -------------------------------- ### Mandatory error handling pattern with NewResourceError Source: https://github.com/aminueza/terraform-provider-minio/blob/main/AGENTS.md Use this pattern in all resource/data source CRUD operations. It wraps errors with context and is required by the repository guidelines. ```go if err != nil { return NewResourceError("creating bucket", bucketName, err) } ``` -------------------------------- ### Run package tests with go test Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/testing-environment.md Runs all tests in the minio package. Use this to execute the package's test suite directly without Docker Compose. ```bash # Run package tests go test ./minio/... ``` -------------------------------- ### Terraform example: minio_iam_group_user_attachment Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/iam_group_user_attachment.md Creates a MinIO IAM group, user, and attaches the user to the group. Outputs expose the attachment's id, group_name, and user_name. ```terraform resource "minio_iam_group" "developer" { name = "developer" } resource "minio_iam_user" "user_one" { name = "test-user" } resource "minio_iam_group_user_attachment" "developer" { group_name = minio_iam_group.group.name user_name = minio_iam_user.user_one.name } output "minio_name" { value = minio_iam_group_user_attachment.developer.id } output "minio_users" { value = minio_iam_group_user_attachment.developer.group_name } output "minio_group" { value = minio_iam_group_user_attachment.developer.user_name } ``` -------------------------------- ### Import minio_iam_user_group_membership by user name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the user name as the import ID for minio_iam_user_group_membership resources. ```hcl ... .m alice ``` -------------------------------- ### Resource Without Provider Block Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/index.md Example of a MinIO S3 bucket resource that can be used when credentials are provided via environment variables, allowing the provider block to be omitted. ```hcl resource "minio_s3_bucket" "state_terraform_s3" { # ..... } ``` -------------------------------- ### Example Usage: minio_notify_nats data source Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/notify_nats.md Retrieves the NATS notification target configuration by name. The output block accesses the subject attribute from the data source. ```terraform data "minio_notify_nats" "example" { name = "my-nats" } output "nats_subject" { value = data.minio_notify_nats.example.subject } ``` -------------------------------- ### Read tags from an S3 bucket with minio_s3_bucket_tags Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/s3_bucket_tags.md Use this data source to read tags from an existing S3 bucket. The example retrieves the 'Environment' tag value and outputs it. ```terraform data "minio_s3_bucket_tags" "my_bucket" { bucket = "my-bucket" } output "environment" { value = data.minio_s3_bucket_tags.my_bucket.tags["Environment"] } ``` -------------------------------- ### Read S3 bucket quota with minio_s3_bucket_quota Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/s3_bucket_quota.md Use this data source to read the quota configuration of an existing S3 bucket. The example fetches the quota for the bucket named 'my-bucket'. ```terraform data "minio_s3_bucket_quota" "example" { bucket = "my-bucket" } ``` -------------------------------- ### Import existing minio_server_config_heal resource Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/server_config_heal.md Imports an existing MinIO server heal configuration resource by its ID. Use the resource address and the example ID to bring the resource under Terraform management. ```shell terraform import minio_server_config_heal.example example-id ``` -------------------------------- ### Import minio_s3_bucket_versioning by bucket name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the bucket name as the import ID for minio_s3_bucket_versioning resources. ```hcl ... .v my-bucket ``` -------------------------------- ### Import an existing MinIO IAM group Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/iam_group.md Imports an IAM group using its group name. The example shows the `terraform import` command for `minio_iam_group.example` with the group name as the import ID. ```shell # IAM groups can be imported using the group name terraform import minio_iam_group.example group-name ``` -------------------------------- ### Debug logging with tflog Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/ai-coding-standards.md Use tflog (github.com/hashicorp/terraform-plugin-log/tflog) instead of log.Printf. It respects TF_LOG_LEVEL / TF_LOG_PROVIDER, is per-resource filterable, and supports structured fields. Pass strings directly to NewResourceErrorStr; no fmt.Sprintf("%s", x). ```go tflog.Debug(ctx, "Creating bucket", map[string]interface{}{"bucket": bucket}) tflog.Warn(ctx, fmt.Sprintf("missing %s, recreating", name)) tflog.Error(ctx, NewResourceErrorStr("op", id, err)) // pass strings directly; no fmt.Sprintf("%s", x) ``` -------------------------------- ### Import with import block (Terraform ≥ 1.5) Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/recipes.md Use the reviewable `import {}` block so the import appears in a plan before touching state. Optionally run `terraform plan -generate-config-out=generated.tf` to scaffold the resource block. ```hcl import { to = minio_s3_bucket.legacy id = "legacy-bucket" } resource "minio_s3_bucket" "legacy" { bucket = "legacy-bucket" } ``` -------------------------------- ### Example Usage: minio_iam_policy_document with statements and conditions Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/iam_policy_document.md Creates an IAM policy document with multiple statements, including conditions and resources. The generated JSON is used by the minio_iam_policy resource to attach the policy. ```terraform data "minio_iam_policy_document" "example" { statement { sid = "1" actions = [ "s3:ListAllMyBuckets", "s3:GetBucketLocation", ] resources = [ "arn:aws:s3:::*", ] } statement { actions = [ "s3:ListBucket", ] resources = [ "arn:aws:s3:::state-terraform-s3", ] condition { test = "StringLike" variable = "s3:prefix" values = [ "", "home/", ] } } statement { actions = [ "s3:PutObject", ] resources = [ "arn:aws:s3:::state-terraform-s3", "arn:aws:s3:::state-terraform-s3/*", ] } } ``` ```terraform resource "minio_iam_policy" "test_policy" { name = "state-terraform-s3" policy = data.minio_iam_policy_document.example.json } ``` -------------------------------- ### minio_s3_bucket resource Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Creates an S3 bucket with optional ACL, force_destroy, object locking, quota, and tags. Use either bucket or bucket_prefix (prefix is create-only). All arguments are optional. ```hcl resource "minio_s3_bucket" "this" { bucket = "my-bucket" # OR bucket_prefix; exact name acl = "private" # default "private" force_destroy = false # true deletes all objects (incl. locked) on destroy object_locking = false # enable object lock at creation (immutable later) quota = 1073741824 # bytes (optional) tags = { Env = "prod" } } ``` -------------------------------- ### Read object lock configuration with minio_s3_bucket_object_lock_configuration Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/s3_bucket_object_lock_configuration.md Use this data source to read the object lock configuration of an existing S3 bucket. The example fetches the configuration for the bucket named 'my-bucket'. ```terraform data "minio_s3_bucket_object_lock_configuration" "example" { bucket = "my-bucket" } ``` -------------------------------- ### Read S3 bucket policy with minio_s3_bucket_policy Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/data-sources/s3_bucket_policy.md Use this data source to read the bucket policy document for an existing S3 bucket. The example retrieves the policy for 'my-bucket' and outputs it as 'policy_json'. ```terraform data "minio_s3_bucket_policy" "my_bucket" { bucket = "my-bucket" } output "policy_json" { value = data.minio_s3_bucket_policy.my_bucket.policy } ``` -------------------------------- ### Import minio_iam_user_policy_attachment by user/policy Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the user/policy pair as the import ID for minio_iam_user_policy_attachment resources. ```hcl ... .a alice/my-policy ``` -------------------------------- ### Import minio_accesskey by access key id Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the access key ID as the import ID for minio_accesskey resources. ```hcl ... .k MYAPPKEY12345 ``` -------------------------------- ### Enable versioning on a bucket with minio_s3_bucket_versioning Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/s3_bucket_versioning.md Creates a versioning configuration for an S3 bucket. Set `status` to "Enabled" to enable versioning or "Suspended" to suspend it. Optionally exclude folders or specific object key prefixes from versioning. ```terraform # Enable versioning on a bucket resource "minio_s3_bucket_versioning" "example" { bucket = "my-bucket" versioning_configuration { status = "Enabled" } } ``` -------------------------------- ### Create a logger webhook resource Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/logger_webhook.md Defines a MinIO logger webhook target that forwards server log events to an HTTP endpoint. The example sets the endpoint, authentication token, and batch size. ```terraform resource "minio_logger_webhook" "splunk" { name = "splunk" endpoint = "https://splunk.example.com:8088/services/collector" auth_token = var.splunk_token batch_size = 100 } ``` -------------------------------- ### Create a KMS encryption key with minio_kms_key Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/kms_key.md Defines a MinIO KMS key resource. The required key_id attribute specifies the KMS key ID. This example creates a key named 'my-encryption-key'. ```terraform # Create a KMS encryption key resource "minio_kms_key" "example" { key_id = "my-encryption-key" } ``` -------------------------------- ### Import minio_iam_policy by policy name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/skills/terraform-minio/references/resources.md Use the policy name as the import ID for minio_iam_policy resources. ```hcl ... minio_iam_policy.p my-policy ``` -------------------------------- ### Run all tests with Docker Compose Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/agents/testing-environment.md Runs the entire test suite inside a Docker Compose service. Use this as the primary command to execute all tests in the project. ```bash # Run all tests docker compose run --rm test ``` -------------------------------- ### Import minio_s3_bucket_versioning using bucket name Source: https://github.com/aminueza/terraform-provider-minio/blob/main/docs/resources/s3_bucket_versioning.md Imports an existing S3 bucket versioning configuration using the bucket name as the import identifier. ```shell # S3 bucket versioning configurations can be imported using the bucket name terraform import minio_s3_bucket_versioning.example bucket-name ```