Skip to content

Commit dcad160

Browse files
committed
feat: Add user management resources and data sources
1 parent 3aa7f0b commit dcad160

File tree

22 files changed

+2910
-0
lines changed

22 files changed

+2910
-0
lines changed

docs/data-sources/user.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
page_title: "crowdstrike_user Data Source - crowdstrike"
3+
subcategory: "User"
4+
description: |-
5+
This data source provides information about an existing CrowdStrike user in the Falcon Console.
6+
API Scopes
7+
The following API scopes are required:
8+
User Management | Read & Write
9+
---
10+
11+
# crowdstrike_user (Data Source)
12+
13+
This data source provides information about an existing CrowdStrike user in the Falcon Console.
14+
15+
## API Scopes
16+
17+
The following API scopes are required:
18+
19+
- User Management | Read & Write
20+
21+
22+
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Optional
28+
29+
- `cid` (String) The CrowdStrike Customer ID (CID) where the existing user resides. If not assigned, the CID associated with the provider credentials will be used.
30+
- `uid` (String) The user's email address, which serves as their username. Either this or the UUID must be provided to locate an existing user.
31+
- `uuid` (String) Unique identifier assigned to the user by CrowdStrike. Either uid or uuid must be provided to find an existing user
32+
33+
### Read-Only
34+
35+
- `first_name` (String) First name of the user.
36+
- `last_name` (String) Last name of the user.

docs/data-sources/user_roles.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
page_title: "crowdstrike_user_roles Data Source - crowdstrike"
3+
subcategory: "User Roles"
4+
description: |-
5+
This data source retrieves available roles for a specified CID.
6+
API Scopes
7+
The following API scopes are required:
8+
User Management | Write
9+
---
10+
11+
# crowdstrike_user_roles (Data Source)
12+
13+
This data source retrieves available roles for a specified CID.
14+
15+
## API Scopes
16+
17+
The following API scopes are required:
18+
19+
- User Management | Write
20+
21+
22+
23+
24+
<!-- schema generated by tfplugindocs -->
25+
## Schema
26+
27+
### Optional
28+
29+
- `cid` (String) The CrowdStrike Customer ID (CID) associated with the user roles to be retrieved. If not specified, the CID associated with the provider credentials will be used.
30+
- `role_ids` (List of String) List of role IDs associated with the specified CID

docs/resources/user.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
page_title: "crowdstrike_user Resource - crowdstrike"
3+
subcategory: "User"
4+
description: |-
5+
This resource allows management of a user on the CrowdStrike Falcon Platform.
6+
Users represent the people who access the Falcon console to manage your Falcon environment. Every user account has a home CID. The home CID is where a user account is created, stored, and managed.
7+
For newly created users, the system automatically sends an email containing a link for password configuration, unless the user's CID employs Single Sign-On (SSO).
8+
API Scopes
9+
The following API scopes are required:
10+
User Management | Read & Write
11+
---
12+
13+
# crowdstrike_user (Resource)
14+
15+
This resource allows management of a user on the CrowdStrike Falcon Platform.
16+
17+
Users represent the people who access the Falcon console to manage your Falcon environment. Every user account has a home CID. The home CID is where a user account is created, stored, and managed.
18+
For newly created users, the system automatically sends an email containing a link for password configuration, unless the user's CID employs Single Sign-On (SSO).
19+
20+
## API Scopes
21+
22+
The following API scopes are required:
23+
24+
- User Management | Read & Write
25+
26+
27+
## Example Usage
28+
29+
```terraform
30+
terraform {
31+
required_providers {
32+
crowdstrike = {
33+
source = "registry.terraform.io/crowdstrike/crowdstrike"
34+
}
35+
}
36+
}
37+
38+
provider "crowdstrike" {
39+
cloud = "us-2"
40+
}
41+
42+
43+
resource "crowdstrike_user" "example" {
44+
45+
first_name = "FirstName"
46+
last_name = "LastName"
47+
cid = "ABCDEF0123456789ABCDEF0123456789"
48+
}
49+
50+
output "user_uuid" {
51+
value = crowdstrike_user.example.uuid
52+
}
53+
output "user_uid" {
54+
value = crowdstrike_user.example.uid
55+
}
56+
output "user_cid" {
57+
value = crowdstrike_user.example.cid
58+
}
59+
output "user_first_name" {
60+
value = crowdstrike_user.example.first_name
61+
}
62+
output "user_last_name" {
63+
value = crowdstrike_user.example.last_name
64+
}
65+
```
66+
67+
<!-- schema generated by tfplugindocs -->
68+
## Schema
69+
70+
### Required
71+
72+
- `first_name` (String) First name of the user.
73+
- `last_name` (String) Last name of the user.
74+
- `uid` (String) The username to assign to the user. This must be a valid email address. Either uid or uuid must be provided to find an existing user.
75+
76+
### Optional
77+
78+
- `cid` (String) The CrowdStrike Customer ID (CID) for user creation. If not specified, the CID associated with the provider credentials will be used.
79+
80+
### Read-Only
81+
82+
- `uuid` (String) Unique identifier assigned to the user by CrowdStrike.
83+
84+
## Import
85+
86+
Import is supported using the following syntax:
87+
88+
```shell
89+
# User can be imported by specifying the UUID.
90+
# The UUID can be found in the URL of the user's profile page within the Falcon UI via the query string.
91+
# Example:
92+
# https://falcon.crowdstrike.com/users-v2/?id=683adeb9-100a-43e6-8968-b2934ebe6a8b
93+
terraform import crowdstrike_user.example 683adeb9-100a-43e6-8968-b2934ebe6a8b
94+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
page_title: "crowdstrike_user_role_assignments Resource - crowdstrike"
3+
subcategory: "User Role Assignments"
4+
description: |-
5+
This resource manages user roles for an existing CrowdStrike userUser roles determine what a user can see and do in the Falcon console. Every Falcon user is required to have at least one role, which is assigned when a user account is created.
6+
User roles are granted at the CID level, and you can have different roles in each CID you're associated with. In each CID, you have access to all of the features that your roles allow.
7+
API Scopes
8+
The following API scopes are required:
9+
User Management | Read & Write
10+
---
11+
12+
# crowdstrike_user_role_assignments (Resource)
13+
14+
This resource manages user roles for an existing CrowdStrike userUser roles determine what a user can see and do in the Falcon console. Every Falcon user is required to have at least one role, which is assigned when a user account is created.
15+
User roles are granted at the CID level, and you can have different roles in each CID you're associated with. In each CID, you have access to all of the features that your roles allow.
16+
17+
## API Scopes
18+
19+
The following API scopes are required:
20+
21+
- User Management | Read & Write
22+
23+
24+
25+
26+
<!-- schema generated by tfplugindocs -->
27+
## Schema
28+
29+
### Required
30+
31+
- `assigned_role_ids` (Set of String) Roles to assign to the user. All available for a cid can be retrieved with the `crowdstrike_user_roles` data source
32+
33+
### Optional
34+
35+
- `cid` (String) The CrowdStrike Customer ID (CID) where the existing user resides. If not specified, the CID associated with the provider credentials will be used.
36+
- `skip_revoke_on_destroy` (Boolean) Retain user permissions upon resource deletion, bypassing the default revocation process
37+
- `uid` (String) The user's email address, which serves as their username. Either uid or uuid must be provided to find an existing user.
38+
- `uuid` (String) Unique identifier assigned to the user by CrowdStrike. Either uid or uuid must be provided to find an existing user.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
terraform {
2+
required_providers {
3+
crowdstrike = {
4+
source = "registry.terraform.io/crowdstrike/crowdstrike"
5+
}
6+
}
7+
}
8+
9+
provider "crowdstrike" {
10+
cloud = "us-2"
11+
}
12+
13+
14+
data "crowdstrike_user" "example" {
15+
uuid = "2db50655-9b58-4d63-9ddd-3edd6499f087"
16+
}
17+
18+
output "user_data_source_uuid" {
19+
value = data.crowdstrike_user.example.uuid
20+
}
21+
output "user_data_source_uid" {
22+
value = data.crowdstrike_user.example.uid
23+
}
24+
output "user_data_source_cid" {
25+
value = data.crowdstrike_user.example.cid
26+
}
27+
output "user_data_source_first_name" {
28+
value = data.crowdstrike_user.example.first_name
29+
}
30+
output "user_data_source_last_name" {
31+
value = data.crowdstrike_user.example.last_name
32+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
terraform {
2+
required_providers {
3+
crowdstrike = {
4+
source = "registry.terraform.io/crowdstrike/crowdstrike"
5+
}
6+
}
7+
}
8+
9+
provider "crowdstrike" {
10+
cloud = "us-2"
11+
}
12+
13+
14+
data "crowdstrike_user_roles" "all" {}
15+
16+
# Filter all roles that contain read or guest
17+
output "user_data_source" {
18+
value = [for role in data.crowdstrike_user_roles.all.role_ids : role if can(regex("(read|guest)", role))]
19+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# User can be imported by specifying the UUID.
2+
# The UUID can be found in the URL of the user's profile page within the Falcon UI via the query string.
3+
# Example:
4+
# https://falcon.crowdstrike.com/users-v2/?id=683adeb9-100a-43e6-8968-b2934ebe6a8b
5+
terraform import crowdstrike_user.example 683adeb9-100a-43e6-8968-b2934ebe6a8b
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
terraform {
2+
required_providers {
3+
crowdstrike = {
4+
source = "registry.terraform.io/crowdstrike/crowdstrike"
5+
}
6+
}
7+
}
8+
9+
provider "crowdstrike" {
10+
cloud = "us-2"
11+
}
12+
13+
14+
resource "crowdstrike_user" "example" {
15+
16+
first_name = "FirstName"
17+
last_name = "LastName"
18+
cid = "ABCDEF0123456789ABCDEF0123456789"
19+
}
20+
21+
output "user_uuid" {
22+
value = crowdstrike_user.example.uuid
23+
}
24+
output "user_uid" {
25+
value = crowdstrike_user.example.uid
26+
}
27+
output "user_cid" {
28+
value = crowdstrike_user.example.cid
29+
}
30+
output "user_first_name" {
31+
value = crowdstrike_user.example.first_name
32+
}
33+
output "user_last_name" {
34+
value = crowdstrike_user.example.last_name
35+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Import existing User Role Assignment by specifying the user's UUID followed by their assigned roles, separated by commas
2+
terraform import crowdstrike_user_role_assignments.example "2db50655-9b58-4d63-9ddd-3edd6499f087,falcon_console_guest,image_viewer"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
terraform {
2+
required_providers {
3+
crowdstrike = {
4+
source = "registry.terraform.io/crowdstrike/crowdstrike"
5+
}
6+
}
7+
}
8+
9+
provider "crowdstrike" {
10+
cloud = "us-2"
11+
}
12+
13+
locals {
14+
// Get all read and guest roles
15+
read_guest_roles = [for role in data.crowdstrike_user_roles.all.role_ids : role if can(regex("(read|guest)", role))]
16+
}
17+
18+
data "crowdstrike_user_roles" "all" {}
19+
20+
resource "crowdstrike_user" "example" {
21+
22+
first_name = "FirstName"
23+
last_name = "LastName"
24+
cid = "ABCDEF0123456789ABCDEF0123456789"
25+
}
26+
27+
resource "crowdstrike_user_role_assignments" "example" {
28+
uuid = crowdstrike_user.example.uuid
29+
assigned_role_ids = local.read_guest_roles
30+
depends_on = [crowdstrike_user.example]
31+
}
32+
33+
output "user_role_assignments" {
34+
value = crowdstrike_user_role_grant.example
35+
}

0 commit comments

Comments
 (0)