spacelift-io / terraform-provider-spacelift

Terraform provider to interact with Spacelift
MIT License
74 stars 28 forks source link

Missing spacelift_user data source #548

Open HighwayofLife opened 4 months ago

HighwayofLife commented 4 months ago

Description:

Currently, the Spacelift Terraform Provider lacks a spacelift_user data source, which would allow users to retrieve information about existing Spacelift users. Adding this data source would enable users to manage existing users/policy mapping more efficiently and avoid potential conflicts when importing them into Terraform management.

Use Case:

When managing Spacelift users with Terraform, it is common to have a mix of existing users and new users. In order to properly manage existing users, it is necessary to retrieve their information from Spacelift and use it in the Terraform configuration. Without a spacelift_user data source, users are forced to manually provide the necessary information with a custom python script to retrieve the users through the GraphQL API, which is error-prone and inefficient.

Proposed Solution:

Implement a new data source called spacelift_user in the Spacelift Terraform Provider. This data source should allow users to retrieve information about existing Spacelift users based on their username or email address.

Proposed Attributes:

Example Usage:

data "spacelift_user" "existing_user" {
  username = "user@example.com"
}

output "existing_user_id" {
  value = data.spacelift_user.existing_user.id
}

output "existing_user_policy" {
  value = data.spacelift_user.existing_user.policy
}

Benefits: