-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathci_user_policy.tf
49 lines (44 loc) · 1.25 KB
/
ci_user_policy.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
resource "aws_iam_policy" "cloudfront-policy" {
count = var.ci_user == "" ? 0 : 1
name = "cloudfront-${var.site_domain}-policy"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "cloudfront:ListDistributions",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"cloudfront:GetDistribution",
"cloudfront:GetDistributionConfig"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"cloudfront:ListCloudFrontOriginAccessIdentities",
"cloudfront:ListInvalidations",
"cloudfront:GetInvalidation",
"cloudfront:CreateInvalidation"
],
"Resource": "*"
}
]
}
EOF
}
resource "aws_iam_user_policy_attachment" "bucket-policy-attach" {
count = var.ci_user == "" ? 0 : 1
user = var.ci_user
policy_arn = aws_iam_policy.bucket-policy.arn
}
resource "aws_iam_user_policy_attachment" "cloudfront-policy-attach" {
count = var.ci_user == "" ? 0 : 1
user = var.ci_user
policy_arn = aws_iam_policy.cloudfront-policy[0].arn
}