netlify / terraform-provider-netlify

MIT License
1 stars 2 forks source link

Support for creating deploy_key #40

Open janario opened 1 month ago

janario commented 1 month ago

As in the rest resources https://open-api.netlify.com/#tag/deployKey

It would be great to have this with terraform, so it would simplify a lot our infra provisioning.

e.g.

resource "netlify_deploy_key" "key" {
  # if any custom param? but I guess the create doesn't need any
}

# easy integrate my gitlab
resource "gitlab_deploy_key" "netlify_key" {
  project = "my-gitlab-project"
  title   = "Netlify deployment key"
  key     = netlify_deploy_key.key.public_key # allows the just created key to access my-gitlab-project
}
ramonsnir commented 1 month ago

Sites should be created with at least one deploy key, in most/all flows. You can query that key using data.netlify_site: https://registry.terraform.io/providers/netlify/netlify/latest/docs/data-sources/site#git_deploy_key

Would that be sufficient for your use case?

janario commented 1 month ago

That would work also, but in our case we have a monorepo with around 30 sites, so I guess it would result in 30 deploy keys right?

So far we used other unofficial providers to do the 1 deploy_key all 30 sites with the same key and our gitlab repo with this 1 key.

ramonsnir commented 1 month ago

I see. So the key part of this is the ability to set the deploy key of a site to an existing one, and not the creation itself of keys. Makes sense!

janario commented 1 month ago

For our scenario create a deploy key and reuse in other resources Gitlab repo and all the 30 sites creation with the same deploy key.