Skip to content

Commit 7122cf0

Browse files
committed
Add support for importing users
Here we add basic support for importing users to state. Ideally we would be able to import by username, as there is an api to find users by username[1], but this is not currently exposed by go-gitlab[2] Towards #36 [1] https://docs.gitlab.com/ee/api/users.html#list-users documents /users?username=:username which worked well in manual testing. [2] https://github.com/xanzy/go-gitlab/blob/master/users.go#L97-L99
1 parent 3ac5a0c commit 7122cf0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gitlab/resource_gitlab_user.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ func resourceGitlabUser() *schema.Resource {
1515
Read: resourceGitlabUserRead,
1616
Update: resourceGitlabUserUpdate,
1717
Delete: resourceGitlabUserDelete,
18+
Importer: &schema.ResourceImporter{
19+
State: schema.ImportStatePassthrough,
20+
},
1821

1922
Schema: map[string]*schema.Schema{
2023
"username": {

website/docs/r/user.html.markdown

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,11 @@ for the user.
5151
The resource exports the following attributes:
5252

5353
* `id` - The unique id assigned to the user by the GitLab server.
54+
55+
## Importing users
56+
57+
You can import a user to terraform state using `terraform import <resource> <id>`.
58+
The `id` must be an integer for the id of the user you want to import,
59+
for example:
60+
61+
terraform import gitlab_user.example 42

0 commit comments

Comments
 (0)