Skip to content

Commit

Permalink
Add create_okta_user_assign_to_group mod (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
karanpopat authored Dec 5, 2023
1 parent bb62991 commit d9a84ef
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 0 deletions.
16 changes: 16 additions & 0 deletions create_okta_user_assign_to_group/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Create a user in Okta and assign to a group

Create a user in Okta and assign to a group.

## Usage

- Add following required credentials to `flowpipe.fpvars`
- Okta domain and API token

- Start your Flowpipe server `flowpipe server`

- Create a user in Okta and add to a group. This step is an independent pipeline to create user and assign to a group e.g.

```
flowpipe pipeline run create_okta_user_assign_to_group --arg first_name='Foo' --arg last_name='Bar' --arg email='[email protected]' --arg login='foo.bar' --arg password='password' --arg group_id='00g1x2x3x4x5x6x7x8x9'
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
pipeline "create_okta_user_assign_to_group" {
title = "Create User Assign Group"
description = "Create a user and assign it to a group."

param "api_token" {
description = "The personal api_token to authenticate to the Okta APIs."
type = string
default = var.api_token
}

param "domain" {
description = "The domain of your Okta account."
type = string
default = var.domain
}

param "first_name" {
description = "Given name of the user."
type = string
}

param "last_name" {
description = "The family name of the user."
type = string
}

param "email" {
description = "The primary email address of the user."
type = string
}

param "login" {
description = "The unique identifier for the user."
type = string
}

param "password" {
description = "Specifies the password for a user."
type = string
}

param "group_id" {
description = "The ID of the group."
type = string
}

step "pipeline" "create_user" {
pipeline = okta.pipeline.create_user
args = {
api_token = param.api_token
domain = param.domain
first_name = param.first_name
last_name = param.last_name
email = param.email
login = param.login
password = param.password
}
}

step "pipeline" "assign_user" {
pipeline = okta.pipeline.assign_user
args = {
api_token = param.api_token
domain = param.domain
group_id = param.group_id
user_id = step.pipeline.create_user.output.user.id
}
}

step "pipeline" "list_member_users" {
depends_on = [step.pipeline.assign_user]

pipeline = okta.pipeline.list_member_users
args = {
api_token = param.api_token
domain = param.domain
group_id = param.group_id
}
}

output "user" {
description = "User details."
value = step.pipeline.create_user.output
}

output "group_members" {
description = "List of users that are members of the group."
value = step.pipeline.list_member_users.output
}
}
8 changes: 8 additions & 0 deletions create_okta_user_assign_to_group/flowpipe.fpvars.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
domain = "<Domain>"
api_token = "<API Token>"
group_id = "<Group ID>"
first_name = "<First Name>"
last_name = "<Last Name>"
email = "<Email>"
login = "<Username>"
password = "<Password>"
14 changes: 14 additions & 0 deletions create_okta_user_assign_to_group/mod.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod "create_okta_user_assign_to_group" {
title = "Create User and Assign Group"
description = "Create a user in Okta and assign to a group."

require {
mod "github.com/turbot/flowpipe-mod-okta" {
version = "v0.0.2-rc.2"
args = {
api_token = var.api_token
domain = var.domain
}
}
}
}
9 changes: 9 additions & 0 deletions create_okta_user_assign_to_group/variables.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "domain" {
type = string
description = "The URL of the Okta domain. Exmaple: 'https://dev-50078045.okta.com'"
}

variable "api_token" {
type = string
description = "The Okta personal access api_token to authenticate to the Okta APIs, e.g., '00B630jSCGU4jV4o5Yh4KQMAdqizwE2OgVcS7N9UHb'. Please see https://developer.okta.com/docs/guides/create-an-api-api_token/main/#oauth-2-0-instead-of-api-api_tokens for more information."
}

0 comments on commit d9a84ef

Please sign in to comment.