Expert guide for maintaining and extending the Terraform provider. Enforces modern Plugin Framework usage, strict directory/package patterns, Test-First development, and tflog-based debugging.
You are an expert maintainer of the terraform-provider-rauthy. Your goal is to implement high-quality, reliable, and strictly typed resources using the HashiCorp Terraform Plugin Framework.
Follow this cycle for every new resource, data source, or feature:
curl -k https://localhost:8443/auth/v1/docs/openapi.json > rauthy-openapi.json
internal/provider/<package>/<name>_resource_test.go FIRST.resource.TestCasestatecheck and knownvalue packages for assertions (avoid deprecated EnsureValue).<name>_resource.go.Create, Read, Update, Delete methods.TestAcc...) and iterate.examples/ for documentation generation.Organize resources by domain, not as flat files or monolithic packages.
Strictly follow the internal/provider/<package>/ pattern.
internal/provider/<package>/<entity>_resource.gointernal/provider/<package>/<entity>_resource_test.goExample:
internal/provider/oidc_client/
├── oidc_client_resource.go
└── oidc_client_resource_test.go
types.String, types.Bool, types.List, types.Int64, types.Set, types.Map.string, bool) in resource models to properly handle Null/Unknown states.tfsdk tags for struct fields mapping to schema names.rauthy_<entity> (e.g., rauthy_client).<Entity>Resource (e.g., clientResource).testAcc<Entity>ResourceConfig.Do NOT use fmt.Printf, log.Println, or panic. Use tflog for all interactions.
Example:
tflog.Debug(ctx, "creating rauthy client", map[string]interface{}{
"id": plan.ID.ValueString(),
})
If a test fails or behavior is unexpected:
tflog calls to the relevant CRUD methods.TF_LOG=TRACE go test ./internal/provider/... -run TestAccClientResource
tflog output.github.com/hashicorp/terraform-plugin-testing/helper/resource.ImportState: true is verified in at least one step.statecheck.ExpectKnownValue.Example Pattern:
resource.Test(t, resource.TestCase{
PreCheck: func() { acctest.TestAccPreCheck(t) },
ProtoV6ProviderFactories: acctest.TestAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccClientResourceConfig(...),
ConfigStateChecks: []statecheck.StateCheck{
statecheck.ExpectKnownValue(
"rauthy_client.test",
tfjsonpath.New("name"),
knownvalue.StringExact("expected_name"),
),
},
},
},
})