0

The following method returns a 422 HTTP status code when I attempt to create a Dyno with the heroku app api:

  client = PlatformAPI.connect_oauth(API_KEY)
  dyno_interface = PlatformAPI::Dyno.new(client)
  begin
    dyno_interface.create('my-cool-app', {"command" => " bin/rails server -p 
  $PORT -e $RAILS_ENV", "size" => "hobby", "type"=> "run"})
  rescue => e
   resp = e.response
  end

It fails with the message: Requested type Hobby is not available. Please use Free.

If it matters, I've tried on different versions of the Ruby client, (version 2.0.0). Also, my app does not currently have a Procfile but I was unsure if this would matter.

TLDR: How can I automatically create Dynos of type Hobby via the Heroku API (preferably in Ruby).

  • Seeing a few places that hint that it might not be possible to set the dyno type with anything but the toolbelt but nothing conclusive: https://github.com/heroku/heroku-dyno-types/blob/50032381752f17ecf594412c37d4b54cf4686103/init.rb#L68 Alternatively, it may be possible but the dyno has to be created first?https://github.com/heroku/hatchet/blob/16af66c415102bd5ccc275e0c36c44806c0f28e5/test/hatchet/labs_test.rb#L10 – not_user9123 Nov 07 '17 at 18:02
  • It may be a payment method issue, rather than a programmatic one. Unless you have a credit card or other payment method setup for an app, I believe it will not let you use anything other than free dynos. – geemus Nov 08 '17 at 15:20
  • @geemus The account previously had payment info and hobby dynos set up. Not sure why it was still failing. – not_user9123 Nov 08 '17 at 17:37
  • I sought additional feedback and I believe the problem may be that Heroku does not allow mixing hobby and free dynos on the same app. So if your web dynos are free, your one-offs are expected to be also. Is it possible that the tier of web dynos changed in some other way between when you tried to script it in Ruby and bash? Additionally, I gather some older versions of CLI may have done something "magic" here which might result in the behavior you are seeing. Are you on an up to date CLI? – geemus Nov 09 '17 at 22:01
  • As far as I know the CLI version was up to date. I guess the mixing free and hobby dynos may have been a problem as it seemed to create an unused free worker dyno. However that did not cause a problem when updating from the command line. Thanks for your help. – not_user9123 Nov 09 '17 at 22:30

1 Answers1

1

Never did figure out how to change the dyno type from Ruby so instead we ended up calling bash/Heroku CLI from ruby.

Still interested if anyone knows how to do this from Ruby.