-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
46 lines (40 loc) · 1.01 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
locals {
bucket_name = "${var.bucket_prefix}${var.tenant_name}"
}
resource "random_string" "user_postfix" {
length = 8
special = false
}
resource "minio_iam_user" "tenant" {
name = "${var.tenant_name}-${random_string.user_postfix.result}"
force_destroy = true
tags = var.user_tags
}
resource "minio_iam_policy" "access_bucket" {
policy = jsonencode({
"Version" : "2012-10-17"
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"s3:*"
],
"Resource" : [
"arn:aws:s3:::${local.bucket_name}/*",
"arn:aws:s3:::${local.bucket_name}"
]
},
]
})
}
resource "minio_iam_user_policy_attachment" "name" {
policy_name = minio_iam_policy.access_bucket.name
user_name = minio_iam_user.tenant.name
}
resource "minio_iam_service_account" "name" {
target_user = minio_iam_user.tenant.name
}
resource "minio_s3_bucket" "tenant" {
bucket = local.bucket_name
force_destroy = var.bucket_force_destroy
}