Skip to content

Commit de5d4e9

Browse files
authored
Merge pull request #20 from ory/chore/feedback_updates
chore: adding some fixes
2 parents 64ee15e + fccd530 commit de5d4e9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2676
-348
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: 83 additions & 44 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,24 +12,44 @@ 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
21+
22+
There are two ways to configure the Ory provider:
23+
24+
### Option 1: Environment Variables (Recommended for CI/CD)
25+
26+
Set credentials as environment variables and use an empty provider block:
2927

30-
Configure via environment variables or provider block:
28+
```bash
29+
export ORY_WORKSPACE_API_KEY="ory_wak_..."
30+
export ORY_WORKSPACE_ID="..." # Required for creating new projects
31+
export ORY_PROJECT_API_KEY="ory_pat_..."
32+
export ORY_PROJECT_ID="..."
33+
export ORY_PROJECT_SLUG="..."
34+
```
3135

3236
```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
37+
terraform {
38+
required_providers {
39+
ory = {
40+
source = "ory/orynetwork"
41+
}
42+
}
3843
}
44+
45+
provider "ory" {} # Picks up from ORY_* environment variables
3946
```
4047

41-
## Example Usage
48+
### Option 2: Terraform Variables (Recommended for tfvars)
49+
50+
Define variables and pass values via `terraform.tfvars` or `-var` flags:
4251

43-
```terraform
44-
# Configure the Ory provider
52+
```hcl
4553
terraform {
4654
required_providers {
4755
ory = {
@@ -50,35 +58,25 @@ terraform {
5058
}
5159
}
5260
53-
# Basic configuration using environment variables
5461
provider "ory" {
55-
# Workspace API key for project/organization management
56-
workspace_api_key = var.ory_workspace_api_key # or set ORY_WORKSPACE_API_KEY env var
57-
58-
# Project API key for identity/OAuth2 operations
59-
project_api_key = var.ory_project_api_key # or set ORY_PROJECT_API_KEY env var
60-
61-
# Project identifiers
62-
project_id = var.ory_project_id # or set ORY_PROJECT_ID env var
63-
project_slug = var.ory_project_slug # or set ORY_PROJECT_SLUG env var
62+
workspace_api_key = var.ory_workspace_api_key
63+
workspace_id = var.ory_workspace_id
64+
project_api_key = var.ory_project_api_key
65+
project_id = var.ory_project_id
66+
project_slug = var.ory_project_slug
6467
}
6568
66-
# Configuration with custom API URLs (for staging/enterprise environments)
67-
# provider "ory" {
68-
# workspace_api_key = var.ory_workspace_api_key
69-
# workspace_id = var.ory_workspace_id
70-
#
71-
# # Custom API URLs (defaults shown)
72-
# console_api_url = "https://api.console.ory.sh" # or set ORY_CONSOLE_API_URL env var
73-
# project_api_url = "https://%s.projects.oryapis.com" # or set ORY_PROJECT_API_URL env var
74-
# }
75-
7669
variable "ory_workspace_api_key" {
7770
type = string
7871
sensitive = true
7972
description = "Ory Workspace API Key (ory_wak_...)"
8073
}
8174
75+
variable "ory_workspace_id" {
76+
type = string
77+
description = "Ory Workspace ID (UUID)"
78+
}
79+
8280
variable "ory_project_api_key" {
8381
type = string
8482
sensitive = true
@@ -96,6 +94,47 @@ variable "ory_project_slug" {
9694
}
9795
```
9896

97+
Then create a `terraform.tfvars` file (do not commit this file):
98+
99+
```hcl
100+
ory_workspace_api_key = "ory_wak_..."
101+
ory_workspace_id = "..."
102+
ory_project_api_key = "ory_pat_..."
103+
ory_project_id = "..."
104+
ory_project_slug = "..."
105+
```
106+
107+
Alternatively, variables can be passed with `-var` parameter when running terraform commands:
108+
109+
```bash
110+
terraform plan -var 'ory_workspace_api_key=ory_wak_...' -var 'ory_workspace_id=...' -var 'ory_project_api_key=ory_pat_...' -var 'ory_project_id=...' -var 'ory_project_slug=...'
111+
```
112+
113+
Or use `TF_VAR_` environment variables:
114+
115+
```bash
116+
export TF_VAR_ory_workspace_api_key="ory_wak_..."
117+
export TF_VAR_ory_workspace_id="..."
118+
export TF_VAR_ory_project_api_key="ory_pat_..."
119+
export TF_VAR_ory_project_id="..."
120+
export TF_VAR_ory_project_slug="..."
121+
122+
terraform plan
123+
```
124+
125+
## Which Credentials Do You Need?
126+
127+
| Resource | Required Credentials |
128+
|----------|---------------------|
129+
| `ory_project`, `ory_workspace` | `workspace_api_key`, `workspace_id` |
130+
| `ory_organization` | `workspace_api_key`, `project_id` |
131+
| `ory_project_config`, `ory_action`, `ory_social_provider`, `ory_email_template` | `workspace_api_key`, `project_id` |
132+
| `ory_identity`, `ory_oauth2_client`, `ory_relationship` | `project_api_key`, `project_slug` |
133+
134+
## Import Requirements
135+
136+
When importing existing resources, ensure you have the appropriate credentials configured **before** running `terraform import`.
137+
99138
<!-- schema generated by tfplugindocs -->
100139
## Schema
101140

docs/resources/action.md

Lines changed: 80 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,83 @@ 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 is only used for `timing = "after"` webhooks.
65+
66+
| Value | Description |
67+
|-------|-------------|
68+
| `password` | Password-based authentication (default) |
69+
| `oidc` | Social/OIDC authentication (Google, GitHub, etc.) |
70+
| `code` | One-time code (magic link, OTP) |
71+
| `webauthn` | Hardware security keys |
72+
| `passkey` | Passkey authentication |
73+
| `totp` | Time-based one-time password |
74+
| `lookup_secret` | Recovery/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 is invoked.
77+
78+
## HTTP Method
79+
80+
The `method` attribute specifies the HTTP method used when calling the webhook:
81+
82+
| Value | Description |
83+
|-------|-------------|
84+
| `POST` | HTTP POST request (default) |
85+
| `GET` | HTTP GET request |
86+
| `PUT` | HTTP PUT request |
87+
| `PATCH` | HTTP PATCH request |
88+
| `DELETE` | HTTP DELETE request |
89+
90+
## Import
91+
92+
Actions must be imported with the HTTP method included in the import ID.
93+
94+
**For "after" timing (post-hooks):**
95+
```shell
96+
terraform import ory_action.example "project_id:flow:after:auth_method:method:url"
97+
```
98+
99+
**For "before" timing (pre-hooks):**
100+
```shell
101+
terraform import ory_action.example "project_id:flow:before:method:url"
102+
```
103+
104+
### Examples
105+
106+
```shell
107+
# Import a POST webhook for post-registration password flow
108+
terraform import ory_action.welcome \
109+
"550e8400-e29b-41d4-a716-446655440000:registration:after:password:POST:https://api.example.com/webhooks/welcome"
110+
111+
# Import a PATCH webhook for post-login social (OIDC) flow
112+
terraform import ory_action.social_login \
113+
"550e8400-e29b-41d4-a716-446655440000:login:after:oidc:PATCH:https://api.example.com/webhooks/social"
114+
115+
# Import a POST pre-login validation webhook
116+
terraform import ory_action.validate \
117+
"550e8400-e29b-41d4-a716-446655440000:login:before:POST:https://api.example.com/webhooks/validate"
118+
```
119+
120+
### Finding Import Values from Ory Console
121+
122+
1. **project_id**: Settings → General → Project ID
123+
2. **flow**: The flow type (login, registration, recovery, settings, verification)
124+
3. **timing**: "before" or "after"
125+
4. **auth_method** (for "after" only): password, oidc, code, webauthn, passkey, totp, lookup_secret
126+
5. **method**: The HTTP method (POST, GET, PUT, PATCH, DELETE)
127+
6. **url**: The exact webhook URL - must match exactly including protocol and trailing slashes
128+
129+
### Troubleshooting Import Errors
130+
131+
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, method, and auth_method.
132+
133+
Common issues:
134+
- **URL mismatch**: URLs must match exactly, including `https://` and any trailing `/`
135+
- **Wrong method**: Check the HTTP method configured for the webhook (POST, PATCH, etc.)
136+
- **Wrong auth_method**: Check which authentication method the webhook is configured for
137+
- **Wrong timing**: Check if the webhook is a pre-hook (before) or post-hook (after)
138+
61139
<!-- schema generated by tfplugindocs -->
62140
## Schema
63141

@@ -69,7 +147,7 @@ resource "ory_action" "sync_verified" {
69147

70148
### Optional
71149

72-
- `auth_method` (String) Authentication method to hook into (password, oidc, code, webauthn, passkey, totp, lookup_secret). Required for 'after' timing.
150+
- `auth_method` (String) Authentication method that triggers the webhook. In the Ory Console UI, this is the "Method" selector. Valid values: `password` (default), `oidc` (social login), `code` (magic link/OTP), `webauthn`, `passkey`, `totp`, `lookup_secret`. Only used for `timing = "after"` webhooks.
73151
- `body` (String) Jsonnet template for the request body.
74152
- `can_interrupt` (Boolean) Allow webhook to interrupt/block the flow (default: false).
75153
- `method` (String) HTTP method (default: POST).

docs/resources/email_template.md

Lines changed: 26 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_email_template Resource - ory"
43
subcategory: ""
54
description: |-
@@ -10,6 +9,25 @@ description: |-
109

1110
Manages an Ory Network email template.
1211

12+
## Template Types
13+
14+
| Template Type | UI Name | Description |
15+
|---------------|---------|-------------|
16+
| `registration_code_valid` | Registration via Code | Sent when user registers with a valid code |
17+
| `registration_code_invalid` | - | Sent when registration code is invalid/expired |
18+
| `login_code_valid` | Login via Code | Sent when user logs in with a valid code |
19+
| `login_code_invalid` | - | Sent when login code is invalid/expired |
20+
| `verification_code_valid` | Verification via Code (Valid) | Sent for email verification with valid code |
21+
| `verification_code_invalid` | - | Sent when verification code is invalid/expired |
22+
| `recovery_code_valid` | Recovery via Code (Valid) | Sent for account recovery with valid code |
23+
| `recovery_code_invalid` | - | Sent when recovery code is invalid/expired |
24+
| `verification_valid` | - | Legacy verification email (link-based) |
25+
| `verification_invalid` | - | Legacy verification invalid |
26+
| `recovery_valid` | - | Legacy recovery email (link-based) |
27+
| `recovery_invalid` | - | Legacy recovery invalid |
28+
29+
**Note:** The "_invalid" templates are sent when a code has expired or is incorrect. The non-code variants (recovery_valid, verification_valid) are for legacy link-based flows.
30+
1331
## Example Usage
1432

1533
```terraform
@@ -105,14 +123,20 @@ resource "ory_email_template" "login_code" {
105123
}
106124
```
107125

126+
## Import
127+
128+
```shell
129+
terraform import ory_email_template.welcome registration_code_valid
130+
```
131+
108132
<!-- schema generated by tfplugindocs -->
109133
## Schema
110134

111135
### Required
112136

113137
- `body_html` (String) HTML body template (Go template syntax).
114138
- `body_plaintext` (String) Plaintext body template (Go template syntax).
115-
- `template_type` (String) Template type (e.g., recovery_code_valid, verification_valid).
139+
- `template_type` (String) The email template type. See the Template Types table above for valid values and their UI equivalents. Common values: `registration_code_valid`, `login_code_valid`, `verification_code_valid`, `recovery_code_valid`.
116140

117141
### Optional
118142

0 commit comments

Comments
 (0)