aiven/terraform-provider-aiven/tf-resource-generator
Claude Code and agent skill by aiven/terraform-provider-aiven
- community
Checking that the SKILL.md file is still in the repository.
Generate new Terraform resources and data sources from YAML definitions and OpenAPI specs. Use when adding resources, creating YAML definitions, working with the Plugin Framework generator, or when the user asks about code generation.
Install
npx vskill@latest install aiven/terraform-provider-aiven/tf-resource-generatorSKILL.md
Terraform Resource Generator Skill
Generate new Terraform resources and data sources by learning from existing patterns in the codebase.
Tooling Rule (read first)
Always drive generation, formatting, and linting through Task:
task generate— generates code and runstask fmtautomatically at the endtask fmt— formats Go, Terraform, and whitespacetask lint— runs all linters
Do NOT use go run ./generators/..., go generate, gofmt, goimports, golangci-lint, or make for these workflows. See AGENTS.md and Taskfile.dist.yml (run task --list) for the full command surface.
Overview
The generator creates Terraform resources by combining:
- OpenAPI Spec (
openapi.json) - Aiven's API schema - YAML Definitions (
definitions/aiven_*.yml) - Configuration for resource generation
Note: This skill is the canonical reference for YAML syntax, adapter API, and implementation patterns. The tf-resource-migration skill builds on this for migrating existing SDK resources.
Generated outputs per resource:
zz_resource.go/zz_datasource.go- Terraform schema + internal schemazz_view.go- CRUD operation handlers,ResourceOptions,DataSourceOptionsexamples/resources/*/import.sh- Import command examples
Generated aggregated output:
internal/plugin/zz_provider.go- Provider resource/datasource registry
User Interaction Pattern
When the user requests a new resource, gather requirements BEFORE starting:
First Question
Settle which Terraform component is needed before writing YAML:
- Both resource and data source - Full CRUD resource + read-only data source (the usual answer)
- Resource only - Just the resource (create, read, update, delete)
- Data source only - Read-only data source
If the request does not make it obvious, ask with AskUserQuestion. When running without a user to answer (autonomous mode), default to both and state the assumption in the summary instead of blocking.
Additional Information to Gather
- Resource name - What API resource/endpoint? (e.g., "MySQL database", "Kafka topic")
- Scope - Project-level, service-level, organization-level?
Discovery Process
- Update OpenAPI spec first by running
task get-specto get the spec matching the pinnedgo-client-codegen - Search OpenAPI spec for operation IDs
- Show the user what you found and ask for confirmation
- Find similar resources in
definitions/and show them - Clarify specifics if needed (composite ID, fields to exclude/rename, custom modifiers)
When NOT to Ask
These rules skip the discovery questions, not the component question above: a lone read operation ID still leaves resource-vs-data-source open, so ask (or apply the autonomous default).
- If the user provided specific operation IDs -> proceed
- If the user provided a complete YAML definition -> proceed
- If it's a modification to existing definition -> read the file and proceed
Confirmation Before Generation
Always summarize what you're about to create before proceeding.
Learning from Existing Resources
CRITICAL: Before creating a new resource, ALWAYS search for similar existing resources to learn patterns:
Key files to reference:
definitions/.schema.yml- Complete YAML schema specificationdefinitions/aiven_*.yml- Real working examples- Existing generated code in
internal/plugin/service/*/zz_*.go
Generation Workflow
1. Update OpenAPI Spec
Always start by downloading the API schema. It comes from the openapi.zip asset of the go-client-codegen release pinned in go.mod, so the spec and the client always match. To pick up a newer API, bump the client first (task update-client):
2. Find the API Operations
Search OpenAPI spec for operation IDs:
Common patterns: ResourceCreate, ResourceGet, ResourceUpdate, ResourceDelete, ResourceList
3. Find a Similar Resource
Search definitions/ for a resource with similar characteristics:
- Same client handler (project, service, organization, etc.)
- Similar ID structure (single vs composite)
- Similar operations (CRUD, list-based reads, etc.)
Read that YAML file to understand the pattern.
4. Create Your YAML Definition
File: definitions/aiven_my_resource.yml
IMPORTANT: Definition files MUST have the aiven_ prefix. The filename (without .yml) becomes the resource name directly: aiven_my_resource.yml -> resource aiven_my_resource.
The generated package always lives at internal/plugin/service/<resource-name-minus-aiven-prefix-and-underscores> — e.g. aiven_my_resource -> internal/plugin/service/myresource, aiven_kafka_topic -> internal/plugin/service/kafkatopic. The directory, the Go package name, and the import alias in zz_provider.go are all the same string, derived from the filename.
Start minimal:
5. Reference Fields
Add ref: to every field that references another resource, see Field References. Check other definitions too: a new resource can be the better target for their fields.
6. Generate and Iterate
Review generated zz_*.go files. Refine YAML definition as needed.
YAML Definition Reference
Top-Level Fields
IMPORTANT: Always check definitions/.schema.yml for the complete, authoritative schema specification.
Common fields:
operations- Array of CRUD operations (id, type, resultKey, etc.)resource/datasource- Configuration metadataidentityFields- Fields that compose the ID (e.g.,[project, service_name])clientHandler- API client type:project,service,organization,organizationbilling, etc.remove- Fields to exclude from schema (exact paths or glob patterns)rename- Field name mappings (API field -> Terraform field)hoist- Lifts the children of a root API object to top-level attributes, e.g.hoist: {access_control: ["*"]}. Values are glob patterns of child names. A hoisted field's path isaccess_control/<child>forremove, and it can't be renamed. The internal schema marks each hoisted field withHoistedFrom: "access_control".d.Expandnests the marked fields after the modifiers, andd.Flattenlifts them before the modifiers, so the views and modifiers work with root fields only.d.HasChangeHoisted("access_control")reports a change of any of them. A child the API omits keeps its state, like a root field, so zero it inflattenModifierif that hides drift (seeaiven_valkey_user). Cross-group pruning applies, e.g.valkey_*children are dropped fromaiven_pg_user. Only root objects can be hoisted. A hoisted array is a set unless the schema setstype: arrayOrdered. A child that no declared update operation accepts is force-new: declare the update operation, even withdisableView: true, and send the whole object (e.g.serviceuser.Update), so new children are updatable.schema- Schema customizations (types, validation, behavior)expandModifier/flattenModifier/readModifier- Enable custom Go modifiersversion- Schema version, the SDKSchemaVersionof a migrated resource (no state upgraders)beta- Mark resource as beta (requiresPROVIDER_AIVEN_ENABLE_BETAenv var)limitedAvailability- Mark resource as limited availabilitylegacyTimeouts- Enable SDK v2-style timeout blocksrequireServiceReady- List of accepted service types; gate CRUD on type and power state (see Service Readiness Gating)userConfigDiscriminator- Split aoneOfuser config into a block per type (see User Configs)
Resource Configuration
identityFields fields compose the string ID and are also the resource identity (Terraform 1.12+). Each must be a top-level string attribute, and Read must rebuild state from them. identityFieldsOptional lists the trailing identityFields not required for identity import; unset ones are left out of the resource and data source string IDs (foo/bar instead of foo/bar/baz). The generator validates these fields and documents identity import for every resource. String import examples use the full ID, including optional fields.
For a custom import handler that accepts additional string ID formats, set resource.importExample to a multiline shell example. It is used in both examples/resources/<type>/import.sh and the resource documentation. Keep alternative commands commented so copying the example imports the resource only once. This overrides documentation only; identityFields still defines the resource ID and identity import.
refreshState: true enables a post-Create/Update Read that completes on the first successful Read, retrying transient 404/403 errors. To also wait for an attribute value, set stateAttribute and a refreshState block with desired and optional failed instead — desired already includes that exists retry. Values within each list use OR semantics. A desired value completes the refresh, and any failed value stops it immediately. Values in neither list are treated as pending and retried until the operation timeout.
stateAttribute names a top-level computed-only attribute; the generator rejects anything else. When the value to wait for lives elsewhere — nested in a collection, spread over several attributes, or derived — keep refreshState: true and set ResourceOptions.RefreshStateCheck in init(). It runs after each Read of the post-Create/Update refresh only (never during plain Read, import, or a data source read), and its error decides what happens next: adapter.ErrRefreshStateFailed stops the refresh, and any other error means "not converged yet" and is retried with the same backoff as a transient Read error.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtools/agents/skills/tf-resource-generator/SKILL.md
Popularity
- Repository stars
- 128
- Repository forks
- 74
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 19 Mar 2026, 8 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/aiven/terraform-provider-aiven/tf-resource-generator)