-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TERRA-68 ⁃ Add support for database lookup via database name #144
Comments
That is currently the case. You can create any number of databases with the exact same name as they are given a unique UUID at creation. This UUID is the only way to identify them in the DevOps API, so the provider can't really guarantee the names will be unique. In your example, you have |
The use case you are describing works fine when there is a single root Terraform module that controls everything but it gets complicated when there are several in a company that has separate teams for cloud, networking, backing services/applications. Each team manages their own bit of infrastructure (which gets deployed in separate CI/CD pipelines):
Tags on resources would also help to identify them without having to resort to implementing namespaces in the database name because otherwise how would I be able to differentiate between two identical named resources? Even now if someone creates a database with the exact same name (say "db-name"), my db lookup would basically fail because it would return "db-namedb-name". If you go the way of:
and return the 1st one that fails if there is no match. If we return the array then the rest of the code still cannot decide which one is correct based just on the name. I know there are solutions like storing the database_id somewhere associated with the name and looking it up in that way, but then this becomes a copy of the information and not the authoritative information which can lead to problems. |
@muresan Apologies for letting this fall off my radar.
I understand separating responsibilities, but not sharing the piece of information that uniquely identifies a DB is wrong in my opinion. As you mention, there are things that can be done to try to figure out the ID from the name, but there are no guarantees you will get the correct ID if there are duplicates. Tags/namespaces would also just be extra pieces added to work around not sharing the already existing unique ID.
We could implement a data source (ex. |
That is my point, I want to share information that uniquely identifies a DB: a name + tags, not a UUID. To make an analogy, in AWS you would not share instance IDs, VPC IDs, you would share the tags on them which uniquely identify that resource.
Most clouds that manage their own IDs have implemented solutions for this, either by enforcing a unique name for the resource or by allowing the resource creator to add metadata to the resource to uniquely identify the resource after creation. I want to avoid creating dependencies between pipelines by forcing one to use the output from the other, because those pipelines run in separate environments and potentially in completely separate CI/CD instances. I know there are lots of options on how to share that information but it only introduces another service dependency (GCS Secrets Manager for example) that needs to be managed and that potentially has outdated information.
I don't think you store the token ID in the state so changes to the token ID should not impact existing resources. The ORG ID has a longer life than a database and most tokens should be ephemeral, there should not be any constraint preventing me from using a different token (for security) for every single terraform run. |
Affected Data source
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:
which has the issue that:
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 the
database_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
https://docs.datastax.com/en/astra/docs/_attachments/devopsv2.html#tag/Database-Operations/operation/getDatabase
┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: TERRA-68
┆priority: Major
The text was updated successfully, but these errors were encountered: