DEV Community

Scott Watermasysk
Scott Watermasysk

Posted on • Originally published at scottw.com on

1

Multiple Heroku Environments

When you have multiple environments for an app on Heroku each command you execute requires you to pass in the -a (–app) flag with the app name. Heroku app names need to be unique not just for you, but for Heroku as a whole. This means the app name might not always be as memorable as you would like. KickoffLabs is actually broken up into three separate apps which further complicates things (6 total app names).

Instead of using the -a flag, you can also use the git remote name via the –remote flag.

The remote name only needs to be unique within your app. This means you can reign in this craziness a bit by using your own git remote names. By default, Heroku creates a remote called heroku. You can use the git remote rename command to rename your remote(s) to something more consistent

git remote rename original_name new_name

With this knowledge, you can create more consistent names for your remotes. I generally go with production and staging.

Next, I add the following to my zsh profile:

function hs(){
  heroku "$@" --remote staging
}

function hp(){
  heroku "$@" --remote production
}

Now, anything I want to do to production is as simple as:

hp config:set VAR=1234

And the same can be done in staging:

hs config:set VAR=1234

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay