feat: add code_mfa_enabled support to ory_project_config#127
Conversation
Add the missing `code_mfa_enabled` attribute to the `ory_project_config` resource, allowing users to configure the code method as a second factor for MFA via Terraform. Closes #122
There was a problem hiding this comment.
Pull request overview
Adds support for configuring code-based MFA (selfservice.methods.code.mfa_enabled) via the ory_project_config Terraform resource.
Changes:
- Exposes new
code_mfa_enabledboolean in the resource model and schema. - Maps the attribute to the corresponding Ory Identity config write/read paths.
- Adds acceptance coverage plus example + generated docs updates.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/resources/projectconfig/resource.go | Adds the code_mfa_enabled schema/model field and wire-up to API patch/read mappings. |
| internal/resources/projectconfig/resource_test.go | Adds an acceptance test covering create/import/update and plan-only verification. |
| internal/resources/projectconfig/testdata/code_mfa.tf.tmpl | Introduces test config template for toggling code_mfa_enabled. |
| examples/resources/ory_project_config/resource.tf | Documents usage of code_mfa_enabled in the example config. |
| docs/resources/project_config.md | Updates generated docs to include code_mfa_enabled and example snippet. |
💡 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.
- Add comment explaining why import ignores config fields (by design) - Add explicit ExpectNonEmptyPlan: false for no-diff assertion - Fix alignment in code_mfa.tf.tmpl template
There was a problem hiding this comment.
Pull request overview
Adds Terraform support for configuring selfservice.methods.code.mfa_enabled via a new code_mfa_enabled attribute on the ory_project_config resource (fixing the gap reported in #122).
Changes:
- Added
code_mfa_enabledto the resource model/schema and wired it to API read/write mappings. - Added acceptance test coverage for create/import/update/no-diff behavior.
- Updated example and generated docs to include the new attribute.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/resources/projectconfig/testdata/code_mfa.tf.tmpl | Adds acceptance-test template to configure code_mfa_enabled. |
| internal/resources/projectconfig/resource_test.go | Adds acceptance test validating CRUD/import and no-perpetual-diff for code_mfa_enabled. |
| internal/resources/projectconfig/resource.go | Extends model/schema and maps code_mfa_enabled to the Ory config paths for read/write. |
| examples/resources/ory_project_config/resource.tf | Updates example usage to demonstrate code_mfa_enabled. |
| docs/resources/project_config.md | Updates generated docs and example snippet to include code_mfa_enabled. |
💡 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.
Description
Add the missing
code_mfa_enabledattribute to theory_project_configresource, allowing users to configure the code method as a second factor for MFA via Terraform.This was reported in #122 — the
mfa_enabledsetting underselfservice->methods->codewas not exposed in the provider.Related Issues
Fixes #122
Type of Change
Checklist
make test)make format)Testing
Changes
CodeMFAEnabledfield (tfsdk:"code_mfa_enabled")code_mfa_enabledboolean attribute with description/services/identity/config/selfservice/methods/code/mfa_enabledselfservice.methods.code.mfa_enabledTestAccProjectConfigResource_codeMFAwith create, import, update, and no-diff verification stepsory_project_configexample to showcode_mfa_enabledusagemake formatAcceptance Test Results
Pre-commit Checks
make build— passmake format— pass (0 lint issues)make test-short— pass (all unit tests pass)make sec— pass (govulncheck, gosec, gitleaks all clean)make sec-trivy— pass (no vulnerabilities)Usage