File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ metadata:
44 name: adot-collector-service-account
55 namespace: default
66 annotations:
7- eks.amazonaws.com/role-arn : arn:aws:iam::611364707713:role/ServiceAccount-eks-test-aoc-role
7+ eks.amazonaws.com/role-arn: $ { RoleArn }
Original file line number Diff line number Diff line change @@ -31,8 +31,14 @@ data "template_file" "daemonset_file" {
3131}
3232
3333resource "kubectl_manifest" "service_account" {
34- count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
35- yaml_body = file (" ./container-insights-agent/service_account_fargate.yml" )
34+ count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
35+ yaml_body = templatefile (" ./container-insights-agent/service_account_fargate.tpl" ,
36+ {
37+ RoleArn : module.iam_assumable_role_admin.iam_role_arn
38+ })
39+ depends_on = [
40+ module . iam_assumable_role_admin
41+ ]
3642}
3743
3844resource "kubectl_manifest" "cluster_role" {
Original file line number Diff line number Diff line change @@ -116,11 +116,28 @@ resource "kubernetes_service_account" "aoc-fargate-role" {
116116 name = " aoc-fargate-role-${ module . common . testing_id } "
117117 namespace = " default"
118118 annotations = {
119- " eks.amazonaws.com/role-arn" : " arn:aws:iam:: ${ data . aws_caller_identity . current . account_id } :role/ServiceAccount-eks-test-aoc-role "
119+ " eks.amazonaws.com/role-arn" : module.iam_assumable_role_admin.iam_role_arn
120120 }
121121 }
122122
123123 automount_service_account_token = true
124+ depends_on = [module . iam_assumable_role_admin ]
125+ }
126+
127+ module "iam_assumable_role_admin" {
128+ create_role = true
129+
130+ role_name = " aoc-eks-assume-role-${ module . common . testing_id } "
131+
132+ provider_url = trimprefix (data. aws_eks_cluster . testing_cluster . identity [0 ]. oidc [0 ]. issuer , " https://" )
133+
134+ role_policy_arns = [
135+ " arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy" ,
136+ " arn:aws:iam::aws:policy/AWSXrayFullAccess" ,
137+ " arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess" ,
138+ ]
139+ source = " terraform-aws-modules/iam/aws//modules/iam-assumable-role-with-oidc"
140+ version = " 4.7.0"
124141}
125142
126143resource "kubernetes_cluster_role_binding" "aoc-role-binding" {
You can’t perform that action at this time.
0 commit comments