Skip to content

tsuru/terraform-tsuru-job

Repository files navigation

Terraform Tsuru Job Module

A comprehensive Terraform module for managing Tsuru jobs with Infrastructure as Code (IaC).

Why This Module?

This module addresses several key challenges in Tsuru job management:

Key Features

  • Complete Tsuru job lifecycle management
  • Job deployment with container images
  • Environment variables management (sensitive and non-sensitive)
  • Flexible scheduling with cron expressions
  • Container configuration support
  • Metadata management with labels and annotations

Usage

Basic Example

module "my_job" {
  source = "github.com/tsuru/terraform-tsuru-job"

  name        = "my-scheduled-job"
  description = "My awesome scheduled job"
  plan        = "c0.5m1"
  pool        = "production"
  team_owner  = "my-team"
  schedule    = "0 2 * * *"  # Run daily at 2 AM
  tags        = ["cronjob", "production"]

  container_image   = "myregistry/myimage:latest"
  container_command = ["python", "script.py"]

  metadata = {
    labels = {
      "app"         = "data-processor"
      "environment" = "production"
    }
    annotations = {
      "description" = "Daily data processing job"
    }
  }

  environment_variables = {
    LOG_LEVEL = "info"
    APP_ENV   = "production"
  }

  private_environment_variables = {
    API_KEY = "your-api-key-here"
    SECRET_TOKEN = "your-secret-token"
  }
}

Examples

Check the examples/ directory for complete usage examples:

  • simple - Basic usage showing scheduled and manual jobs

Each example includes a detailed README with instructions and important notes about deployment requirements.

Prerequisites

Contributing

For more details on how to contribute please see the contributing guideline.

Maintainers

This module is maintained by:

Feel free to reach out to the maintainers for questions, suggestions, or if you're interested in becoming a maintainer yourself.


Requirements

Name Version
terraform >= 1.8
tsuru ~> 2.17.1

Providers

Name Version
tsuru ~> 2.17.1

Modules

No modules.

Resources

Name Type
tsuru_job.job resource
tsuru_job_deploy.job_deploy resource
tsuru_job_env.job_env resource

Inputs

Name Description Type Default Required
active_deadline_seconds Time a Job can run before its terminated. Defaults is 3600 number null no
concurrency_policy Concurrency policy string null no
container_command Container command for the job list(string) null no
container_image Container image for the job string null no
deploy Deploy the job after creation bool false no
deploy_wait Wait for the rollout of deploy to complete bool false no
description Tsuru job description string "" no
environment_variables Non-sensitive job ENV variables map(string) {} no
image Docker image to be deployed to the job string "" no
metadata Job metadata with labels and annotations
object({
labels = optional(map(string), {})
annotations = optional(map(string), {})
})
{
"annotations": {},
"labels": {}
}
no
name Tsuru job name string n/a yes
plan Tsuru job plan (see: tsuru plan list) string "c0.1m0.1" no
pool Tsuru pool (see: tsuru pool list) string n/a yes
private_environment_variables Sensitive job ENV variables map(string) {} no
schedule Cron-like schedule for when the job should be triggered (keep empty for manual jobs) string "" no
tags Tsuru tags set(string) [] no
team_owner Tsuru job team owner string n/a yes

Outputs

Name Description
deploy_output_image Image generated after success of deploy
deploy_status Deploy status
job_cluster The name of the cluster where the job is deployed
job_description Job description
job_environment_variables Job environment variables (non-sensitive)
job_name Job name
job_plan Job plan
job_pool Job pool
job_schedule Job schedule (cron format)
job_tags Job tags
job_team_owner Job team owner

About

Tsuru Job Terraform Module

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published