aiven/terraform-provider-aiven/tf-resource-migration

Claude Code and agent skill by aiven/terraform-provider-aiven

Trust tier 3
  • community
Source check pending

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-migration

SKILL.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 runs task fmt automatically at the end
  • task fmt — formats Go, Terraform, and whitespace
  • task 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:

bash
# Find resource file
find internal/sdkprovider -name "*resource_*.go" | grep -i "resource_name"
# Find data source file
find internal/sdkprovider -name "*datasource_*.go" | grep -i "resource_name"

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:

bash
# Search for API client calls in the resource
grep -A 5 "client\." internal/sdkprovider/service/resource_name.go
# IMPORTANT: Also check the data source — it may use a different API operation
grep -A 5 "client\." internal/sdkprovider/service/resource_name_data_source.go

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:

bash
go mod download github.com/aiven/go-client-codegen # no-op once built; ensures {{.Dir}} is populated
grep -rl "OperationID: \"<OperationID>\"" "$(go list -m -f '{{.Dir}}' github.com/aiven/go-client-codegen)/handler/"

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 TypeYAML Type
schema.TypeStringtype: string
schema.TypeInttype: integer
schema.TypeFloattype: number
schema.TypeBooltype: boolean
schema.TypeListtype: arrayOrdered
schema.TypeSettype: array (or arrayOrdered for performance)
schema.TypeMapadditionalProperties: {type: string}
SDK Attributes -> YAML Attributes
SDK AttributeYAML Attribute
Required: truerequired: true
Optional: trueoptional: true
Computed: truecomputed: true
Sensitive: truesensitive: true
ForceNew: trueforceNew: true
ConflictsWith: []conflictsWith: []
ExactlyOneOf: []exactlyOneOf: []
Nested Blocks

SDK Set of objects:

go
"tags": {
Type: schema.TypeSet,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key": {Type: schema.TypeString},
"value": {Type: schema.TypeString},
},
},
}

YAML (use arrayOrdered for performance):

yaml
schema:
tags:
type: arrayOrdered
items:
type: object
properties:
key:
type: string
value:
type: string
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:

bash
# Look for ResourceData.SetId calls
grep -A 2 "SetId" internal/sdkprovider/service/resource_name.go
# Look for ID builder functions
grep -B 5 "buildResourceID\|parseResourceID" internal/sdkprovider/service/resource_name.go

Common ID patterns:

  • Single field: project
  • Composite: project/service_name/database_name

Set in YAML:

yaml
identityFields: [project, service_name, database_name]
5. Handle Custom Logic

Identify in SDK code and map to generator features:

SDK PatternGenerator Feature
StateUpgradersNot ported, keep SchemaVersion as version in YAML (see State Compatibility Verification)
CustomizeDiffmodifyPlan: true (writes plan values, d.RequiresReplace for replacement) — not readModifier, which runs inside Read
Flatten/Expand functionsexpandModifier: true / flattenModifier: true
DiffSuppressFuncNo 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 UpdateCustom 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 statewriteOnly: 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 + SetNew on 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 Sensitive field as sensitive: true in 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
bash
task generate
task build
task lint
8. State Compatibility Verification

CRITICAL: Ensure state is compatible between SDK and Plugin Framework versions.

Check schema version in SDK:

bash
grep -A 3 "SchemaVersion" internal/sdkprovider/service/resource_name.go

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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/aiven/terraform-provider-aiven/tf-resource-migration/badge)](https://verified-skill.com/skills/aiven/terraform-provider-aiven/tf-resource-migration)

Something wrong with this skill or its page? Tell us.