Search code examples
pythonheroku

Change Dyno types through the Heroku API


I have an app running in Heroku; I'm using the Heroku scheduler to run a python script that scales the number of dynos at particular times of the day, using the python API (following this answer):

import heroku
cloud = heroku.from_key(os.environ.get('HEROKU_API_KEY'))
app = cloud.apps['myapp']
webproc = app.processes['web']
webproc.scale(1)

My question is: is there an API call to change Dyno types? For instance to change it from "standard 1X" to "standard 2X" or to "hobby".

Thanks


Solution

  • A chat with the Heroku support has confirmed that the python API has no command to perform this operation; I have therefore resorted to add the following script to the app (following this answer):

    #!/bin/bash
    
    curl -s https://s3.amazonaws.com/assets.heroku.com/heroku-client/heroku-client.tgz | tar xz
    mv heroku-client/* .
    rmdir heroku-client
    PATH="bin:$PATH"
    
    heroku dyno:type hobby --app MYAPP
    

    Changing hobby with standard-1x or standard-2x as needed.