-
Notifications
You must be signed in to change notification settings - Fork 2
/
iam_gait_landing_staging.tf
84 lines (76 loc) · 2.24 KB
/
iam_gait_landing_staging.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
resource "aws_iam_user" "dq_gait_landing_staging_bucket" {
count = var.namespace == "prod" ? 1 : 0
name = "iam-user-gait-landing-staging-bucket-${local.naming_suffix}"
}
resource "aws_iam_group" "dq_gait_landing_staging_bucket" {
count = var.namespace == "prod" ? 1 : 0
name = "iam-group-gait-landing-staging-bucket-${local.naming_suffix}"
}
resource "aws_iam_policy" "dq_gait_landing_staging_bucket_policy" {
count = var.namespace == "prod" ? 1 : 0
name = "iam-policy-gait-landing-staging-bucket-${local.naming_suffix}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:GetBucketLocation",
"s3:ListBucket",
"s3:ListBucketMultipartUploads",
"s3:ListMultipartUploadParts"
],
"Effect": "Allow",
"Resource": [
"${aws_s3_bucket.dq_gait_landing_staging_bucket[0].arn}",
"${aws_s3_bucket.dq_gait_landing_staging_bucket[0].arn}/*"
]
},
{
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": [
"${aws_s3_bucket.dq_gait_landing_staging_bucket[0].arn}/*"
]
},
{
"Action": [
"s3:DeleteObject"
],
"Effect": "Allow",
"Resource": [
"${aws_s3_bucket.dq_gait_landing_staging_bucket[0].arn}/*"
]
},
{
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": [
"${aws_s3_bucket.dq_gait_landing_staging_bucket[0].arn}"
]
}
]
}
EOF
}
resource "aws_iam_group_policy_attachment" "dq_gait_landing_staging_bucket_policy" {
count = var.namespace == "prod" ? 1 : 0
group = aws_iam_group.dq_gait_landing_staging_bucket[0].id
policy_arn = aws_iam_policy.dq_gait_landing_staging_bucket_policy[0].arn
}
resource "aws_iam_group_membership" "dq_gait_landing_staging_bucket" {
count = var.namespace == "prod" ? 1 : 0
name = "iam-gait-landing-staging-bucket${local.naming_suffix}"
users = [aws_iam_user.dq_gait_landing_staging_bucket[count.index].name]
group = aws_iam_group.dq_gait_landing_staging_bucket[count.index].name
}