-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache.tf
60 lines (54 loc) · 1.39 KB
/
cache.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
resource "aws_s3_bucket" "gitlab_cache" {
bucket = local.stack_name
}
data "aws_iam_policy_document" "gitlab_cache" {
statement {
effect = "Allow"
actions = [
"kms:GetPublicKey",
"kms:Decrypt",
"kms:Encrypt",
"kms:DescribeKey",
"kms:GenerateDataKey",
]
resources = ["*"]
}
statement {
effect = "Allow"
actions = [
"s3:GetObject",
"s3:GetObjectVersion",
"s3:DeleteObject",
"s3:PutObject",
"s3:AbortMultipartUpload",
"s3:ListBucket",
"s3:ListMultipartUploadParts",
]
resources = [
"${aws_s3_bucket.gitlab_cache.arn}/*",
aws_s3_bucket.gitlab_cache.arn,
]
}
}
resource "aws_iam_policy" "gitlab_cache_policy" {
name = "gitlab-cache-${local.stack_name}"
policy = data.aws_iam_policy_document.gitlab_cache.json
}
data "aws_iam_policy_document" "gitlab_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
effect = "Allow"
}
}
# resource "aws_iam_role" "gitlab_role" {
# name = "gitlab-role-${local.stack_name}"
# assume_role_policy = data.aws_iam_policy_document.gitlab_assume_role_policy.json
# }
resource "aws_iam_role_policy_attachment" "gitlab_policy_attachment" {
policy_arn = aws_iam_policy.gitlab_cache_policy.arn
role = var.iam_role
}