Skip to content
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

Reference/Create New Project by Name Rather than ID #121

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jmarhee
Copy link
Contributor

@jmarhee jmarhee commented Mar 21, 2024

Convenience update: rather than needing the ID, user can specify (or define for creation) a project by its name rather than ID (and then ID is rendered via datasource). Changes variable from project_id to project_name and updates module accordingly.

…t exist, references it via datasource if it does.

Signed-off-by: Joseph Marhee <[email protected]>
@jmarhee jmarhee force-pushed the reference-or-create-project-name branch from 9566671 to ee9dd02 Compare March 21, 2024 17:49
@displague
Copy link
Member

displague commented Mar 21, 2024

Is this related to needs of https://github.com/rancherlabs/harvester-equinix-terraform?

@displague
Copy link
Member

displague commented Mar 21, 2024

A variable named equinix_metal_project_name exists and could be used. Doing so could keep the project_id variable intact and used as an alternative for the datasource (lookup by id OR name -- https://developer.hashicorp.com/terraform/language/expressions/custom-conditions#input-variable-validation).

Project names are not necessarily unique. If the user supplied a non-unique name the TF provider would throw an error, which would be the correct behavior for this scenario.

@jmarhee
Copy link
Contributor Author

jmarhee commented Mar 21, 2024

Got it. I didn't realize the project names themselves were not unique (and for some reason did not catch the existing variable!)-- I put this together thinking it'd be convenient so if there's that other better approach that can be worked with (as you noted), then that seems more than sufficient and we can close this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants