dbt-labs / terraform-provider-dbtcloud

dbt Cloud Terraform Provider
https://registry.terraform.io/providers/dbt-labs/dbtcloud
MIT License
82 stars 19 forks source link

Fetch `deploy_key` on repository creation #85

Closed mittonface closed 1 year ago

mittonface commented 1 year ago

For one of my projects I'm able to more fully automate my infrastructure if I can retrieve the public key from DBT. Through a bit of snooping how DBT builds their own pages I found that you can do this by passing ?include_related=['deploy_key'] on the repositories endpoint.

I've not worked on a terraform provider before, so this was a bit of guesswork on my part. Ideally I don't think you'd want to include this new query-parameter all of the time.

Happy to clean this up & write some tests if you want to give some feedback.

GtheSheep commented 1 year ago

Hey! Thanks so much for submitting this! Just a couple of questions:

thanks so much for taking the time to do this! 🥳

mittonface commented 1 year ago

The way that I'm intending to use this is so that DBT can automatically gain read-access to a private bitbucket repo. In my TF I will take this deploy key and pass it through a bitbucket provider and automate that setup.

I've got a few more sprint obligations to get through, but I'll try to take your feedback and tidy things up a bit in the next few days/week.

(feel free to get rid of my Draft PR if you don't want it junking up your repo until I'm ready to go)

mittonface commented 1 year ago

Made the changes that you suggested.

I do think setting a parameter to decide whether or not to retrieve the key feels a little clumsy, but I'm not sure of any other solutions. Seems to all be working, though I stumbled my way through it a bit.

GtheSheep commented 1 year ago

/ok-to-test sha=9bebc413e97142f8339ce47d89a5764d18260643

GtheSheep commented 1 year ago

compile failing here

mittonface commented 1 year ago

⁉️ weird! I ran acceptance and unit tests locally. Let me take another look!

GtheSheep commented 1 year ago

/ok-to-test sha=d727675fe8d966a11faaf9887ee2553341059922