kislerdm / terraform-provider-neon

Terraform provider to manage Neon SaaS resources
https://registry.terraform.io/providers/kislerdm/neon/latest/docs
Mozilla Public License 2.0
35 stars 13 forks source link

Data resources #22

Closed analytically closed 7 months ago

analytically commented 1 year ago

Would be good to have data resources to read out Neon parameters from the API for existing resources.

Eg.

data.neon_project.database_host
kislerdm commented 1 year ago

@analytically Hey Mathias, thanks a lot for approaching. Would resource import suffice the use case?

For example, in the case of project:

terraform import neon_project.foo my-project-id

One can access the host this way:

resource "neon_project" "foo" {
  name = "my project"
}

output "host" {
  value = neon_project.foo.database_host
}
barathvk commented 9 months ago

@kislerdm they serve a bit of a different purpose. For example, if I have a project that is managed elsewhere, but would like to get the main branch ID for a database so I can branch from it, but I don't actually manage the database, it would be very useful to be able to query for the database id and the branch id, but not make any changes to the project (because I don't own or manage it), data sources will be very useful. Could please consider reopening this issue?

kislerdm commented 9 months ago

@barathvk Hey! What is the advantage of a data source compared to a variable in your example?

barathvk commented 8 months ago

Thanks for reopening the issue! let's say I need the default_branch_id of a project someone else on anther team owns, if the project is recreated, the default_branch_id will change and I won't know. If it was a data source, on the other hand, i only need to know the project name, which is controlled by my colleagues team which owns the project, unlike defaulr_branch_id

kislerdm commented 8 months ago

@barathvk thanks for illustration - I accept the request on its basis. Would you like to contribute to the project and implement the data source(s) relevant for your use cases? Thanks!