Skip to content

An opinionated Terraform module to provision an application and database very easily with Scalingo

License

Notifications You must be signed in to change notification settings

scalingo-community/terraform-scalingo-app

Repository files navigation

Terraform Module for Scalingo App

An opinionated Terraform module to provision an application and database very easily with Scalingo.

Example usage

module "my_app" {
  source  = "scalingo-community/app/scalingo"
  version = "0.3.2"

  # Configure the name and the canonical domain of the application
  name = "my-app"
  domain = "my-app.example.com"

  # Define environment variables
  environment = {
    FOO = "bar"
  }

  # Configure size and amount of containers "web"
  containers = {
    web = {
      size = "S"
      amount = 2
    }
  }

  # Attach a free PostgreSQL database
  addons = [{ provider = "postgresql", plan = "postgresql-sandbox" }]

  # Configure log drains, will be auto-configured for app and every addons
  log_drains = [{ type = "elk", url = "https://user:[email protected]" }]
}

Community

Used in production by :

Requirements

Name Version
terraform >= 1.3.0, < 2.0.0
environment ~> 1.3
scalingo ~> 2.2

Resources

Name Type
scalingo_addon.addons resource
scalingo_app.app resource
scalingo_autoscaler.autoscalers resource
scalingo_collaborator.collaborators resource
scalingo_container_type.containers resource
scalingo_domain.canonical_domain resource
scalingo_domain.domain_aliases resource
scalingo_log_drain.addons resource
scalingo_log_drain.app resource
scalingo_scm_repo_link.scm_repo_link resource

Inputs

Name Description Type Default Required
additionnal_collaborators List of emails of collaborators that have admin rights for the application list(string) [] no
addons List of addons to add to the application
list(object({
provider = string
plan = string
database_features = optional(list(string))
}))
[] no
authorize_unsecure_http When true, Scalingo does not automatically redirect HTTP traffic to HTTPS. The default behavior is to redirect HTTP traffic to HTTPS (when value is false) bool false no
containers Configuration of the containers of the application.
map(object({
size = optional(string, "S")
amount = optional(number, 1)
autoscaler = optional(object({
min_containers = optional(number, 2)
max_containers = optional(number, 10)
metric = optional(string, "cpu")
target = optional(number, 0.8)
}))
}))
{
"web": {
"amount": 0,
"size": "S"
}
}
no
domain Main domain name of the application, known as "canonical domain" in Scalingo's dashboard. Note that SSL configuration must be completed through the dashboard. string null no
domain_aliases List of others domain names for the application list(string) [] no
environment Map of environment variables to set on the application. Note that value of environment variables can be null or empty. map(string) null no
github_integration Configuration of the GitHub integration of the application. Only one of github_integration or gitlab_integration can be set.
object({
repo_url = string
integration_uuid = optional(string)
branch = optional(string, "main")
auto_deploy_enabled = optional(bool, true)
})
null no
gitlab_integration Configuration of the GitLab integration of the application. Only one of github_integration or gitlab_integration can be set.
object({
repo_url = string
integration_uuid = optional(string)
branch = optional(string, "main")
auto_deploy_enabled = optional(bool, true)
})
null no
log_drains List of log_drain configuration to redirect logs from the application and addons to a log management service. Each configuration is automatically associated to the application and to every eligible addons.
list(object({
type = string
url = optional(string, "")
drain_region = optional(string, "")
host = optional(string, "")
port = optional(string, "")
token = optional(string, "")
}))
[] no
name Name of the application. Must be unique on Scalingo. string n/a yes
review_apps Configuration of the review apps of the application.
object({
enabled = optional(bool, false)

# By default: delete review apps 0 hours after closing the PR
delete_on_close_enabled = optional(bool, true)
hours_before_delete_on_close = optional(string, "0")

# By default: delete review apps after 5 days of inactivity (= no new deployment)
delete_stale_enabled = optional(bool, true)
hours_before_delete_stale = optional(string, "168")

# By default: do not create review apps for PRs from forks
automatic_creation_from_forks_allowed = optional(bool, false)
})
{} no
router_logs When true, the router logs are included in the application logs. (default: false) bool false no
stack The stack to use for the app (default: "scalingo-22"). string "scalingo-22" no
sticky_session When true, sticky sessions are enabled. (default: false) bool false no

Outputs

Name Description
all_environment_variables All environment variables of the Scalingo application (ones added by the terraform module and ones added by Scalingo add-ons).
app_id ID of the Scalingo application.
domain Hostname to use to access the application. Same as the url output but without the https://.
git_url Hostname to use to deploy code with Git + SSH.
origin_domain The FQDN of the Scalingo application (<your_app_name>.<region>.scalingo.io). Same as the domain output if you have not set a canonical domain.
region Region where the application is deployed.
url Base URL to access the application (https://*). If you have set a canonical domain, this will be the URL with the canonical domain, otherwise it will be the default URL of the Scalingo application.

Generate documentation

This module use terraform-docs to auto-generate its documentation. You can use it without installing it thanks to this docker command :

docker run --rm -v "$(pwd):/terraform-docs" -u $(id -u) quay.io/terraform-docs/terraform-docs:0.16.0 markdown table /terraform-docs

About

An opinionated Terraform module to provision an application and database very easily with Scalingo

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages