11data "template_file" "cluster_role_file" {
2+ count = 1
23 template = file (" ./container-insights-agent/cluster_role.tpl" )
34 vars = {
4- NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
5+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
56 }
67 depends_on = [aws_eks_fargate_profile . test_profile ]
78}
89
910data "template_file" "cluster_role_binding_file" {
11+ count = 1
1012 template = file (" ./container-insights-agent/cluster_role_binding.tpl" )
1113 vars = {
12- NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name,
13- SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role.metadata[0 ].name
14+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name,
15+ SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role[count.index] .metadata[0 ].name
1416 }
1517 depends_on = [aws_eks_fargate_profile . test_profile ]
1618}
1719
1820data "template_file" "config_map_file" {
21+ count = 1
1922 template = file (" ./container-insights-agent/config_map.tpl" )
2023 vars = {
21- NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
24+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
2225 }
2326 depends_on = [aws_eks_fargate_profile . test_profile ]
2427}
2528
2629data "template_file" "daemonset_file" {
30+ count = 1
2731 template = file (" ./container-insights-agent/daemonset.tpl" )
2832 vars = {
29- NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
30- SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role.metadata[0 ].name
33+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
34+ SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role[count.index] .metadata[0 ].name
3135 OTELIMAGE = module.common.aoc_image
3236 REGION = var.region
3337 }
@@ -39,7 +43,7 @@ resource "kubectl_manifest" "service_account" {
3943 yaml_body = templatefile (" ./container-insights-agent/service_account_fargate.yml" ,
4044 {
4145 RoleArn : module.iam_assumable_role_admin.iam_role_arn,
42- Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace
46+ Namespace : tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace
4347 })
4448 depends_on = [
4549 module . iam_assumable_role_admin ,
@@ -48,34 +52,37 @@ resource "kubectl_manifest" "service_account" {
4852}
4953
5054resource "kubectl_manifest" "cluster_role" {
51- yaml_body = var. deployment_type == " fargate" ? file (" ./container-insights-agent/cluster_role_fargate.yml" ) : data. template_file . cluster_role_file . rendered
55+ count = 1
56+ yaml_body = var. deployment_type == " fargate" ? file (" ./container-insights-agent/cluster_role_fargate.yml" ) : data. template_file . cluster_role_file [count . index ]. rendered
5257}
5358
5459resource "kubectl_manifest" "cluster_role_binding" {
55- yaml_body = var. deployment_type == " fargate" ? templatefile (" ./container-insights-agent/cluster_role_binding_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace }) : data. template_file . cluster_role_binding_file . rendered
60+ count = 1
61+ yaml_body = var. deployment_type == " fargate" ? templatefile (" ./container-insights-agent/cluster_role_binding_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile [count . index ]. selector )[0 ].namespace }) : data. template_file . cluster_role_binding_file [count . index ]. rendered
5662 depends_on = [
5763 kubectl_manifest . cluster_role ,
5864 aws_eks_fargate_profile . test_profile
5965 ]
6066}
6167
6268resource "kubectl_manifest" "config_map" {
63- yaml_body = var. deployment_type == " fargate" ? templatefile (" ./container-insights-agent/config_map_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace }) : data. template_file . config_map_file . rendered
69+ count = 1
70+ yaml_body = var. deployment_type == " fargate" ? templatefile (" ./container-insights-agent/config_map_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile [count . index ]. selector )[0 ].namespace }) : data. template_file . config_map_file [count . index ]. rendered
6471 depends_on = [aws_eks_fargate_profile . test_profile ]
6572}
6673
6774resource "kubectl_manifest" "daemonset" {
6875 count = var. aoc_base_scenario == " infra" && var. deployment_type != " fargate" ? 1 : 0
6976
70- yaml_body = data. template_file . daemonset_file . rendered
77+ yaml_body = data. template_file . daemonset_file [ count . index ] . rendered
7178 depends_on = [
7279 kubectl_manifest . config_map
7380 ]
7481}
7582
7683resource "kubectl_manifest" "aoc_service_deploy" {
7784 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
78- yaml_body = templatefile (" ./container-insights-agent/aoc_service_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace })
85+ yaml_body = templatefile (" ./container-insights-agent/aoc_service_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace })
7986 depends_on = [
8087 kubectl_manifest . config_map ,
8188 aws_eks_fargate_profile . test_profile
@@ -85,7 +92,7 @@ resource "kubectl_manifest" "aoc_service_deploy" {
8592resource "kubectl_manifest" "aoc_fargate_deploy" {
8693 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
8794 yaml_body = templatefile (" ./container-insights-agent/stateful_set_fargate.yml" ,
88- { ClusterName : var.eks_cluster_name, AocRepo : var.aoc_image_repo, AocTag : var.aoc_version, Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace })
95+ { ClusterName : var.eks_cluster_name, AocRepo : var.aoc_image_repo, AocTag : var.aoc_version, Namespace : tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace })
8996 depends_on = [
9097 kubectl_manifest . aoc_service_deploy ,
9198 aws_eks_fargate_profile . test_profile
@@ -94,7 +101,7 @@ resource "kubectl_manifest" "aoc_fargate_deploy" {
94101
95102resource "kubectl_manifest" "logs_sample_fargate_deploy" {
96103 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
97- yaml_body = templatefile (" ./container-insights-agent/logs_sample_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace })
104+ yaml_body = templatefile (" ./container-insights-agent/logs_sample_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile. test_profile [ count . index ] . selector )[0 ].namespace })
98105 depends_on = [
99106 kubectl_manifest . aoc_fargate_deploy ,
100107 aws_eks_fargate_profile . test_profile
0 commit comments