You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[FEAT] Support looking up github_membership data source by user_id
Add an optional 'user_id' input (mutually exclusive with 'username') to the
github_membership data source. When set, the user is resolved via
GET /user/{id} and the resulting login is used to query the org
membership endpoint, which only accepts logins.
The data source now always exposes 'user_id' as a computed attribute too,
so downstream resources can refer to the stable numeric ID even when the
query used a login.
Refs #524
Copy file name to clipboardExpand all lines: docs/data-sources/membership.md
+19-3Lines changed: 19 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,15 +16,31 @@ data "github_membership" "membership_for_some_user" {
16
16
}
17
17
```
18
18
19
+
### Lookup by stable user ID
20
+
21
+
```terraform
22
+
# Look up a membership by the stable GitHub user ID.
23
+
# The numeric ID does not change when the user renames their account.
24
+
data "github_membership" "by_user_id" {
25
+
user_id = 1
26
+
}
27
+
```
28
+
19
29
## Argument Reference
20
30
21
-
-`username` - (Required) The username to lookup in the organization.
31
+
Exactly one of the following must be set:
32
+
33
+
-`username` - (Optional) The username (login) to lookup in the organization.
34
+
-`user_id` - (Optional) The GitHub numeric user ID. Stable across username changes; prefer this for lookups that should survive renames.
35
+
36
+
Other arguments:
22
37
23
-
-`organization` - (Optional) The organization to check for the above username.
38
+
-`organization` - (Optional) The organization to check for the above user.
24
39
25
40
## Attributes Reference
26
41
27
-
-`username` - The username.
42
+
-`username` - The username (login). Always reflects the user's current login at refresh time.
43
+
-`user_id` - The GitHub numeric user ID.
28
44
-`role` - `admin` or `member` -- the role the user has within the organization.
29
45
-`etag` - An etag representing the membership object.
30
46
-`state` - `active` or `pending` -- the state of membership within the organization. `active` if the member has accepted the invite, or `pending` if the invite is still pending.
Description: "The username (login) to lookup in the organization. Exactly one of `username` or `user_id` must be set.",
21
+
},
22
+
"user_id": {
23
+
Type: schema.TypeInt,
24
+
Optional: true,
25
+
Computed: true,
26
+
ExactlyOneOf: []string{"username", "user_id"},
27
+
Description: "The GitHub numeric user ID to lookup in the organization. Stable across username changes. Exactly one of `username` or `user_id` must be set.",
- `username` - (Required) The username to lookup in the organization.
21
+
Exactly one of the following must be set:
22
+
23
+
- `username` - (Optional) The username (login) to lookup in the organization.
24
+
- `user_id` - (Optional) The GitHub numeric user ID. Stable across username changes; prefer this for lookups that should survive renames.
25
+
26
+
Other arguments:
18
27
19
-
- `organization` - (Optional) The organization to check for the above username.
28
+
- `organization` - (Optional) The organization to check for the above user.
20
29
21
30
## Attributes Reference
22
31
23
-
- `username` - The username.
32
+
- `username` - The username (login). Always reflects the user's current login at refresh time.
33
+
- `user_id` - The GitHub numeric user ID.
24
34
- `role` - `admin`or`member` -- the role the user has within the organization.
25
35
- `etag` - An etag representing the membership object.
26
36
- `state` - `active`or`pending` -- the state of membership within the organization.`active`if the member has accepted the invite, or`pending`if the invite is still pending.
0 commit comments