provider-resources_skill

This skill helps you design and implement Terraform Provider resources and data sources using the Plugin Framework for robust CRUD, state, and testing.
  • Shell
  • Official

196

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill hashicorp/agent-skills --skill provider-resources

  • SKILL.md16.3 KB

Overview

This skill implements Terraform Provider resources and data sources using the Terraform Plugin Framework. It focuses on designing resource schemas, implementing CRUD operations, managing state transitions and not-found behavior, and writing acceptance tests for provider resources. It is targeted at developers building or extending Terraform providers with robust lifecycle and validation logic.

How this skill works

The skill provides concrete patterns and code structure for Plugin Framework resources: Metadata, Schema, Create, Read, Update, and Delete methods. It shows attribute types, plan modifiers, validators, and handling of sensitive fields. It also includes state helpers for polling resource status, error mapping for not-found cases, and test scaffolding for acceptance and disappearance tests.

When to use it

  • When building new Terraform provider resources or data sources with the Plugin Framework
  • When migrating SDKv2 resource implementations to the Plugin Framework
  • When you need reliable state handling for eventual-consistency APIs or long-running creates
  • When designing schema validations, plan modifiers, or sensitive attributes
  • When writing acceptance tests and teardown/sweeper logic for provider resources

Best practices

  • Organize resources in a service package with resource, tests, finder, and registration files
  • Use plan modifiers like RequiresReplace and UseStateForUnknown to control replacement and unknown handling
  • Validate inputs with framework validators (length, regex, enums, numeric ranges) to fail early in plan
  • Map API not-found errors to state removal and return warnings instead of failing plans
  • Implement wait/refresh functions for eventual-consistency with a StateChangeConf pattern
  • Write acceptance tests covering create/read/update/import and disappears scenarios and include CheckDestroy assertions

Example use cases

  • Create a namespaced resource with Name, ARN, and tags using StringAttribute, computed ARN, and RequiresReplace on name changes
  • Implement a Create method that calls the API client, sets ID and computed attributes, and writes state
  • Implement Read that finds resource by ID, removes resource from state on not-found, and updates computed attributes
  • Implement Update to detect field changes, call the API update, and set the new plan into state
  • Write TestAcc tests: basic create/import, disappears test, and a CheckDestroy helper that verifies resources are cleaned up

FAQ

Use a retry.StateChangeConf with a refresh function that queries resource status and targets the desired ready states; timeouts and pending/target arrays control polling behavior.

What is the right way to remove a missing resource from state?

Detect not-found errors in Read and call resp.State.RemoveResource(ctx) after emitting a warning so Terraform will drop the resource without failing the plan.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational