11data "template_file" "cluster_role_file" {
22 template = file (" ./container-insights-agent/cluster_role.tpl" )
33 vars = {
4- NAMESPACE = var.deployment_type == " fargate" ? " default " : kubernetes_namespace.aoc_ns.metadata[0 ].name
4+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
55 }
6+ depends_on = [aws_eks_fargate_profile . test_profile ]
67}
78
89data "template_file" "cluster_role_binding_file" {
910 template = file (" ./container-insights-agent/cluster_role_binding.tpl" )
1011 vars = {
11- NAMESPACE = var.deployment_type == " fargate" ? " default " : kubernetes_namespace.aoc_ns.metadata[0 ].name,
12+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name,
1213 SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role.metadata[0 ].name
1314 }
15+ depends_on = [aws_eks_fargate_profile . test_profile ]
1416}
1517
1618data "template_file" "config_map_file" {
1719 template = file (" ./container-insights-agent/config_map.tpl" )
1820 vars = {
19- NAMESPACE = var.deployment_type == " fargate" ? " default " : kubernetes_namespace.aoc_ns.metadata[0 ].name
21+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
2022 }
23+ depends_on = [aws_eks_fargate_profile . test_profile ]
2124}
2225
2326data "template_file" "daemonset_file" {
2427 template = file (" ./container-insights-agent/daemonset.tpl" )
2528 vars = {
26- NAMESPACE = var.deployment_type == " fargate" ? " default " : kubernetes_namespace.aoc_ns.metadata[0 ].name
29+ NAMESPACE = var.deployment_type == " fargate" ? tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace : kubernetes_namespace.aoc_ns.metadata[0 ].name
2730 SERVICE_ACCOUNT = kubernetes_service_account.aoc- agent- role.metadata[0 ].name
2831 OTELIMAGE = module.common.aoc_image
2932 REGION = var.region
3033 }
34+ depends_on = [aws_eks_fargate_profile . test_profile ]
3135}
3236
3337resource "kubectl_manifest" "service_account" {
3438 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
35- yaml_body = templatefile (" ./container-insights-agent/service_account_fargate.tpl " ,
39+ yaml_body = templatefile (" ./container-insights-agent/service_account_fargate.yml " ,
3640 {
37- RoleArn : module.iam_assumable_role_admin.iam_role_arn
41+ RoleArn : module.iam_assumable_role_admin.iam_role_arn,
42+ Namespace : tolist (aws_eks_fargate_profile. test_profile . selector )[0 ].namespace
3843 })
3944 depends_on = [
40- module . iam_assumable_role_admin
45+ module . iam_assumable_role_admin ,
46+ aws_eks_fargate_profile . test_profile
4147 ]
4248}
4349
@@ -46,14 +52,16 @@ resource "kubectl_manifest" "cluster_role" {
4652}
4753
4854resource "kubectl_manifest" "cluster_role_binding" {
49- yaml_body = var. deployment_type == " fargate" ? file (" ./container-insights-agent/cluster_role_binding_fargate.yml" ) : data. template_file . cluster_role_binding_file . rendered
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
5056 depends_on = [
51- kubectl_manifest . cluster_role
57+ kubectl_manifest . cluster_role ,
58+ aws_eks_fargate_profile . test_profile
5259 ]
5360}
5461
5562resource "kubectl_manifest" "config_map" {
56- yaml_body = var. deployment_type == " fargate" ? file (" ./container-insights-agent/config_map_fargate.yml" ) : data. template_file . config_map_file . rendered
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
64+ depends_on = [aws_eks_fargate_profile . test_profile ]
5765}
5866
5967resource "kubectl_manifest" "daemonset" {
@@ -67,25 +75,28 @@ resource "kubectl_manifest" "daemonset" {
6775
6876resource "kubectl_manifest" "aoc_service_deploy" {
6977 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
70- yaml_body = file (" ./container-insights-agent/aoc_service_fargate.yml" )
78+ yaml_body = templatefile (" ./container-insights-agent/aoc_service_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace } )
7179 depends_on = [
72- kubectl_manifest . config_map
80+ kubectl_manifest . config_map ,
81+ aws_eks_fargate_profile . test_profile
7382 ]
7483}
7584
7685resource "kubectl_manifest" "aoc_fargate_deploy" {
7786 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
78- yaml_body = templatefile (" ./container-insights-agent/stateful_set_fargate.tpl " ,
79- { ClusterName : var.eks_cluster_name, AocRepo : var.aoc_image_repo, AocTag : var.aoc_version })
87+ 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 })
8089 depends_on = [
81- kubectl_manifest . aoc_service_deploy
90+ kubectl_manifest . aoc_service_deploy ,
91+ aws_eks_fargate_profile . test_profile
8292 ]
8393}
8494
8595resource "kubectl_manifest" "logs_sample_fargate_deploy" {
8696 count = var. aoc_base_scenario == " infra" && var. deployment_type == " fargate" ? 1 : 0
87- yaml_body = file (" ./container-insights-agent/logs_sample_fargate.yml" )
97+ yaml_body = templatefile (" ./container-insights-agent/logs_sample_fargate.yml" , { Namespace : tolist (aws_eks_fargate_profile . test_profile . selector )[ 0 ].namespace } )
8898 depends_on = [
89- kubectl_manifest . aoc_fargate_deploy
99+ kubectl_manifest . aoc_fargate_deploy ,
100+ aws_eks_fargate_profile . test_profile
90101 ]
91102}
0 commit comments