heroku_slug

Provides a Heroku Slug resource.

This resource supports uploading a pre-generated archive file of executable code, making it possible to launch apps directly from a Terraform config. This resource does not itself generate the slug archive. A guide to creating slug archives is available in the Heroku Dev Center.

Minimal Example

Create a ready-to-release slug:

resource "heroku_app" "foobar" {
  name = "foobar"
  region = "us"
}

resource "heroku_slug" "foobar" {
  app_id   = heroku_app.foobar.id
  file_url = "https://github.com/heroku/terraform-provider-heroku/raw/master/heroku/test-fixtures/slug.tgz"

  process_types = {
    web = "ruby server.rb"
  }
}

Example Usage

Complete config to launch a Heroku app:

resource "heroku_app" "foobar" {
    name = "foobar"
    region = "us"
}

# Create a slug for the app with a local slug archive file
resource "heroku_slug" "foobar" {
  app_id                         = heroku_app.foobar.id
  buildpack_provided_description = "Ruby"
  // The slug archive file must already exist
  file_path                      = "slug.tgz"

  process_types = {
    web = "ruby server.rb"
  }
}

# Deploy a release to the app with the slug
resource "heroku_app_release" "foobar" {
  app_id  = heroku_app.foobar.id
  slug_id = heroku_slug.foobar.id
}

# Launch the app's web process by scaling-up
resource "heroku_formation" "foobar" {
  app_id     = heroku_app.foobar.id
  type       = "web"
  quantity   = 1
  size       = "Standard-1x"
  depends_on = ["heroku_app_release.foobar"]
}

Argument Reference

The following arguments are supported:

Attributes Reference

The following attributes are exported:

Import

Existing slugs can be imported using the combination of the application name, a colon, and the slug ID.

For example:

$ terraform import heroku_slug.foobar bazbux:4f1db8ef-ed5c-4c42-a3d6-3c28262d5abc