From d9ffa00b0331fed74823107db4bd49f3affa63ca Mon Sep 17 00:00:00 2001 From: Ricard Illa Date: Tue, 4 Jul 2023 15:31:18 +0200 Subject: [PATCH] feat: added minio bucket with terraform state --- justfile | 10 +++++----- main.tf | 4 ++++ modules/minio_buckets/main.tf | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 modules/minio_buckets/main.tf diff --git a/justfile b/justfile index c853e5b..371ac12 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,3 @@ -# export TF_VAR_hetzner_token := `pass hetzner.com/tokens/suricata` export TF_VAR_pg_passwd := `pass pg.monotremata.xyz/terraform` export TF_VAR_minio_root_user := "rilla" export TF_VAR_minio_root_password := `pass minio.monotremata.xyz/rilla` @@ -7,13 +6,14 @@ export LINODE_TOKEN := `pass linode.com/token` export VULTR_API_KEY := `pass vultr.com/api_key` export HETZNER_DNS_API_TOKEN := `pass hetzner.com/tokens/terraform` -minio_access_key := `pass minio.monotremata.xyz/terraform/access_key` -minio_secret_key := `pass minio.monotremata.xyz/terraform/secret_key` +export MINIO_ENDPOINT := "minio.monotremata.xyz:443" +export MINIO_USER := `pass minio.monotremata.xyz/terraform/access_key` +export MINIO_PASSWORD := `pass minio.monotremata.xyz/terraform/secret_key` init: terraform init \ - -backend-config="access_key={{minio_access_key}}" \ - -backend-config="secret_key={{minio_secret_key}}" + -backend-config="access_key=$(pass minio.monotremata.xyz/terraform/access_key)" \ + -backend-config="secret_key=$(pass minio.monotremata.xyz/terraform/secret_key)" plan *ARGS: terraform plan {{ARGS}} diff --git a/main.tf b/main.tf index 6bde38f..fbe9ad4 100644 --- a/main.tf +++ b/main.tf @@ -79,3 +79,7 @@ module "minio" { minio_console_url = "minio-console.monotremata.xyz" minio_host_path = "/mnt/k3s_volumes/minio" } + +module "minio_buckets" { + source = "./modules/minio_buckets" +} diff --git a/modules/minio_buckets/main.tf b/modules/minio_buckets/main.tf new file mode 100644 index 0000000..55a7a85 --- /dev/null +++ b/modules/minio_buckets/main.tf @@ -0,0 +1,17 @@ +terraform { + required_providers { + minio = { + source = "aminueza/minio" + version = ">= 1.15.2" + } + } +} + +provider "minio" { + minio_ssl = true +} + +resource "minio_s3_bucket" "state_terraform_s3" { + bucket = "terraform" + acl = "private" +}