-
Notifications
You must be signed in to change notification settings - Fork 16
/
ecr-exporter.tf
81 lines (66 loc) · 1.8 KB
/
ecr-exporter.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
################
# ECR Exporter #
################
resource "helm_release" "ecr_exporter" {
count = var.enable_ecr_exporter ? 1 : 0
name = "ecr-exporter"
namespace = kubernetes_namespace.monitoring.id
chart = "prometheus-ecr-exporter"
version = "0.4.0"
repository = "https://ministryofjustice.github.io/cloud-platform-helm-charts"
set {
name = "serviceAccount.name"
value = local.ecr_exporter_sa
}
set {
name = "serviceMonitor.enabled"
value = true
}
set {
name = "aws.region"
value = "eu-west-2"
}
depends_on = [
local.prometheus_dependency,
]
lifecycle {
ignore_changes = [keyring]
}
}
################
# ECR Exporter #
################
data "aws_iam_policy_document" "ecr_exporter" {
statement {
actions = [
"ecr:DescribeRepositories",
"ecr:ListImages",
]
resources = ["*"]
}
}
resource "aws_iam_policy" "ecr_exporter" {
count = var.enable_ecr_exporter ? 1 : 0
name_prefix = "ecr_exporter"
description = "EKS ECR Exporter policy for cluster ${var.cluster_domain_name}"
policy = data.aws_iam_policy_document.ecr_exporter.json
}
# IRSA
module "irsa" {
count = var.enable_ecr_exporter ? 1 : 0
source = "github.com/ministryofjustice/cloud-platform-terraform-irsa?ref=2.0.0"
eks_cluster_name = terraform.workspace
namespace = kubernetes_namespace.monitoring.id
role_policy_arns = {
irsa = aws_iam_policy.ecr_exporter[0].arn
}
service_account_name = local.ecr_exporter_sa
# Tags
# Tags
business_unit = var.business_unit
application = var.application
is_production = var.is_production
team_name = var.team_name
environment_name = var.environment
infrastructure_support = var.infrastructure_support
}