generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Affected Data source
- data.astra_database
Expected Behavior
Allow lookup of database by name. I am currently looking up databases via data.astra_databases but this has the problem that it does not fail if at least one database is present in the organization and leads to code like:
locals {
database_id_tmp = join("", [for db in data.astra_databases.list.results : db.id if db.name == var.database_name])
database_id = local.database_id_tmp != "" ? local.database_id_tmp : "00000000-0000-0000-0000-000000000000"
}
which has the issue that:
- when database does not exist, database_id_tmp is empty so all places where you would use it, like other astra resources, they fail at the validation step because they expect the database_id to be in UUID format.
- I "fixed" this by using "00000000-0000-0000-0000-000000000000" which created even more fun failure scenarios on the provider.
A data structure would fail directly if the DB does not exist and would "propagate" the error to the rest of terraform, without that there's no clear error and in some cases you end up with an API call with thedatabase_id = "00000000-0000-0000-0000-000000000000"
which fails with another cryptic error.
Important Factoids
The API only supports lookup using the DB id and database name may not be enforced to be unique so this may not be possible. Implementing this by enumerating all the databases and selecting the one matching the name might be too inefficient.
References
┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: TERRA-68
┆priority: Major
devopsmatt
Metadata
Metadata
Assignees
Labels
No labels