Files
homelab/terraform/authentik/README.md

82 lines
2.5 KiB
Markdown
Raw Normal View History

2026-03-12 18:20:40 +00:00
# Authentik Terraform Configuration
2025-09-15 21:42:01 +03:00
2026-03-12 18:20:40 +00:00
Root Terraform configuration for managing Authentik SSO — applications (OAuth2/OIDC, Proxy, SAML), groups, outposts, flows, certificates, and property mappings.
State is stored in Terraform Cloud (organization `ultradesu`, workspace `Authentik`).
## Structure
```
.
├── main.tf # Resources: groups, outposts, policy bindings, module calls
├── variables.tf # Input variable definitions
├── outputs.tf # Outputs (app details, groups, flows, wiki data)
├── providers.tf # Authentik provider (goauthentik/authentik 2025.12.1)
├── state.tf # Terraform Cloud backend
├── terraform.tfvars # General settings: authentik_url, outposts, flows, tags
├── oauth2-apps.auto.tfvars # OAuth2/OIDC application definitions
├── proxy-apps.auto.tfvars # Proxy application definitions
├── groups.auto.tfvars # Group definitions
└── modules/
├── oauth-provider/ # OAuth2/OIDC provider + application
├── proxy-provider/ # Proxy provider + application
└── saml-provider/ # SAML provider + application
```
2025-09-15 21:42:01 +03:00
## Usage
2026-03-12 18:20:40 +00:00
```bash
# Set the API token
export TF_VAR_authentik_token="..."
terraform init
terraform plan
terraform apply
```
All `*.auto.tfvars` files are loaded automatically — no `-var-file` flags needed.
## Adding applications
OAuth2/OIDC — add to `oauth2-apps.auto.tfvars`:
2025-09-15 21:42:01 +03:00
```hcl
2026-03-12 18:20:40 +00:00
oauth_applications = {
"my-app" = {
name = "My App"
slug = "my-app"
group = "Tools"
redirect_uris = ["https://my-app.example.com/callback"]
create_group = true
access_groups = ["admins"]
2025-09-15 21:42:01 +03:00
}
2026-03-12 18:20:40 +00:00
}
```
2025-09-15 21:42:01 +03:00
2026-03-12 18:20:40 +00:00
Proxy — add to `proxy-apps.auto.tfvars`:
2025-09-15 21:42:01 +03:00
2026-03-12 18:20:40 +00:00
```hcl
proxy_applications = {
"my-proxy" = {
name = "My Proxy"
slug = "my-proxy"
group = "Tools"
external_host = "https://my-proxy.example.com"
internal_host = "http://my-service.namespace.svc:80"
outpost = "kubernetes-outpost"
create_group = true
access_groups = ["admins"]
2025-09-15 21:42:01 +03:00
}
}
```
2026-03-12 18:20:40 +00:00
## CI/CD
2025-09-15 21:42:01 +03:00
2026-03-12 18:20:40 +00:00
Managed via Gitea Actions (`.gitea/workflows/authentik-apps.yaml`). Runs `terraform apply` on push to `main` when files in `terraform/authentik/` change. Also generates a wiki page with the applications list.
2025-09-15 21:42:01 +03:00
## Requirements
- Terraform >= 1.0
2026-03-12 18:20:40 +00:00
- goauthentik/authentik provider 2025.12.1
- Authentik API token with admin permissions