Skip to content

noinarisak/okta-terraformer-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Okta ❀️ Terraformer

Simple demos showcasing Okta and Terraformer( Reverse Terraform). The intended audience for this repo are for practitioners who are familiar with Terraform and Okta. Please review this introduction on Terraform and of course more info on Okta if you are not. My other Okta Terraform Demo is quick walk-through to get you started.

Table of Contents

Pre Req

  • Okta Tenant - Free Development tenant here.
  • Terraform - Install docs here and introduction here.
  • Terraformer - Install docs here.
  • (Optional, but highly recommended) tfenv - Terraform Version Manager πŸŽ‰
  • (Optional, but highly recommended) dotenv - Best environment variable tool for command-line ninja.

Quick Start

NOTE: Please review Terraformer Okta supported resources at the following link. The contributors are continuously adding and fixing resources to align in parity to the Terraform Okta Provider. Issues and feature request can be submitted on the main repo.

Tools

NOTE: It is subtle but names of the commandline tools are terraform and terraformer which are two commandline applications.

Validate install:

# Show version
$ terraform version

# Output
ie.
Terraform v1.0.9
on darwin_amd64
+ provider registry.terraform.io/okta/okta v3.15.0
...

# List of help details
$ terraform help
# Show version
$ terraformer -v

# Output
ie.
version v0.8.17

Setup Steps for Demo

Setup a developer Okta Org and create a API Token.

  1. Setup developer Okta Org at developer.okta.com.
  2. Activate your Okta Org and then go to the Dashboard.
  3. On the Dashboard screen, navigate API menu and select Tokens.
  4. On the API screen, click Create Token and name your API Token.
  5. Copy and store the generated token so you can use this backend.config file later.
  6. Make note of your Okta Org url. (ie. dev-302083.okta.com) you need this later too.

Setting your commandline environment, which I'm using direnv and copy and update .envrc.sample to have .envrc file containing Okta information.

  1. Validate direnv is installed.
$ direnv version

ie.
2.28.0
  1. Copy and update the .envrc.sample file using your favorite editor. I'm using VIM.
$ cp .envrc.sample .envrc

$ vim .envrc

# Update the file, etc

# Should look similar to this.
$ cat .envrc
# Okta Tenant ie https://dev-1537305.okta.com or https://dev-1537305.oktapreview.com
export OKTA_API_TOKEN=00e...
export OKTA_ORG_NAME=dev-1537305
export OKTA_BASE_URL=okta.com
  1. Now load environment variable to only this directory with direnv tool.
$ direnv allow .

# Output
# ie.
# direnv: loading /xdata/_prj/okta-terrafomer-demo/.envrc
# direnv: export +OKTA_API_TOKEN +OKTA_BASE_URL +OKTA_ORG_NAME

This demo walk-through expects a existing Okta org/tenant that contains a few supporting resources like: Oauth/OIDC apps, users, groups, etc.

Prepare for extraction

  1. Create okta.tf or use the only in this repo.
$ cat okta.tf

# Output
# ie.
# # This all you need to start with Terraformer to extract Okta resource from your Okta tenant.
# terraform {
#   required_providers {
#     okta = {
#       source  = "okta/okta",
#       version = "~> 3.13"
#     }
#   }
# }

# provider "okta" {
# }%
  1. Install terraform binary and use version that you installed. I will be using tfenv to do that.
# Install the terraform binary
$ tfenv install 1.0.9

# Set to the version that I installed
$ tfenv use 1.0.9
  1. Initialized the Okta provider. (Basically, get the Okta provider binaries to working space).
$ terraform init
  1. Finally, start extracting the Okta resource using the terraformer commandline tool into HCL and Terraform State file.
$ terrafomer import okta --resources=okta_user
  1. Review. The above command by default will create a generated folder containing specific resource that you wanted extracted, in the example that was the okta_user resource.

NOTE: I'm using the tree command tool, which may not exist in your OS. You can observe the generated folder using MacOS Finder app or similar tool.

$tree generated

# Output
ie.
generated
└── okta
    └── okta_user
        β”œβ”€β”€ outputs.tf
        β”œβ”€β”€ provider.tf
        β”œβ”€β”€ terraform.tfstate
        └── user.tf

2 directories, 4 files

More Example

  • Extract User and OAuth/OpenID Applications
$ terraformer import okta --resources=okta_user,okta_app_oauth
  • Extract User, Groups, OAuth/OpenID Applications, and Authorization Server
$ terraformer import okta --resources=okta_user,okta_group,okta_app_oauth,okta_auth_server

Issues/Bugs or Features

Please submit Issues/Bugs/Features using GitHub Issues page and clicking on New issue button.

More information

About

Okta Terraformer (Reverse Terraform) Demo

Topics

Resources

Stars

Watchers

Forks

Languages