Open Jefferson-Faseler opened 5 years ago
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.
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?
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
}
}
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.
@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.
Terraform Version
Terraform v0.12.7
Heroku Provider Version
Affected Resource(s)
Please list the resources as a list, for example:
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.