Issue
I'm trying to promote a secondary/shared Heroku Redis instance on my app but I see the below error:
! REDIS on app-name is the last billing attachment to
! existing-redis-instance; either remove the add-on entirely or add a new
! attachment to it before replacing its config vars.
Resolution
This is a tricky situation as the add-on would require at least one attachment as an app for billing purposes but when you try to promote the secondary/shared instance in order to make it primary, it would overwrite the REDIS_URL
attachment which is currently used as the only attachment for the existing one.
heroku-redis (redis-sinuous-12345) premium-0 $15/month created
- as REDIS
heroku-redis (redis-convex-67890) premium-0 (billed to shared app) created
- as HEROKU_REDIS_RED
- as REDIS on shared app
As this instance (redis-sinuous-12345
) wouldn't have any other attachments left, it would become orphaned and hence, this action isn't allowed to perform by the Heroku CLI.
To workaround this situation, you can attach the old add-on (redis-sinuous-12345
) to the same app with a new attachment name using the addons:attach
command. This would give it an extra attachment to the add-on along with the current one (REDIS_URL
/REDIS
) and once this is in place, you should be able to promote the shared add-on redis-convex-67890
.
Please find the steps below-
- Attach the old add-on using:
heroku addons:attach redis-sinuous-12345 --as OLD_REDIS -a app-name
. - Run
heroku addons -a app-name
to check both the add-ons have two attachments.
heroku-redis (redis-sinuous-12345) premium-0 $15/month created
- as REDIS
- as OLD_REDIS
heroku-redis (redis-convex-67890) premium-0 (billed to shared app) created
- as HEROKU_REDIS_RED
- as REDIS on shared app
- Promote the shared instance:
heroku redis:promote redis-convex-67890 -a app-name
.
This should now have your shared instance promoted as REDIS_URL
(same as REDIS
) on your app. The old add-on would now still reside on your app with the attachment name OLD_REDIS
. This can be checked using the command heroku addons -a app-name
.
heroku-redis (redis-sinuous-12345) premium-0 $15/month created
- as OLD_REDIS
heroku-redis (redis-convex-67890) premium-0 (billed to shared app) created
- as HEROKU_REDIS_RED
- as REDIS
- as REDIS on shared app
You can replace OLD_REDIS
with any name of your choice in the above command but ensure to have it in uppercase.