-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam-ecr.tf
49 lines (47 loc) · 1.46 KB
/
iam-ecr.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
data "aws_iam_policy_document" "svcfoundry_access_to_ecr" {
statement {
effect = "Allow"
actions = [
"ecr:GetRegistryPolicy",
"ecr:DescribeImageScanFindings",
"ecr:GetLifecyclePolicyPreview",
"ecr:CreateRepository",
"ecr:GetDownloadUrlForLayer",
"ecr:DescribeImageReplicationStatus",
"ecr:ListTagsForResource",
"ecr:BatchGetRepositoryScanningConfiguration",
"ecr:GetRegistryScanningConfiguration",
"ecr:PutImage",
"ecr:BatchGetImage",
"ecr:DescribeRepositories",
"ecr:BatchCheckLayerAvailability",
"ecr:GetRepositoryPolicy",
"ecr:GetLifecyclePolicy",
"ecr:ListImages",
"ecr:InitiateLayerUpload",
"ecr:CompleteLayerUpload",
"ecr:DescribeImages",
"ecr:DeleteRepository",
"ecr:UploadLayerPart",
]
resources = [
"arn:aws:ecr:${var.aws_region}:${var.aws_account_id}:repository/tfy-*"
]
}
statement {
effect = "Allow"
actions = [
"ecr:DescribeRegistry",
"ecr:GetAuthorizationToken",
"sts:GetServiceBearerToken"
]
resources = ["*"]
}
}
resource "aws_iam_policy" "svcfoundry_access_to_ecr" {
count = var.truefoundry_iam_role_enabled ? 1 : 0
name_prefix = "${local.svcfoundry_unique_name}-access-to-ecr"
description = "ECR access for ${var.svcfoundry_k8s_service_account} on ${var.cluster_name}"
policy = data.aws_iam_policy_document.svcfoundry_access_to_ecr.json
tags = local.tags
}