How to remove addon when attached with multiple names on Heroku? - heroku

We're migrating some things around and needed to attach the same database using two different environment variables temporarily. Now that we migrated, I would like to remove the attachment, but sadly, the Heroku command-line client says that I have an ambiguous identifier:
$ heroku addons --app $APP_SOURCE
Add-on Plan Price State
────────────────────────────────────────────────────────────── ─────────── ──────── ───────
heroku-postgresql (...) hobby-basic $9/month created
├─ as DATABASE
├─ as HEROKU_POSTGRESQL_ORANGE
├─ as DATABASE on stb-crds-rails-sf app
├─ as SHARETHEBUS_RAILS_DATABASE on stb-crds-rails-sf app
└─ as SHARETHEBUS_RAILS_DATABASE_URL on stb-crds-rails-sf app
$ heroku addons:detach --app stb-crds-rails-sf $ADDON_NAME
▸ Ambiguous identifier; multiple matching attachments found: DATABASE, SHARETHEBUS_RAILS_DATABASE, SHARETHEBUS_RAILS_DATABASE_URL.
I tried also tried heroku addons:detach --app stb-crds-rails-sf $ADDON_NAME --as SHARETHEBUS_RAILS_DATABASE_URL and heroku addons:detach --app stb-crds-rails-sf $ADDON_NAME SHARETHEBUS_RAILS_DATABASE_URL, but the command-line says the last arguments are unexpected.
What are our options to remove the extra addons?

Turns out you can use the variable name instead of the addon name:
$ heroku addons:detach SHARETHEBUS_RAILS_DATABASE_URL

Related

How to add -a -app in my Websockets file?

I've got a problem when I upload my project on Heroku. I've trying changing value of socket.io and MongoUrl, but I get this error:
Error: Missing required flag:
› -a, --app APP app to run command against
This has nothing to do with any of your files. It's an argument that you must provide to the Heroku CLI itself, e.g.
heroku config:set SOME_VARIABLE=some_value -a myapp
where myapp is the name of your Heroku app.
The -a / --app argument is required when heroku can't figure out what app to connect to, either bcause there is no Heroku remote configured or because there is more than one Heroku remote configured.
See also How to avoid the --app option with heroku CLI?

Multiple apps in git remotes when trying to access rails console

I have two git branches, staging and production, and I deployed them on Heroku in the same Heroku acccount. Suppose my app names are app1.heroku-app.com and app2.heroku-app.com and the remote names are heroku-staging and heroku-production,respectively. I deployed both apps on Heroku. After I login to Heroku from the console using heroku login and then try to access a Rails console using heroku run rails c, I get this message :
▸ multiple apps in git remotes
▸ remotes: heroku-staging heroku-production
How can I access a console?
If there's only one Heroku remote, heroku can infer which you want. When there are multiple (or if you want to access an application that doesn't have a remote in this Git repo, or when you're not in a Git repo at all), you need to use the --app option to specify which application you want a console on.
$ heroku --help
Usage: heroku COMMAND [--app APP] [command-specific-options]
$ heroku run rails c --app app1
$ heroku run rails c --app app2
In addition to being able to specify the app as a per-command flag, if you'd like for there to be a default environment, setting the environment variable HEROKU_APP to the app you want will make it so that heroku commands don't rely on git config.
$ heroku logs
› Error: Multiple apps in git remotes
...
$ export HEROKU_APP=app1
$ heroku logs
2018-12-31T03:56:34.888350+00:00 app[web.1]: 1.2.3.4 ...

How can I deploy to a specific app with heroku docker:release?

Using the heroku docker:release command, how can I specify which app to release to? I can't see from any documentation whether there's any switch for this purpose.
Heroku commands take their context from the directory you are in when you run them.
Go into the directory from where you did heroku create then run heroku docker:release.
If you haven't used heroku create, then you can specify the app name with the --app <APP NAME> command line parameter. for instance, if you were to release to the app named f00 you would type:
heroku docker:release --app f00

Where did these Heroku apps come from?

I have created a local git repository called phantomjs123 and I'm trying to deploy to Heroku:
me#my-PC /f/EasyPHP-12.1/www/phantomjs123 (master)
$ heroku apps
=== My Apps
phantomjs123
protected-waters-9718
serene-mesa-1437
As you can see 2 additional apps have been created. I tried to delete them but when I do
me#my-PC /f/EasyPHP-12.1/www/phantomjs123 (master)
$ ls
bin nbproject procfile
They don't appear to exist locally. Can someone explain what these other apps are and how to remove them?
To destroy apps on Heroku you can do:
heroku apps:destroy <APPNAME>
Mind you, they would only exist as a result of doing a heroku create.

Heroku CLI: How to reference an app by custom domain? (Example in documentation not working)

Heroku's documentation on CLI says to do this (link):
If you have multiple heroku remotes or want to execute an app command outside of a local working copy, you can specify an explicit app name, domain, or git remote as follows:
$ heroku info --app myapp
$ heroku info --app www.example.com
$ heroku info --remote staging
However, I'm unable to get that second one to work. This is what I get:
$ heroku info --app foo
=== foo
[...]
$ heroku domains --app foo
Domain names for foo.herokuapp.com:
foo.example.com
$ heroku info --app foo.example.com
! Resource not found
At the very least, the documentation seems incorrect. But is it possible to reference an app by one of its custom domains another way?
Thanks!
Yep, I concur that - using the latest Heroku CLI all the methods work except using the domain name. Is there a particular reason why you want to use that way if the other ways work for you?

Resources