-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13-iam-service-a.tf
36 lines (30 loc) · 1006 Bytes
/
13-iam-service-a.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
data "aws_iam_policy_document" "service_a" {
statement {
actions = ["sts:AssumeRoleWithWebIdentity"]
effect = "Allow"
condition {
test = "StringEquals"
variable = "${replace(aws_iam_openid_connect_provider.eks.url, "https://", "")}:sub"
values = ["system:serviceaccount:service-a:service-a"]
}
principals {
identifiers = [aws_iam_openid_connect_provider.eks.arn]
type = "Federated"
}
}
}
resource "aws_iam_role" "service_a" {
assume_role_policy = data.aws_iam_policy_document.service_a.json
name = "${local.env}-${local.eks_name}-eks-service-a"
}
resource "aws_iam_policy" "service_a" {
policy = file("./proxy-auth.json")
name = "AppMeshServiceAAccess"
}
resource "aws_iam_role_policy_attachment" "service_a" {
role = aws_iam_role.service_a.name
policy_arn = aws_iam_policy.service_a.arn
}
output "iam_service_a_arn" {
value = aws_iam_role.service_a.arn
}