-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathiam_crt.tf
63 lines (54 loc) · 1.26 KB
/
iam_crt.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
resource "aws_iam_group" "crt" {
name = "iam-group-crt-${local.naming_suffix}"
}
resource "aws_iam_group_membership" "crt" {
name = "iam-group-membership-crt-${local.naming_suffix}"
users = [
aws_iam_user.crt.name,
]
group = aws_iam_group.crt.name
}
resource "aws_iam_policy" "crt" {
name = "iam-policy-crt-${local.naming_suffix}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListS3Bucket",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "${aws_s3_bucket.data_archive_bucket.arn}"
},
{
"Sid": "GetS3Bucket",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject"
],
"Resource": "${aws_s3_bucket.data_archive_bucket.arn}/crt-backup/*"
},
{
"Sid": "UseKMSKey",
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:ReEncrypt*",
"kms:GenerateDataKey*",
"kms:DescribeKey"
],
"Resource": "${aws_kms_key.bucket_key.arn}"
}
]
}
EOF
}
resource "aws_iam_group_policy_attachment" "crt" {
group = aws_iam_group.crt.name
policy_arn = aws_iam_policy.crt.arn
}
resource "aws_iam_user" "crt" {
name = "iam-user-crt-${local.naming_suffix}"
}