feat: support specifying client_id on oauth2 client creation#125
Closed
feat: support specifying client_id on oauth2 client creation#125
Conversation
Allow users to specify a custom `client_id` when creating an OAuth2 client resource, matching the Ory API capability. The field is Optional+Computed with RequiresReplace, so changing it forces recreation. Closes #121 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for user-specified client_id when creating ory_oauth2_client resources (matching Ory API behavior), including docs and acceptance coverage.
Changes:
- Make
client_idOptional+Computedand mark changes asRequiresReplace(). - Pass
client_idthrough to the Ory API on create when provided. - Add acceptance test coverage and update docs/examples to explain custom IDs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/resources/oauth2_client.md.tmpl | Documents how to set a custom client_id, including replace behavior note. |
| internal/resources/oauth2client/testdata/with_custom_client_id.tf.tmpl | Adds acceptance test config template for creating with a custom client_id. |
| internal/resources/oauth2client/testdata/with_custom_client_id_updated.tf.tmpl | Adds acceptance test config template for updating non-ID fields while keeping client_id stable. |
| internal/resources/oauth2client/resource_test.go | Adds acceptance test covering create/import/update with a custom client_id. |
| internal/resources/oauth2client/resource.go | Updates schema (Optional+Computed + RequiresReplace) and passes client_id to API on create; updates in-file HCL example. |
| examples/resources/ory_oauth2_client/resource.tf | Adds an example resource using a custom client_id. |
| docs/resources/oauth2_client.md | Publishes the generated docs updates reflecting the new client_id behavior and example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
159
to
167
| "client_id": schema.StringAttribute{ | ||
| Description: "The OAuth2 client ID.", | ||
| Description: "The OAuth2 client ID. If not specified, a random ID will be generated. Once set, changing this value forces recreation of the resource.", | ||
| Optional: true, | ||
| Computed: true, | ||
| PlanModifiers: []planmodifier.String{ | ||
| stringplanmodifier.UseStateForUnknown(), | ||
| stringplanmodifier.RequiresReplace(), | ||
| }, | ||
| }, |
| } | ||
|
|
||
| output "client_id" { | ||
| value = ory_oauth2_client.api.client_id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Support specifying a custom
client_idwhen creating OAuth2 client resources, matching the Ory API's existing capability. This allows users to maintain consistent naming conventions across environments (e.g., migrating from self-hosted Hydra to Ory Network).Related Issues
Fixes #121
Type of Change
Checklist
make test)make format)Testing
Changes
Schema (
internal/resources/oauth2client/resource.go):client_idattribute fromComputedtoOptional+ComputedRequiresReplace()plan modifier (changing client_id forces recreation)Create (
internal/resources/oauth2client/resource.go):client_idto the Ory API on creationTests (
internal/resources/oauth2client/resource_test.go):TestAccOAuth2ClientResource_withCustomClientIDcovering create, import, and update with a custom client_idDocumentation:
templates/resources/oauth2_client.md.tmplwith Custom Client ID sectionexamples/resources/ory_oauth2_client/resource.tfAcceptance Test Results
All 9 OAuth2 client acceptance tests pass:
Security Scans
All pass clean:
make sec(govulncheck, gosec, gitleaks) - 0 issuesmake sec-trivy- 0 findingsmake licenses- passed🤖 Generated with Claude Code