π― This is a GitHub Template Repository - Click "Use this template" to create your own fork!
A complete GitOps solution for managing Okta Identity Governance (OIG) using Infrastructure as Code with Terraform, GitHub Actions, and Python automation.
New to this repository? Pick the guide that matches your goal:
| Your Goal | Guide | Time | Complexity |
|---|---|---|---|
| "I just want to use Terraform locally" | LOCAL-USAGE.md | 15 min | Beginner |
| "I want to back up my code in GitHub" | GITHUB-BASIC.md | 20 min | Beginner |
| "I want full CI/CD with team collaboration" | GITHUB-GITOPS.md | 45 min | Intermediate |
| "I need Terraform resource examples" | TERRAFORM-BASICS.md | Reference | Beginner |
| "I'm having an issue" | TROUBLESHOOTING.md | Reference | All levels |
LOCAL-USAGE.md β GITHUB-BASIC.md β GITHUB-GITOPS.md
(15 min) (20 min) (45 min)
Most users should start with LOCAL-USAGE.md - no GitHub, no CI/CD, just Terraform + Okta.
π GITHUB-GITOPS.md - Set up GitHub Actions and team workflows
This guide covers:
- Click "Use this template"
- Add your Okta credentials as GitHub secrets
- Import your Okta org into code
- Automated validation on pull requests
After using this template, run the setup script to configure repository settings automatically:
# One command to configure repository
./scripts/setup-repository.shWhat it configures:
- β GitHub Actions permissions for PR creation
- β Repository labels (template-sync, maintenance)
- β Validates GitHub CLI authentication
Requires: GitHub CLI with admin access to the repository.
For advanced configurations:
- docs/AWS_BACKEND_SETUP.md - S3/DynamoDB state backend for team collaboration
- docs/03-WORKFLOWS-GUIDE.md - Complete GitHub Actions workflow reference
ποΈ Documentation Index - Master guide to all 50+ documentation files
Can't find what you're looking for? Check the documentation index for:
- Topic-based organization (Setup, Workflows, API, Terraform, Testing)
- "I want to..." quick reference table
- Links to all guides and references
This template provides everything you need to manage Okta with GitOps:
- β Multi-tenant structure - Manage multiple Okta organizations
- β GitHub Actions workflows - Automated validation, planning, and deployment
- β AWS S3 state backend - Team collaboration with state locking
- β AD infrastructure automation - Deploy Windows Server Domain Controller with automated setup
- β Python automation scripts - Resource owners, labels, and bulk operations
- β AI-assisted generation - Quickly create demo environments
- β Comprehensive documentation - Guides for every scenario
- β Template environments - Production, staging, and development ready to customize
Terraformer does NOT import OIG resources (the Terraform provider endpoints are new).
What this means:
- β Terraformer imports: users, groups, apps, policies, etc.
- β Terraformer cannot import: OIG reviews, catalogs, workflows, etc.
- β Solution: Use our Python import scripts for OIG resources
See Terraformer Guide for full details.
This repository uses an environment-based structure where each directory represents one Okta organization.
π Critical Rule: One Directory = One Okta Org
environments/
βββ production/ # Your production Okta tenant (template)
βββ staging/ # Your staging Okta tenant (template)
βββ development/ # Your development Okta tenant (template)
To add your first environment:
# Example: Create your company environment
mkdir -p environments/mycompany/{terraform,imports,config}
# Copy template files
cp environments/myorg/terraform/* environments/mycompany/terraform/
cp environments/myorg/config/* environments/mycompany/config/
# See TEMPLATE_SETUP.md for complete setup instructionsBenefits:
- β Complete environment isolation - no cross-org pollution
- β Each environment uses its own GitHub Environment secrets
- β Independent Terraform state per organization
- β Easy to add or remove tenants
- β Clear separation of concerns
β See Environments README for complete guide including:
- Environment isolation rules (CRITICAL)
- Directory structure and organization
- Import workflows for each environment
- Terraform usage examples
- Best practices for multi-tenant management
π Want to use OIG features? See OIG_PREREQUISITES.md for required setup steps (Entitlement Management must be enabled manually in GUI).
New to Terraform or starting with a brand new Okta org? We provide ready-to-use templates!
Each environment includes starter templates to help you quickly set up resources:
Perfect for: Testing, learning, quick demos
Contains:
- 5 demo users (employees, manager, contractor)
- 3 groups with memberships
- 1 OAuth application
- Complete outputs for credentials
Deploy:
cd environments/mycompany/terraform
cp QUICKSTART_DEMO.tf.example demo.tf
# Uncomment all code, change @example.com to your domain
terraform init && terraform applyPerfect for: Finding examples of any resource type
Contains:
- ALL Okta Terraform resources with examples
- Users, Groups, Apps, Policies, OIG, Auth Servers, Hooks
- Real-world configuration patterns
- Detailed comments explaining each attribute
Usage:
# Browse for examples
less environments/mycompany/terraform/RESOURCE_EXAMPLES.tf
# Copy examples to your own .tf filesLocated in each terraform/ directory with:
- Explanation of all available templates
- Quick start workflows for different scenarios
- Best practices (file organization, naming, escaping)
- Testing and troubleshooting guides
β See terraform/README.md for complete template guide.
Each environment can include AWS infrastructure for Active Directory integration with Okta.
Per-environment infrastructure (environments/{env}/infrastructure/):
- Windows Server 2022 EC2 instance configured as Domain Controller
- Automated AD setup - Promotes to DC, creates OUs, groups, and sample users
- VPC with public/private subnets - Isolated network per environment
- Security groups - All necessary AD and RDP ports pre-configured
- Okta AD Agent installer - Automatically downloaded and ready to install
- Okta Privileged Access - Optional RDP access integration
# Navigate to environment infrastructure
cd environments/mycompany/infrastructure
# Configure variables
cp terraform.tfvars.example terraform.tfvars
export TF_VAR_admin_password="YourPassword123!"
export TF_VAR_ad_safe_mode_password="YourSafeModePassword123!"
export TF_VAR_okta_org_url="https://dev-12345.okta.com"
# Deploy
terraform init
terraform apply
# Wait 15-20 minutes for automated setup, then connect via RDPAfter terraform apply, the Domain Controller will automatically:
- β
Rename computer to
{NETBIOS}-DC01 - β Install AD-Domain-Services role
- β Promote to Domain Controller
- β Create OU structure (IT, HR, Finance, Sales, etc.)
- β Create security groups (department teams, admin groups)
- β
Create sample users with realistic names (default password:
Welcome123!) - β
Download Okta AD Agent installer to
C:\Terraform\
Total setup time: ~15-20 minutes
- Connect via RDP using public IP from outputs
- Verify AD setup - Open "Active Directory Users and Computers"
- Install Okta AD Agent - Run
C:\Terraform\OktaADAgentSetup.exe - Configure Okta AD integration in Admin Console
- Test synchronization from AD to Okta
~$35-40/month for t3.medium instance with 50GB storage (stop when not in use to save costs)
β See Infrastructure README for complete guide including:
- Detailed architecture
- Security best practices
- Customization options
- Troubleshooting guide
- Okta Privileged Access setup
The Okta Terraform Provider (v6.4.0+ required) includes comprehensive support for Okta Identity Governance:
okta_reviews- Access review campaigns for periodic certificationokta_principal_entitlements- Define what principals have access tookta_request_conditions- Conditions for access requestsokta_request_sequences- Approval workflows with multiple stagesokta_request_settings- Global access request configurationokta_catalog_entry_default- Configure app catalog entriesokta_catalog_entry_user_access_request_fields- Custom request fieldsokta_entitlement_bundle- Group entitlements into bundles
These features require Python scripts (not yet in Terraform provider):
- Resource Owners - Assign owners to apps, groups, and bundles
- Governance Labels - Categorize resources for governance
- Risk Rules (SOD Policies) - Define separation of duties policies for access certification
- Admin Labeling - Automatically label admin entitlements
- Bulk Operations - Manage resources at scale with rate limiting
This template implements a complete GitOps workflow:
Feature Branch β Pull Request β Terraform Plan β
Code Review β Merge β Manual Apply Trigger β
Approval Gate β Terraform Apply β Okta Updated
Feature Branch β Pull Request β Syntax Validation β
Code Review β Merge β Auto Dry-Run β
Review Changes β Manual Apply β Okta Updated
Key Features:
- β All changes go through pull requests
- β Automated validation and planning
- β Peer review before deployment
- β Manual approval gates for production
- β Complete audit trail in Git
- β Drift detection via scheduled imports
See docs/GITOPS_WORKFLOW.md for detailed workflow documentation.
Import and Sync:
import-all-resources.yml- Import all OIG resources from Oktasync-labels.yml- Sync governance labels from Oktaexport-oig.yml- Export OIG configurations to JSON
Terraform Operations:
terraform-plan.yml- Run plan on PRs (with AWS OIDC)terraform-apply-with-approval.yml- Apply with manual approval
API Management:
apply-owners.yml- Apply resource owner assignmentsapply-labels.yml- Deploy governance labelsapply-risk-rules.yml- Apply risk rules (SOD policies)apply-admin-labels.yml- Auto-label admin entitlementsimport-risk-rules.yml- Import risk rules from Okta
Validation:
validate-pr.yml- YAML syntax, security scanningvalidate-label-mappings.yml- Label configuration validation
Located in scripts/:
Import and Sync:
import_oig_resources.py- Import OIG resources from Okta APIsync_owner_mappings.py- Sync resource owners from Oktasync_label_mappings.py- Sync governance labels from Oktaimport_risk_rules.py- Import risk rules (SOD policies) from Okta
Apply:
apply_resource_owners.py- Apply owners to resourcesapply_admin_labels.py- Auto-label admin entitlementsapply_labels_from_config.py- Deploy labels from config fileapply_risk_rules.py- Apply risk rules to Okta
Located in aws-backend/:
- S3 bucket for Terraform state
- DynamoDB table for state locking
- IAM roles for GitHub Actions OIDC
- Complete setup guide
Benefits:
- β Team collaboration without state conflicts
- β State history and versioning for rollback
- β Encryption at rest and in transit
- β No long-lived AWS credentials in GitHub
See docs/AWS_BACKEND_SETUP.md for setup instructions.
Located in ai-assisted/:
Quickly generate Terraform code for demos using AI:
Tier 1: Manual - Copy context and prompts to your AI assistant Tier 2: Automated - CLI tool with Gemini/GPT/Claude integration
# Example: Generate demo environment
cd ai-assisted
python generate.py --prompt "Create 5 marketing users and Salesforce app" \
--provider gemini --output ../environments/mycompany/terraform/demo.tfSee ai-assisted/README.md for complete guide.
- Terraform >= 1.9.0
- Python >= 3.9
- Git (for version control)
- GitHub CLI (optional, for workflow management)
- Okta Organization with Identity Governance enabled
- GitHub Account with Actions enabled
- AWS Account (for S3/DynamoDB state backend - optional but recommended)
Your API token needs these scopes:
okta.groups.manageokta.users.manageokta.apps.manageokta.governance.accessRequests.manageokta.governance.accessReviews.manageokta.governance.catalogs.manage
Click the "Use this template" button at the top of this page, or:
gh repo create my-okta-gitops --template joevanhorn/okta-terraform-demo-template
cd my-okta-gitopscd aws-backend
terraform init
terraform apply
# Save the output - you'll need it for GitHub secrets
terraform output github_actions_role_arnGo to Settings β Environments and create your first environment:
Environment Name: MyCompany (matches your directory name)
Required Secrets:
OKTA_API_TOKEN- Okta API token with governance scopesOKTA_ORG_NAME- Your Okta org name (e.g.,dev-12345678)OKTA_BASE_URL- Base URL (e.g.,okta.comoroktapreview.com)
Repository Secret (for AWS):
AWS_ROLE_ARN- From terraform output above
# Create directory structure
mkdir -p environments/mycompany/{terraform,imports,config}
# Copy template files
cp environments/myorg/terraform/provider.tf environments/mycompany/terraform/
cp environments/myorg/terraform/variables.tf environments/mycompany/terraform/
cp environments/myorg/config/*.json environments/mycompany/config/
# Update provider.tf with your backend key
# Change: key = "Okta-GitOps/production/terraform.tfstate"
# To: key = "Okta-GitOps/mycompany/terraform.tfstate"# Import all OIG resources from your Okta tenant
gh workflow run import-all-resources.yml \
-f tenant_environment=MyCompany \
-f update_terraform=true \
-f commit_changes=truecd environments/mycompany/terraform
terraform init
terraform plan
terraform applyπ You're now managing Okta with GitOps!
For detailed setup instructions, see TEMPLATE_SETUP.md.
This template receives regular updates including new features, bug fixes, improved workflows, and enhanced documentation.
Use the built-in sync workflow:
-
One-time setup:
a. Create labels:
# Create labels for automated PRs gh label create template-sync --description "Automated template sync pull request" --color "0366d6" gh label create maintenance --description "Repository maintenance" --color "fbca04"
Or create via GitHub web UI: Issues β Labels β New label
b. Enable workflow PR permissions:
- Go to Settings β Actions β General
- Under "Workflow permissions": Select "Read and write permissions"
- Check: "Allow GitHub Actions to create and approve pull requests"
- Click "Save"
-
Enable the workflow:
- Go to Actions tab in your repository
- Find "Sync Template Updates" workflow
- Click "Enable workflow" if needed
-
Run manually anytime:
gh workflow run sync-template.yml
Or click "Run workflow" in the Actions tab
-
Review the PR:
- Workflow creates a PR with template updates
- Review changes in the PR
- Merge when ready
The workflow runs automatically:
- π Weekly on Sundays at 2 AM UTC
- π Manually via workflow dispatch
- π¦ Creates PR with all template updates
- π Shows exactly what changed
If you prefer manual control:
# One-time setup: Add template as remote
git remote add template https://github.com/joevanhorn/okta-terraform-demo-template.git
# Sync updates anytime:
git fetch template
git checkout -b sync-template-updates
git merge template/main --allow-unrelated-histories
git push origin sync-template-updates
# Create PR via GitHub web UI or:
gh pr create --title "Sync template updates" --body "Updates from template repository"Watch this repository for updates:
- Click "Watch" button (top right)
- Select "Custom"
- Enable "Releases"
- Click "Apply"
You'll be notified when new features are released!
v2.0.0 (2025-11-12):
- β¨ Added Gemini Gem support (Tier 3 AI-assisted generation)
- π GitHub web UI integration guide
- π Automatic template sync workflow
See CHANGELOG.md for full history.
Comprehensive guides are available in the docs/ directory:
- TEMPLATE_SETUP.md - Complete setup guide for new users
- OIG_PREREQUISITES.md - Required Okta configuration
- DIRECTORY_GUIDE.md - Repository structure explained
- docs/GITOPS_WORKFLOW.md - GitOps patterns and best practices
- docs/WORKFLOWS.md - GitHub Actions workflow reference
- docs/API_MANAGEMENT.md - Python scripts guide (1190+ lines)
- docs/AWS_BACKEND_SETUP.md - S3 state backend setup
- docs/LESSONS_LEARNED.md - Common issues and solutions
- docs/TERRAFORMER_OIG_FAQ.md - Terraformer limitations
- docs/TROUBLESHOOTING_ENTITLEMENT_BUNDLES.md - Bundle-specific issues
- DEMO_GUIDE.md - Build demos with templates, AI, or manually (30-60 min)
- TERRAFORM-BASICS.md - Terraform resource reference and examples
- ai-assisted/README.md - AI code generation guide
gh workflow run import-all-resources.yml \
-f tenant_environment=MyCompany \
-f update_terraform=truecd environments/mycompany/terraform
terraform plan# Trigger manual apply workflow (requires approval)
gh workflow run terraform-apply-with-approval.yml \
-f environment=mycompany# Sync from Okta
python3 scripts/sync_owner_mappings.py \
--output environments/mycompany/config/owner_mappings.json
# Apply to Okta
gh workflow run apply-owners.yml \
-f environment=mycompany \
-f dry_run=false# Sync from Okta
python3 scripts/sync_label_mappings.py \
--output environments/mycompany/config/label_mappings.json
# Apply to Okta
gh workflow run apply-labels-from-config.yml \
-f environment=mycompany \
-f dry_run=falsegh workflow run apply-admin-labels.yml \
-f environment=mycompany \
-f dry_run=falseWant to see this template in action with a real, configured environment?
π okta-terraform-complete-demo
This working repository demonstrates:
- Fully configured MyOrg demo environment
- 31 entitlement bundles
- 200 access review campaigns
- Complete governance label setup
- Resource owner assignments
- Real-world workflow examples
Understanding what goes where is critical:
Layer 1: Terraform Provider (Full CRUD)
- Standard Okta resources: users, groups, apps, policies
- OIG resources: entitlement bundles, access reviews, approval sequences
- Managed in
environments/{env}/terraform/*.tffiles
Layer 2: Python API Scripts (Read/Write)
- Resource Owners (not in Terraform provider yet)
- Governance Labels (not in Terraform provider yet)
- Managed in
environments/{env}/config/*.jsonfiles
Layer 3: Manual Management (Okta Admin UI)
- Entitlement assignments (which users/groups have bundles)
- Access review decisions and approvals
- Certain advanced OIG configurations
Each environment maintains independent state:
s3://your-bucket/
βββ Okta-GitOps/
βββ mycompany/terraform.tfstate
βββ production/terraform.tfstate
βββ staging/terraform.tfstate
βββ development/terraform.tfstate
Key Features:
- State locking via DynamoDB
- AES256 encryption at rest
- Versioning enabled for rollback
- GitHub Actions authentication via AWS OIDC (no long-lived credentials)
- β Use GitHub Environments for Okta credentials
- β Use AWS OIDC for state backend (no long-lived AWS keys)
- β Rotate API tokens regularly (every 90 days)
- β Use least-privilege scopes
- β Never commit secrets to Git
- β All changes via pull requests
- β Required approvals for production
- β Automated validation on PRs
- β Manual approval gates for applies
- β Complete audit trail in Git
- β State stored in encrypted S3
- β DynamoDB locking prevents conflicts
- β State versioning for rollback
- β Never commit state files to Git
This template is actively maintained and used in production environments.
- β Full OIG resource management via Terraform
- β Resource owners and labels via Python API
- β Multi-tenant environment support
- β GitHub Actions automation
- β AWS S3/DynamoDB state backend
- β AI-assisted code generation
- β Comprehensive documentation
- β Working examples and demos
β οΈ Terraformer doesn't support OIG resources (use Python import scripts)β οΈ Principal assignments must be managed in Okta UIβ οΈ Some OIG features still in development (check provider docs)
Found a bug or have a suggestion? Please:
- Check existing issues
- Create a new issue with details
- Or submit a pull request!
This project is licensed under the MIT License - see the LICENSE file for details.
Built with:
- Okta Terraform Provider
- Terraform
- GitHub Actions
- Python
- AWS (S3, DynamoDB, IAM)
- Documentation: See
docs/directory - Issues: GitHub Issues
- Discussions: GitHub Discussions
- Working Example: okta-terraform-complete-demo
Ready to get started? β TEMPLATE_SETUP.md