Skip to content

Commit 3fdc6bc

Browse files
committed
adding some fixes
1 parent 9cadc88 commit 3fdc6bc

File tree

15 files changed

+807
-83
lines changed

15 files changed

+807
-83
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ A Terraform provider for managing [Ory Network](https://www.ory.sh/) resources u
3939
terraform {
4040
required_providers {
4141
ory = {
42-
source = "ory/terraform-provider-orynetwork"
42+
source = "ory/orynetwork"
4343
version = "~> 0.1"
4444
}
4545
}
@@ -60,7 +60,7 @@ Then configure Terraform to use the local provider:
6060
# ~/.terraformrc
6161
provider_installation {
6262
dev_overrides {
63-
"ory/terraform-provider-orynetwork" = "/path/to/terraform-provider-orynetwork"
63+
"ory/orynetwork" = "/path/to/terraform-provider-orynetwork"
6464
}
6565
direct {}
6666
}
@@ -101,7 +101,7 @@ provider "ory" {
101101
terraform {
102102
required_providers {
103103
ory = {
104-
source = "ory/terraform-provider-orynetwork"
104+
source = "ory/orynetwork"
105105
}
106106
}
107107
}

docs/index.md

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "ory Provider"
43
description: |-
5-
The Ory provider enables Terraform to manage Ory Network https://www.ory.sh/ resources.
6-
Authentication
7-
Ory Network uses two types of API keys:
8-
Workspace API Key (ory_wak_...): For organizations, projects, and workspace managementProject API Key (ory_pat_...): For identities, OAuth2 clients, and sessions
9-
Configure via environment variables or provider block:
10-
11-
provider "ory" {
12-
workspace_api_key = var.ory_workspace_key # or ORY_WORKSPACE_API_KEY env var
13-
project_api_key = var.ory_project_key # or ORY_PROJECT_API_KEY env var
14-
project_id = var.ory_project_id # or ORY_PROJECT_ID env var
15-
project_slug = var.ory_project_slug # or ORY_PROJECT_SLUG env var
16-
}
4+
The Ory provider enables Terraform to manage Ory Network resources.
175
---
186

197
# ory Provider
@@ -24,20 +12,38 @@ The Ory provider enables Terraform to manage [Ory Network](https://www.ory.sh/)
2412

2513
Ory Network uses two types of API keys:
2614

27-
1. **Workspace API Key** (`ory_wak_...`): For organizations, projects, and workspace management
28-
2. **Project API Key** (`ory_pat_...`): For identities, OAuth2 clients, and sessions
15+
| API Key Type | Prefix | Used For |
16+
|--------------|--------|----------|
17+
| **Workspace API Key** | `ory_wak_...` | Projects, organizations, workspace management, project config, actions |
18+
| **Project API Key** | `ory_pat_...` | Identities, OAuth2 clients, relationships |
19+
20+
## Configuration Options
2921

30-
Configure via environment variables or provider block:
22+
```bash
23+
export ORY_WORKSPACE_API_KEY="ory_wak_..."
24+
export ORY_WORKSPACE_ID="..." # Required for creating new projects
25+
export ORY_PROJECT_API_KEY="ory_pat_..."
26+
export ORY_PROJECT_ID="..."
27+
export ORY_PROJECT_SLUG="..."
28+
```
3129

3230
```hcl
33-
provider "ory" {
34-
workspace_api_key = var.ory_workspace_key # or ORY_WORKSPACE_API_KEY env var
35-
project_api_key = var.ory_project_key # or ORY_PROJECT_API_KEY env var
36-
project_id = var.ory_project_id # or ORY_PROJECT_ID env var
37-
project_slug = var.ory_project_slug # or ORY_PROJECT_SLUG env var
38-
}
31+
provider "ory" {} # Picks up from ORY_* environment variables
3932
```
4033

34+
## Which Credentials Do You Need?
35+
36+
| Resource | Required Credentials |
37+
|----------|---------------------|
38+
| `ory_project`, `ory_workspace` | `workspace_api_key`, `workspace_id` |
39+
| `ory_organization` | `workspace_api_key`, `project_id` |
40+
| `ory_project_config`, `ory_action`, `ory_social_provider`, `ory_email_template` | `workspace_api_key`, `project_id` |
41+
| `ory_identity`, `ory_oauth2_client`, `ory_relationship` | `project_api_key`, `project_slug` |
42+
43+
## Import Requirements
44+
45+
When importing existing resources, ensure you have the appropriate credentials configured **before** running `terraform import`.
46+
4147
## Example Usage
4248

4349
```terraform
@@ -55,6 +61,9 @@ provider "ory" {
5561
# Workspace API key for project/organization management
5662
workspace_api_key = var.ory_workspace_api_key # or set ORY_WORKSPACE_API_KEY env var
5763
64+
# Workspace ID (required for creating new projects)
65+
workspace_id = var.ory_workspace_id # or set ORY_WORKSPACE_ID env var
66+
5867
# Project API key for identity/OAuth2 operations
5968
project_api_key = var.ory_project_api_key # or set ORY_PROJECT_API_KEY env var
6069
@@ -77,22 +86,32 @@ variable "ory_workspace_api_key" {
7786
type = string
7887
sensitive = true
7988
description = "Ory Workspace API Key (ory_wak_...)"
89+
default = null
90+
}
91+
92+
variable "ory_workspace_id" {
93+
type = string
94+
description = "Ory Workspace ID (UUID)"
95+
default = null
8096
}
8197
8298
variable "ory_project_api_key" {
8399
type = string
84100
sensitive = true
85101
description = "Ory Project API Key (ory_pat_...)"
102+
default = null
86103
}
87104
88105
variable "ory_project_id" {
89106
type = string
90107
description = "Ory Project ID (UUID)"
108+
default = null
91109
}
92110
93111
variable "ory_project_slug" {
94112
type = string
95113
description = "Ory Project Slug (e.g., vibrant-moore-abc123)"
114+
default = null
96115
}
97116
```
98117

docs/resources/action.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "ory_action Resource - ory"
43
subcategory: ""
54
description: |-
@@ -10,6 +9,8 @@ description: |-
109

1110
Manages an Ory Action (webhook) for identity flows.
1211

12+
Actions allow you to trigger webhooks at specific points in identity flows (login, registration, recovery, settings, verification).
13+
1314
## Example Usage
1415

1516
```terraform
@@ -58,6 +59,69 @@ resource "ory_action" "sync_verified" {
5859
}
5960
```
6061

62+
## Authentication Methods
63+
64+
The `auth_method` attribute specifies which authentication method triggers the webhook. This corresponds to the "Next" modal in the Ory Console UI when creating an action.
65+
66+
| Value | Description | UI Equivalent |
67+
|-------|-------------|---------------|
68+
| `password` | Password-based authentication (default) | "Password" |
69+
| `oidc` | Social/OIDC authentication (Google, GitHub, etc.) | "Social Sign-In" |
70+
| `code` | One-time code (magic link, OTP) | "Code" |
71+
| `webauthn` | Hardware security keys | "WebAuthn" |
72+
| `passkey` | Passkey authentication | "Passkey" |
73+
| `totp` | Time-based one-time password | "TOTP" |
74+
| `lookup_secret` | Recovery/backup codes | "Backup Codes" |
75+
76+
~> **Note:** `auth_method` is only used for `timing = "after"` webhooks. For `timing = "before"` hooks, the webhook runs before any authentication method.
77+
78+
## Import
79+
80+
Actions use different import formats depending on timing:
81+
82+
**For "after" timing (post-hooks):**
83+
```shell
84+
terraform import ory_action.welcome_email "project_id:flow:after:auth_method:url"
85+
```
86+
87+
**For "before" timing (pre-hooks):**
88+
```shell
89+
terraform import ory_action.validate_login "project_id:flow:before:url"
90+
```
91+
92+
### Examples
93+
94+
```shell
95+
# Import a post-registration password webhook
96+
terraform import ory_action.welcome \
97+
"550e8400-e29b-41d4-a716-446655440000:registration:after:password:https://api.example.com/webhooks/welcome"
98+
99+
# Import a post-login social (OIDC) webhook
100+
terraform import ory_action.social_login \
101+
"550e8400-e29b-41d4-a716-446655440000:login:after:oidc:https://api.example.com/webhooks/social"
102+
103+
# Import a pre-login validation webhook (no auth_method needed)
104+
terraform import ory_action.validate \
105+
"550e8400-e29b-41d4-a716-446655440000:login:before:https://api.example.com/webhooks/validate"
106+
```
107+
108+
### Finding Import Values from Ory Console
109+
110+
1. **project_id**: Settings → General → Project ID
111+
2. **flow**: The flow type (login, registration, recovery, settings, verification)
112+
3. **timing**: "before" or "after"
113+
4. **auth_method** (for "after" only): password, oidc, code, webauthn, passkey, totp, lookup_secret
114+
5. **url**: The exact webhook URL - must match exactly including protocol and trailing slashes
115+
116+
### Troubleshooting Import Errors
117+
118+
If you see "Cannot import non-existent remote object", the import will show a warning listing webhooks found at that location. This helps you find the correct URL and auth_method.
119+
120+
Common issues:
121+
- **URL mismatch**: URLs must match exactly, including `https://` and any trailing `/`
122+
- **Wrong auth_method**: UI-created actions default to "password" if you didn't explicitly select one
123+
- **Wrong timing**: Check if the webhook is a pre-hook (before) or post-hook (after)
124+
61125
<!-- schema generated by tfplugindocs -->
62126
## Schema
63127

@@ -69,7 +133,7 @@ resource "ory_action" "sync_verified" {
69133

70134
### Optional
71135

72-
- `auth_method` (String) Authentication method to hook into (password, oidc, code, webauthn, passkey, totp, lookup_secret). Required for 'after' timing.
136+
- `auth_method` (String) Authentication method to hook into. This corresponds to the 'Next' step in the Ory Console UI when creating an action. Valid values: `password` (default), `oidc` (social login), `code` (magic link/OTP), `webauthn`, `passkey`, `totp`, `lookup_secret`. Only used for `timing = "after"` webhooks.
73137
- `body` (String) Jsonnet template for the request body.
74138
- `can_interrupt` (Boolean) Allow webhook to interrupt/block the flow (default: false).
75139
- `method` (String) HTTP method (default: POST).

docs/resources/project.md

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,8 @@
11
---
2-
# generated by https://github.com/hashicorp/terraform-plugin-docs
32
page_title: "ory_project Resource - ory"
43
subcategory: ""
54
description: |-
65
Manages an Ory Network project.
7-
Projects are the top-level resource in Ory Network. Each project has its own
8-
identity service, OAuth2 server, and configuration.
9-
Example Usage
10-
11-
resource "ory_project" "main" {
12-
name = "My Application"
13-
environment = "prod"
14-
}
15-
16-
Import
17-
Projects can be imported using their ID:
18-
19-
terraform import ory_project.main <project-id>
206
---
217

228
# ory_project (Resource)
@@ -28,13 +14,49 @@ identity service, OAuth2 server, and configuration.
2814

2915
## Example Usage
3016

31-
```hcl
32-
resource "ory_project" "main" {
33-
name = "My Application"
17+
```terraform
18+
# Create a production project
19+
resource "ory_project" "production" {
20+
name = "My Application - Production"
3421
environment = "prod"
3522
}
23+
24+
# Create a staging project
25+
resource "ory_project" "staging" {
26+
name = "My Application - Staging"
27+
environment = "stage"
28+
}
29+
30+
# Create a development project (note: no B2B Organizations support)
31+
resource "ory_project" "dev" {
32+
name = "My Application - Development"
33+
environment = "dev"
34+
}
35+
36+
# Output the project details
37+
output "production_project_id" {
38+
value = ory_project.production.id
39+
}
40+
41+
output "production_project_slug" {
42+
description = "Use this for ORY_PROJECT_SLUG"
43+
value = ory_project.production.slug
44+
}
3645
```
3746

47+
## Environment Types
48+
49+
The `environment` attribute determines which features are available:
50+
51+
| Environment | Description | B2B Organizations |
52+
|-------------|-------------|-------------------|
53+
| `prod` | Production environment with full features | Supported |
54+
| `stage` | Staging environment for testing | Supported |
55+
| `dev` | Development environment with limited features | **Not supported** |
56+
57+
~> **Important:** If you plan to use `ory_organization` resources, you must use `prod` or `stage` environment.
58+
The `dev` environment does not support B2B features.
59+
3860
## Import
3961

4062
Projects can be imported using their ID:
@@ -43,21 +65,31 @@ Projects can be imported using their ID:
4365
terraform import ory_project.main <project-id>
4466
```
4567

68+
After import, you can reference the computed outputs:
4669

70+
```hcl
71+
output "project_slug" {
72+
value = ory_project.main.slug
73+
}
74+
75+
output "project_state" {
76+
value = ory_project.main.state
77+
}
78+
```
4779

4880
<!-- schema generated by tfplugindocs -->
4981
## Schema
5082

5183
### Required
5284

53-
- `name` (String) The name of the project.
85+
- `name` (String) The display name of the project. This is shown in the Ory Console.
5486

5587
### Optional
5688

57-
- `environment` (String) The environment type: prod, stage, or dev.
89+
- `environment` (String) The environment type. Must be one of: `prod` (production), `stage` (staging), or `dev` (development). Defaults to `prod`. **Cannot be changed after creation** - changing this will force a new resource. Note: `dev` environment does not support B2B Organizations.
5890

5991
### Read-Only
6092

61-
- `id` (String) The unique identifier of the project.
62-
- `slug` (String) The project slug (e.g., 'vibrant-moore-abc123').
63-
- `state` (String) The project state (e.g., 'running').
93+
- `id` (String) The unique identifier of the project (UUID format).
94+
- `slug` (String) The project slug (e.g., `vibrant-moore-abc123`). This is auto-generated by Ory and used in API URLs. Use this value for `ORY_PROJECT_SLUG` or `project_slug` in provider configuration.
95+
- `state` (String) The project state. Typically `running` for active projects.

0 commit comments

Comments
 (0)