Home > Mobile >  Terraform / Heroku not finding 'web' process in heroku/ruby buildpack
Terraform / Heroku not finding 'web' process in heroku/ruby buildpack

Time:02-19

I'm getting an error in Terraform:

Error: Patch "https://api.heroku.com/apps/coderdojo-contentful-staging/formation/web": Couldn't find that process type (web).

│ with heroku_formation.coderdojo_contentful_staging_formation[0],
│ on terraform.tf line 41, in resource "heroku_formation" "coderdojo_contentful_staging_formation":
│ 41: resource "heroku_formation" "coderdojo_contentful_staging_formation" {

from these lines from my terraform.tf file:

resource "heroku_formation" "coderdojo_contentful_staging_formation" {
  count    = length(var.formations)
  app      = heroku_app.coderdojo_contentful_staging.name
  type     = lookup(var.formations[count.index], "type")
  quantity = lookup(var.formations[count.index], "quantity")
  size     = lookup(var.formations[count.index], "size")
}

which rely on these lines in my terraform.tfvars file:

formations = [
  {
    type     = "web"
    size     = "standard-1x"
    quantity = "1"
  }
]

buildpacks = [
  "heroku/ruby"
]

Searching the documentation online (e.g. buildpacks and heroku-buildpack-ruby) it appears that the web process type comes from either the buildpack, or the Procfile.

Another project works fine with a very similar setup (i.e. no Procfile), but with the addition of a heroku/nodejs buildpack. I tried adding that build pack but got the same error.

What am I missing?

CodePudding user response:

Another project works fine with a very similar setup (i.e. no Procfile), but with the addition of a heroku/nodejs buildpack. I tried adding that build pack but got the same error.

The heroku/nodejs buildpack falls back to the start script defined in the package.json if no Procfile is present. I suspect your other project that uses that buildpack has a start script. The Ruby buildpack has no such default.

If your app doesn't require Node.js, don't add the Node.js buildpack. Instead, add a Procfile to the root of your repository that tells Heroku how to run your app, e.g.

web: bundle exec ruby path/to/some/script.rb

This defines a web process that runs bundle exec ruby ruby path/to/some/script.rb.

  • Related