Skip to content

tsuru/terraform-tsuru-app

Repository files navigation

Terraform Tsuru App Module

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

Why This Module?

This module addresses several key challenges in Tsuru application management:

Key Features

  • Complete Tsuru application lifecycle management
  • Automatic scaling configuration
  • Environment variables management (sensitive and non-sensitive)
  • Custom CNAMEs and SSL certificates
  • Service instance bindings
  • Multiple routers support
  • Process-level customization with metadata

Usage

Basic Example

module "my_app" {
  source = "github.com/tsuru/terraform-tsuru-app"

  name        = "my-application"
  description = "My awesome application"
  platform    = "python"
  plan        = "c0.5m1"
  pool        = "production"
  team_owner  = "my-team"
  tags        = ["api", "production"]

  processes = [
    {
      name                 = "web"
      custom_plan          = "c2m4"
      autoscale_target_cpu = 75
      autoscale_min_units  = 3
      autoscale_max_units  = 20
      labels = {
        "process" = "api"
      }
    },
    {
      name                 = "worker"
      autoscale_target_cpu = 80
      autoscale_min_units  = 2
      autoscale_max_units  = 10
    }
  ]

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

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

  # CNAMEs with optional SSL certificates
  cnames = [
    {
      hostname = "myapp.example.com"
      issuer   = "letsencrypt"  # Creates CNAME + SSL certificate
    },
    {
      hostname = "api.example.com"
      issuer   = "letsencrypt"  # Creates CNAME + SSL certificate
    },
    {
      hostname = "staging.example.com"
      # No issuer - only creates CNAME
    }
  ]

}

Examples

Check the examples/ directory for complete usage examples:

  • simple - Basic usage showing both autoscale and fixed units configuration

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_app.app resource
tsuru_app_autoscale.app_scale resource
tsuru_app_cname.app_cname resource
tsuru_app_deploy.app_deploy resource
tsuru_app_env.app_env resource
tsuru_app_grant.team resource
tsuru_app_router.app_router resource
tsuru_app_unit.app_unit resource
tsuru_certificate_issuer.cert resource
tsuru_service_instance_bind.app_bind resource

Inputs

Name Description Type Default Required
annotations Annotations metadata map(string) {} no
app_units Configures fixed units (tsuru_app_unit) per process. Can only be used when the process does not have autoscale configured (autoscale_* not set).
list(
object({
process = string
units_count = number
})
)
[] no
binds App binds
list(
object({
service_name = string
service_instance = string
})
)
[] no
cnames CNAMEs for the application. If issuer is provided, a certificate will be created
list(
object({
hostname = string
issuer = optional(string, null)
})
)
[] no
custom_cpu_burst CPU burst factory override number null no
default_router Tsuru app default router (see: tsuru router list) string "none" no
deploy Deploy the app after creation bool false no
description Tsuru app description string n/a yes
environment_variables non-sensitive app ENV variables map(string) {} no
image Image to be used by the app string "" no
labels Labels metadata map(string) {} no
name Tsuru app name string n/a yes
plan Tsuru app plan (see: tsuru plan list) string "c0.1m0.1" no
platform Tsuru app platform string n/a yes
pool Tsuru pool (see: tsuru pool list) string n/a yes
private_environment_variables Sensitive app ENV variables map(string) {} no
processes Tsuru process configuration. Fields: name (required). Autoscale is optional: to enable it, set autoscale_target_cpu/autoscale_min_units/autoscale_max_units. Optional fields: custom_plan, annotations, labels, scale_down, schedule, prometheus
list(
object({
name = string
custom_plan = optional(string, null)
autoscale_target_cpu = optional(number, null)
autoscale_min_units = optional(number, null)
autoscale_max_units = optional(number, null)
annotations = optional(map(string), {})
labels = optional(map(string), {})
scale_down = optional(object({
percentage = optional(number, null)
stabilization_window = optional(number, null)
units = optional(number, null)
}), null)
schedule = optional(list(object({
min_replicas = number
start = string
end = string
timezone = optional(string, "UTC")
})), [])
prometheus = optional(list(object({
name = string
query = string
threshold = number
custom_address = optional(string, null)
})), [])
})
)
n/a yes
restart_on_update Whether to restart the app when its configuration or processes are updated bool true no
routers Tsuru app routers (see: tsuru router list) set(string) [] no
tags Tsuru tags set(string) n/a yes
team_grants List of teams to grant access to the application set(string) [] no
team_owner Tsuru app team owner string n/a yes

Outputs

Name Description
app_cluster The name of the cluster where the app is deployed
app_cnames List of CNAMEs configured for the application
app_description Application description
app_environment_variables Application environment variables (non-sensitive)
app_name Application name
app_platform Application platform
app_pool Application pool
app_processes Application processes with autoscaling configuration
app_routers List of additional routers configured for the application
app_tags Application tags
app_team_owner Application team owner

About

Tsuru App Terraform Module

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •