Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

heroku_addon follower option for dbs #236

Open
Jefferson-Faseler opened this issue Aug 28, 2019 · 6 comments
Open

heroku_addon follower option for dbs #236

Jefferson-Faseler opened this issue Aug 28, 2019 · 6 comments
Labels
Heroku API Support Ticket/PR is blocked on the Heroku API supporting the use case

Comments

@Jefferson-Faseler
Copy link

Terraform Version

Terraform v0.12.7

Heroku Provider Version

  • provider.heroku v2.1.2

Affected Resource(s)

Please list the resources as a list, for example:

  • heroku_addon
  • heroku_addon_attachment

Right now our configuration is ignorant that we would want to create our databases as followers when running an apply step.

I've searched documentation and looking at the relevant go file it doesn't seem to be possible at the moment.

This of course could be a very important feature. Ideally it could be something that also allows it to be used with a second app like the CLI docs describe.

@mars mars added the Heroku API Support Ticket/PR is blocked on the Heroku API supporting the use case label Aug 31, 2019
@mars
Copy link
Member

mars commented Aug 31, 2019

Unfortunately the Heroku Data APIs to perform these operations is not GA (generally available).

Our policy with this provider is to only use GA, officially documented and maintained Heroku APIs.

@oboxodo
Copy link

oboxodo commented Oct 28, 2022

I second this request. I understand Heroku doesn't want to use non-GA APIs from the provider then... I'd ask for the required APIs to be made GA first :).

In the meantime... should I expect any undesired side-effects if I create a follower using Heroku's CLI, then import it to terraform's state as a managed resource?

@oboxodo
Copy link

oboxodo commented Oct 28, 2022

Actually... I was able to create a follower from Terraform in my tests.

USE THIS AT YOUR OWN RISK UNTIL SOMEONE FROM HEROKU CONFIRMS

resource "heroku_addon" "follower-database" {
  app_id = heroku_app.my_app.id
  plan = "heroku-postgresql:standard-2"
  config = {
    follow: "postgresql-xxxxxx-12345" # Here goes the name of the DB addon you want to follow
  }
}

@mars
Copy link
Member

mars commented Oct 28, 2022

That's a clever find @oboxodo 😄 🙌

Those config options only effect the add-on at creation, and so are forceNew in the provider schema.

Meaning that changing that config.follow value later would destructively replace the database add-on 💥 Terraform will of course warn you in its plan.

I'd recommend leaving that follow option out of Terraform, so that it's not a bit of config that drifts, and then maybe causes someone to "fix" and accidentally delete the existing database.

@oboxodo
Copy link

oboxodo commented Oct 28, 2022

@mars haha. Yes. Thanks for your fast reply!

I learned that after creating the follower. The following plan didn't know anything about it being a follower and wanted to replace it. But it got solved by commenting that config portion after the DB was already created. So I'm safe. Haha.

One important thing to consider is that the apply will keep running until the follower finishes provisioning and that can take a long time depending on the DB size. My first try was OK but on the 2nd try on a bigger DB it took over 20 minutes to finish and terraform timedout. So I ended up adding this:

provider "heroku" {
  timeouts {
    addon_create_timeout = 35 # Defaults to 20 minutes but some tasks like creating a follower DB can create longer.
  }
}

I'LL REPEAT MYSELF HERE: USE THIS AT YOUR OWN RISK.

@davidji99
Copy link
Collaborator

davidji99 commented Oct 28, 2022

Just as an FYI, I attempted to model PG follower as a resource here but it got quite complex, so I gave up.

One thing I remembered was how to handle when a follower is promoted to primary, which would be an out-of-band change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Heroku API Support Ticket/PR is blocked on the Heroku API supporting the use case
Projects
None yet
Development

No branches or pull requests

4 participants