-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
fargate.tf
37 lines (32 loc) · 1.04 KB
/
fargate.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
resource "aws_eks_fargate_profile" "fargate" {
for_each = var.fargate_selector
cluster_name = aws_eks_cluster.cluster.name
fargate_profile_name = "${var.environment_name}-${each.key}"
pod_execution_role_arn = lookup(each.value, "role_arn", aws_iam_role.fargate.arn)
subnet_ids = lookup(each.value, "subnet_ids", aws_subnet.private.*.id)
selector {
namespace = each.key
}
tags = local.tags
}
resource "aws_iam_role" "fargate" {
name = "${var.environment_name}-fargate"
assume_role_policy = jsonencode({
Statement = [{
Action = "sts:AssumeRole"
Effect = "Allow"
Principal = {
Service = [
"eks.amazonaws.com",
"eks-fargate-pods.amazonaws.com"
]
}
}]
Version = "2012-10-17"
})
tags = local.tags
}
resource "aws_iam_role_policy_attachment" "fargate-AmazonEKSFargatePodExecutionRolePolicy" {
policy_arn = "arn:${local.partition}:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy"
role = aws_iam_role.fargate.name
}