Skip to content

Commit e782e5c

Browse files
giacomosirriGnoale
andauthored
feat(iam): creation of user as Member (#3029)
* Distinguish between Member users and Guest users in user creation * Add all API parameters to resource schema * Complete implementation of user creation * Add fields to user read function * Fix schema of some parameters * Reimplement acceptance tests to test creation for both user types * Complete acceptance tests * Add comments * Final test runs: no errors * Update docs * Update CRUD operations for the User resource to reflect changes in the API * Fix typo in docs * Update acceptance tests * Add support for username update * Remove ForceNew from Email field definition * Update and run acceptance tests * Update docs * fix linting issues --------- Co-authored-by: Guillaume Noale <[email protected]>
1 parent ee4eaf3 commit e782e5c

File tree

5 files changed

+1093
-217
lines changed

5 files changed

+1093
-217
lines changed

docs/resources/iam_user.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,29 @@ For more information, see the [API documentation](https://www.scaleway.com/en/de
1010

1111
## Example Usage
1212

13-
### Basic
13+
### Guest user
1414

1515
```terraform
16-
resource "scaleway_iam_user" "basic" {
17-
16+
resource "scaleway_iam_user" "guest" {
17+
18+
tags = ["test-tag"]
1819
}
1920
```
2021

22+
### Member user
23+
24+
```terraform
25+
resource "scaleway_iam_user" "member" {
26+
27+
tags = ["test-tag"]
28+
username = "foo"
29+
first_name = "Foo"
30+
last_name = "Bar"
31+
}
32+
```
33+
34+
When `username` is set, the user is created as a [Member](https://www.scaleway.com/en/docs/iam/concepts/#member). Otherwise, it is created as a [Guest](https://www.scaleway.com/en/docs/iam/concepts/#guest).
35+
2136
### Multiple users
2237

2338
```terraform
@@ -28,35 +43,52 @@ locals {
2843
])
2944
}
3045
31-
resource scaleway_iam_user user {
46+
resource "scaleway_iam_user" "user" {
3247
for_each = local.users
3348
email = each.key
3449
}
3550
```
3651

3752
## Argument Reference
3853

39-
- `email` - (Required) The email of the IAM user.
54+
- `organization_id` - (Defaults to [provider](../index.md#organization_id) `organization_id`) The ID of the organization the user is associated with.
55+
56+
- `email` - (Required) The email of the IAM user. For Guest users, this argument is not editable.
4057

4158
- `tags` - (Optional) The tags associated with the user.
4259

43-
- `organization_id` - (Defaults to [provider](../index.md#organization_d) `organization_id`) The ID of the organization the user is associated with.
60+
- `username` - (Optional) The username of the IAM user. When it is set, the user is created as a Member. When it is not set, the user is created as a Guest and the username is set as equal to the email.
61+
62+
- `password` - The password for first access.
63+
64+
- `send_password_email` - Whether or not to send an email containing the password for first access.
65+
66+
- `send_welcome_email` - Whether or not to send a welcome email that includes onboarding information.
67+
68+
- `first_name` - The user's first name.
69+
70+
- `last_name` - The user's last name.
71+
72+
- `phone_number` - The user's phone number.
73+
74+
- `locale` - The user's locale (e.g., en_US).
75+
76+
Important: When creating a Guest user, all arguments are ignored, except for `organization_id`, `email` and `tags`.
4477

4578
## Attributes Reference
4679

4780
In addition to all arguments above, the following attributes are exported:
4881

4982
- `id` - The ID of the user (UUID format).
50-
- `email` - The email of the user
5183
- `created_at` - The date and time of the creation of the IAM user.
5284
- `updated_at` - The date and time of the last update of the IAM user.
5385
- `deletable` - Whether the IAM user is deletable.
54-
- `organization_id` - The ID of the organization the user.
5586
- `last_login_at` - The date of the last login.
5687
- `type` - The type of user. Check the possible values in the [API doc](https://www.scaleway.com/en/developers/api/iam/#path-users-get-a-given-user).
5788
- `status` - The status of user invitation. Check the possible values in the [API doc](https://www.scaleway.com/en/developers/api/iam/#path-users-get-a-given-user).
5889
- `mfa` - Whether the MFA is enabled.
5990
- `account_root_user_id` - The ID of the account root user associated with the user.
91+
- `locked` - Whether the user is locked.
6092

6193
## Import
6294

0 commit comments

Comments
 (0)