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