Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
How to get output of k8s job in terraform

I am using kubernetes provider in terraform, and I run a kubernetes job on an EKS cluster on AWS. I want to obtain some pieces of output from the job and store them in my terraform variables (or AWS parameter store) so I can use them in my terraform files in other places.
I am not sure how to do it.
Can the job write this information in a file and put it back into the config map that it received? Or is there a way in terraform to parse the log (the stdout) of the k8s job?

Here is, more or less, my terraform file:

resource "kubernetes_job" "my_job" {

  metadata {
    name = "my_job"
    namespace = var.namespace
  }
  spec {
    template {
      metadata {}
      spec {
       volume {
                name = local.config_name
                config_map {
                            name = kubernetes_config_map.my_job.metadata[0].name
                            default_mode = "0777"
                           }
                }
             container {
                    name        = "my_container"
                    image       = "123456789012.dkr.ecr.us-east-1.amazonaws.com/my_container:6.4.1.37"
                    command     = ["/bin/bash","/opt/utilities/run_pre_db_script.sh"]
                    working_dir = "/opt/utilities"
                    volume_mount {

                                name =  local.config_name
                                mount_path = "/opt/my_container_mount"
                              }
             }
        restart_policy = "Never"
      }
    }
  }
  timeouts {
    create="5m"
  }
  wait_for_completion = true
}
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Terraform can't parse the logs the job produces, and changing the configmap values is ill-advised as it will create a difference between your configuration and the state in production.

The best solution I can think of for achieving your task is having the job produce dynamically generated tarraform files/terraform parameter files, commit them to the store where the rest of your terraform files are stored (a git repository, for example).

Once you achieve that you can have the next terraform invocation retrieve the results of the job and incorporate it into the next execution.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda