How okta/terraform-provider-okta works
Project Type and Purpose
• This is a Terraform Provider plugin written in Go.
• Purpose: enable Terraform to manage Okta resources (apps, groups, policies, etc.) through the Okta REST API.
File Structure
• Top-level:
• Configuration & CI (.github, .circleci, goreleaser.yml, GNUmakefile)
• Source entrypoint (main.go)
• Provider implementation (okta/ directory)
• Generated SDK wrappers (sdk/ directory)
• Examples (examples/), Documentation (docs/), Templates (templates/)
• Tests & fixtures (test/) and scripts (scripts/)
• Patterns: separation of concerns into
• Core plugin logic and schema (okta/provider.go, resources_*.go, data_source_*.go)
• Transport & rate-limiting (okta/internal/transport)
• Generated low-level API types (sdk/v2_*.go)
• Acceptance tests using VCR cassettes
README
• Confirms: Terraform Plugin Framework, Go Modules, Go 1.x, Terraform ≥0.14.
• Build and test workflows using GitHub Actions, CircleCI, and goreleaser.
• Usage: terraform init→ uses this plugin binary → communicates to Okta API.
Diagramming the System
a. Main Components
1. Terraform CLI (user invokes terraform commands)
2. Terraform Core & Plugin Framework
3. Okta Provider Plugin
– Entrypoint (main.go)
– Provider setup (provider.go → schema & resources/dataSources)
– Resources & DataSources (okta/resource_*.go, data_source_*.go)
– Internal modules (transport, apimutex for rate-limiting)
4. Okta Go SDK (sdk/ folder)
5. Okta REST API
6. CI/CD pipelines & Tooling (GitHub Actions, CircleCI, goreleaser)
7. Examples, Templates, Docs, Tests (auxiliary but critical for extensibility)
b. Relationships and Interactions
• Terraform CLI → loads Provider Plugin via Plugin Framework → calls Initialize → receives schema registration.
• On “terraform apply” → Terraform Core calls Resource CRUD functions → plugin code uses Okta SDK client → issues HTTP requests to Okta REST API → receives responses.
• Rate-limiting & mutex (okta/internal/apimutex) interpose between client calls.
• Examples and tests drive the plugin code → test fixtures use VCR to replay Okta API interactions.
• CI/CD workflows build the plugin binary, run lint/tests, publish releases via goreleaser.
c. Architectural Patterns & Principles
• Plugin pattern (Terraform Plugin Framework)
• Modular code generation (SDK types auto-generated from OpenAPI → sdk/v2_*.go)
• Separation of business logic (resource implementations) from transport concerns (governed_transport).
• Test-driven development with fixtures (VCR) and unit tests for each resource/data source.
d. Key Technologies & Frameworks
• Go Modules, Go 1.x
• Terraform Plugin Framework
• okta-sdk-golang v3 (wrapped in sdk/)
• VCR-based acceptance tests
• GitHub Actions & CircleCI
• goreleaser for multi-platform binaries