forked from hellofresh/eks-rolling-update
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathiam.tf
38 lines (36 loc) · 1.2 KB
/
iam.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
data "aws_iam_policy_document" "eks_rolling_update" {
statement {
sid = "EKSRollingUpdate"
actions = [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:SuspendProcesses",
"autoscaling:ResumeProcesses",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:CreateOrUpdateTags",
"autoscaling:DeleteTags",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeInstances"
]
resources = [
"*"
]
}
}
resource "aws_iam_policy" "eks_rolling_update" {
name = var.app_name
path = "/"
policy = data.aws_iam_policy_document.eks_rolling_update.json
}
module "iam_assumable_role_eks_rolling_update" {
source = "terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
version = "5.28.0"
create_role = true
role_name = var.app_name
provider_url = var.eks_oidc_provider
role_policy_arns = [aws_iam_policy.eks_rolling_update.arn]
oidc_fully_qualified_subjects = ["system:serviceaccount:${var.namespace}:${var.app_name}"]
tags = {
"Name" = var.app_name
}
}