aiven/terraform-provider-aiven/tf-resource-migration
Claude Code and agent skill by aiven/terraform-provider-aiven
- community
Checking that the SKILL.md file is still in the repository.
Migrate existing Terraform resources from SDK provider (sdkprovider) to Plugin Framework. Use when converting legacy resources, ensuring state compatibility, or when the user asks to port/migrate existing resources.
Install
npx vskill@latest install aiven/terraform-provider-aiven/tf-resource-migrationSKILL.md
The same SKILL.md was published earlier as aiven/terraform-provider-aiven/tf-resource-migration.
Terraform Resource Migration Skill
Migrate existing SDK-based resources to Plugin Framework while maintaining state compatibility and behavior parity.
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
This skill guides migration of resources from:
- Source:
internal/sdkprovider/(terraform-plugin-sdk/v2) - Target:
internal/plugin/(terraform-plugin-framework) with YAML-generated code
Key Challenge: Preserve exact behavior and state compatibility so users don't experience breaking changes.
Prerequisites: This skill builds on tf-resource-generator. For YAML syntax, adapter API, modifier patterns, custom view overrides, write-only fields, and all implementation details, see that skill.
When to Use This Skill
Use this skill when:
- Migrating existing
aiven_*resources from SDK to Plugin Framework - User says: "migrate", "convert", "port", "move to Plugin Framework"
Use tf-resource-generator skill when:
- Creating brand new resources from scratch
- Questions about YAML syntax, adapter API, or implementation patterns
Migration Workflow
1. Analyze the Existing SDK Resource
Find the SDK resource:
Read and document:
- Schema definition (all fields, types, attributes)
- CRUD functions (Create, Read, Update, Delete)
- Custom logic and transformations
- Schema version (
SchemaVersion) - Existing tests (critical for parity)
2. Identify API Operations
Check what API operations the SDK resource uses:
Then find corresponding OpenAPI operation IDs. See tf-resource-generator for OpenAPI search patterns.
Determine `clientHandler`: The clientHandler YAML value is the Go package name under github.com/aiven/go-client-codegen/handler/. Find it by searching for the operation ID in the client source, at the version pinned in go.mod:
A local checkout of go-client-codegen next to this repo works as well, and is easier to read than the module cache. For example, ServiceFlinkCreateApplication lives in handler/flinkapplication/, so clientHandler: flinkapplication.
3. Map SDK Schema to YAML
SDK Type -> YAML Type
| SDK Type | YAML Type | |
|---|---|---|
schema.TypeString | type: string | |
schema.TypeInt | type: integer | |
schema.TypeFloat | type: number | |
schema.TypeBool | type: boolean | |
schema.TypeList | type: arrayOrdered | |
schema.TypeSet | type: array (or arrayOrdered for performance) | |
schema.TypeMap | additionalProperties: {type: string} |
SDK Attributes -> YAML Attributes
| SDK Attribute | YAML Attribute | |
|---|---|---|
Required: true | required: true | |
Optional: true | optional: true | |
Computed: true | computed: true | |
Sensitive: true | sensitive: true | |
ForceNew: true | forceNew: true | |
ConflictsWith: [] | conflictsWith: [] | |
ExactlyOneOf: [] | exactlyOneOf: [] |
Nested Blocks
SDK Set of objects:
YAML (use arrayOrdered for performance):
Read-Only Nested Collections
Do not reshape a field to fix a diff. A list stays a list and a set stays a set, which is what keeps an existing state readable.
Nested collections are the one exception, and the generator decides it: a collection that is read-only all the way down becomes a computed nested attribute, everything else a block. No YAML key asks for this — Item.RendersAsAttribute derives it.
The Plugin Framework has no computed blocks: Terraform plans a block from the configuration, so a value stored for a block the configuration doesn't declare either shows up as a permanent diff or fails the apply with an inconsistent result. An attribute can be computed, and a read-only collection gives up nothing by losing the block body — it has no field to write in it. The two are interchangeable for readers: same list(object({...})) in the state, same expressions (app.application_versions[0].id), so no state upgrade is involved.
An object stays a one-element collection in both forms, as the SDKv2 state holds it. That is due for removal in v5.0.0, when current_deployment.0.status becomes current_deployment.status. Never anticipate it in a migration: it breaks every reader.
Caveat — this holds only when nothing inside is settable. An optional: true + computed: true collection such as the kafka topic config stays a block, because real configurations write it in block syntax. Marking one nested field optional: true is enough to turn the whole collection back into a block. Data sources keep blocks too: their result is not planned against a configuration, so a block holding API values causes no diff there.
For an optional+computed block, drop the values the user did not set instead — see flattenConfig in internal/plugin/service/kafkatopic/topic.go. Flatten writes back only the keys the response carries, so delete(dto, name) leaves whatever prior state holds; d.Set(name, nil) removes it.
Generated example: application_versions in internal/plugin/service/flinkjarapplication/zz_resource.go.
4. Preserve ID Structure
CRITICAL: The ID format MUST stay the same for state compatibility.
Find the ID format in SDK code:
Common ID patterns:
- Single field:
project - Composite:
project/service_name/database_name
Set in YAML:
5. Handle Custom Logic
Identify in SDK code and map to generator features:
| SDK Pattern | Generator Feature | |
|---|---|---|
StateUpgraders | Not ported, keep SchemaVersion as version in YAML (see State Compatibility Verification) | |
CustomizeDiff | modifyPlan: true (writes plan values, d.RequiresReplace for replacement) — not readModifier, which runs inside Read | |
| Flatten/Expand functions | expandModifier: true / flattenModifier: true | |
DiffSuppressFunc | No equivalent, see Diff Suppression Has No Equivalent | |
| Post-Create/Update waiter (poll Read until the resource converges) | refreshState: true, or stateAttribute with refreshState.desired/refreshState.failed, or ResourceOptions.RefreshStateCheck when the value is nested (see tf-resource-generator) | |
| Multiple API calls in Update | Custom updateView via init() override | |
| Delete waiter (poll until gone/terminal state; conflicts clear as Delete is re-issued) | deleteState (see tf-resource-generator); avoid a custom deleteView | |
| Complex delete (cancel + delete state machine) | Custom deleteView via init() override | |
| Data source looks up by alt key (e.g. name) | A second read op with datasourceLookup: true + resultListLookupKeys; add resultIDField: <GoField> when the lookup endpoint differs in shape from the canonical read and should only resolve the id | |
| Sensitive field not stored in state | writeOnly: true |
For implementation details of each, see tf-resource-generator skill.
Diff Suppression Has No Equivalent
DiffSuppressFunc cannot be ported. Terraform rejects a plan whose value for a configured attribute differs from the configuration, which is why the Plugin Framework offers no such hook: SDKv2 only got away with it through its legacy type-system shims. Decide what the suppression was buying:
- It hid a change that needs no API call (e.g. a local file path the API never sees). Set
forceNew: false on the attribute and let the change apply in place. No update view is needed: the adapter skips a nil Update and refreshes the state, so the new value is simply stored.
- It hid a formatting difference the API normalizes (casing, trailing slash). Normalize the same
way in modifyPlan — but only for computed attributes, since a configured one must keep the configured value.
- It paired with a computed attribute that drove replacement (
CustomizeDiff+SetNewon a
ForceNew computed field). Compute the value in modifyPlan and call d.RequiresReplace on it.
Whichever applies, the behavior changes for at least some configurations, so call it out in the appropriate section of the draft CHANGELOG.md (see CONTRIBUTING.md — Changelog). When the change addresses a GitHub issue, end the bullet with its link. internal/plugin/service/flinkjarapplicationversion migrated a resource that used both a DiffSuppressFunc and CustomizeDiff.
6. Create YAML Definition
Create definitions/aiven_resource_name.yml. For complete YAML syntax reference, see tf-resource-generator skill.
IMPORTANT: Definition files MUST have the aiven_ prefix. The filename becomes the resource name directly.
Focus on migration-specific concerns:
- Match all SDK schema fields exactly
- Preserve ID structure
- Copy descriptions from SDK resource
- Keep every SDK
Sensitivefield assensitive: truein YAML (no regressions) - Add
ref:to fields that reference other resources, see tf-resource-generator → Field References.
The SDK example's references show the intent: data.aiven_project.foo.project becomes ref: aiven_organization_project.project_id (newest, non-deprecated target).
- Once the YAML has a generated example, definitions referencing this resource use that generated block,
labelled example, instead of the hand-written one. Regenerate and review their docs.
7. Generate and Build
8. State Compatibility Verification
CRITICAL: Ensure state is compatible between SDK and Plugin Framework versions.
Check schema version in SDK:
If SDK has SchemaVersion > 0, set the same version in YAML, or the state can't be read. Don't port the StateUpgraders: users upgrade an older state with the last release that has them, the latest version in CHANGELOG.md. Then:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 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-migration/SKILL.md
Popularity
- Repository stars
- 132
- Repository forks
- 78
- 7-day trend score
- 24
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
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-migration)