diff options
Diffstat (limited to 'terraform/modules')
-rw-r--r-- | terraform/modules/minio-pg-backup/main.tf | 63 | ||||
-rw-r--r-- | terraform/modules/minio-pg-backup/vars.tf | 3 |
2 files changed, 66 insertions, 0 deletions
diff --git a/terraform/modules/minio-pg-backup/main.tf b/terraform/modules/minio-pg-backup/main.tf new file mode 100644 index 0000000..f9e774a --- /dev/null +++ b/terraform/modules/minio-pg-backup/main.tf @@ -0,0 +1,63 @@ +terraform { + required_providers { + minio = { + source = "tidalf/minio" + version = "1.1.1" + } + } +} + +resource "minio_iam_user" "sender" { + name = "pg-backup-${var.id}-sender" +# update_secret = true +} + +resource "minio_s3_bucket" "bucket" { + bucket = "pg-backup-${var.id}" + acl = "public" +} + +resource "minio_iam_policy" "sender" { + name = minio_iam_user.sender.id + policy= <<EOF +{ + "Version":"2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:ListBucket" + ], + "Resource": "arn:aws:s3:::${minio_s3_bucket.bucket.bucket}" + }, + { + "Effect": "Allow", + "Action": [ + "s3:ListBucket", + "s3:GetObject", + "s3:PutObject" + ], + "Resource": "arn:aws:s3:::${minio_s3_bucket.bucket.bucket}/*" + } + ] +} +EOF +} + +resource "minio_iam_user_policy_attachment" "sender" { + user_name = minio_iam_user.sender.id + policy_name = minio_iam_policy.sender.id +} + +output "sender" { + value = { + access_key: minio_iam_user.sender.name, + secret_key: minio_iam_user.sender.secret, + } +} + +output "bucket" { + value = { + name: minio_s3_bucket.bucket.id, + } +} diff --git a/terraform/modules/minio-pg-backup/vars.tf b/terraform/modules/minio-pg-backup/vars.tf new file mode 100644 index 0000000..f1f47fe --- /dev/null +++ b/terraform/modules/minio-pg-backup/vars.tf @@ -0,0 +1,3 @@ +variable "id" { + type = string +} |