hashicorp/provider-actions

Terraform ProviderのアクションをPlugin Frameworkを使用して実装します。ライフサイクルイベント(作成前/後、更新前/後、削除前/後)で実行される命令的操作の開発時に使用します。

provider-actions とは?

このスキルは、Terraform Providerの開発において、Plugin Frameworkを活用してライフサイクルイベントに応じた命令的操作(アクション)を実装するためのガイドを提供します。主に、リソースの作成前後、更新前後、削除前後など、特定のタイミングで実行されるカスタムロジックを定義する際に有用です。Hashicorp社が提供する公式のProvider開発フレームワークに対応しており、Terraform CLIや関連ツールとシームレスに統合できます。SKILL.mdには、アクションの定義方法、実行コンテキスト、エラーハンドリング、テスト手法などが詳細に記載されています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/hashicorp/agent-skills/tree/main/skills/provider-actions

Installed? Explore more 生産性&コラボレーション skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

provider-actions は何をしますか?

Terraform ProviderのアクションをPlugin Frameworkを使用して実装します。ライフサイクルイベント(作成前/後、更新前/後、削除前/後)で実行される命令的操作の開発時に使用します。

このスキルは、Terraform Providerのプラグインフレームワークにおいて、リソースのライフサイクルに関連するアクションを実装するための手順とベストプラクティスを提供します。具体的には、terraform-provider のコードベース内で、リソースの作成(Create)、読み取り(Read)、更新(Update)、削除(Delete)の各フェーズにフックするカスタムロジックを追加する方法を説明します。

前提条件

  • Terraform Plugin Framework(terraform-plugin-framework)の基本的な知識
  • Go言語の開発環境
  • 既存のProviderコードベースへのアクセス

使用方法

  1. リソースのスキーマ定義にアクション用の属性を追加します。
  2. 各ライフサイクルメソッド(Create, Read, Update, Delete)内でアクションを呼び出します。
  3. エラーハンドリングとロールバックロジックを実装します。

例

func (r *resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
    // リソース作成前のアクション
    r.beforeCreate(ctx, req, resp)
    
    // 実際のリソース作成処理
    // ...
    
    // リソース作成後のアクション
    r.afterCreate(ctx, req, resp)
}

注意点

  • アクションは冪等性を保つように設計してください。
  • 外部システムとの連携が必要な場合は、適切なタイムアウトとリトライ機構を実装してください。
  • アクションの状態はTerraformのステートに保存するか、外部のデータストアを利用してください。

参考

Individual skills in this repo

This repo contains 15 individual skills — each has its own dedicated page.

hashicorp/aws-ami-builder

Build Amazon Machine Images (AMIs) with Packer using the amazon-ebs builder. Use when creating custom AMIs for EC2 instances.

hashicorp/azure-image-builder

Build Azure managed images and Azure Compute Gallery images with Packer. Use when creating custom images for Azure VMs.

hashicorp/azure-verified-modules

Azure Verified Modules (AVM) requirements and best practices for developing certified Azure Terraform modules. Use when creating or reviewing Azure modules that need AVM certification.

hashicorp/new-terraform-provider

Use this when scaffolding a new Terraform provider.

hashicorp/provider-docs

Create, update, and review Terraform provider documentation for Terraform Registry using HashiCorp-recommended patterns, tfplugindocs templates, and schema descriptions. Use when adding or changing provider configuration, resources, data sources, ephemeral resources, list resources, functions, or guides; when validating generated docs; and when troubleshooting missing or incorrect Registry documentation.

hashicorp/provider-resources

Implement Terraform Provider resources and data sources using the Plugin Framework. Use when developing CRUD operations, schema design, state management, and acceptance testing for provider resources.

hashicorp/provider-test-patterns

Terraform provider acceptance test patterns using terraform-plugin-testing with the Plugin Framework. Covers test structure, TestCase/TestStep fields, ConfigStateChecks with custom statecheck.StateCheck implementations, plan checks, CompareValue for cross-step assertions, config helpers, import testing with ImportStateKind, sweepers, and scenario patterns (basic, update, disappears, validation, regression), and ephemeral resource testing with the echoprovider package. Use when writing, reviewing, or debugging provider acceptance tests, including questions about statecheck, plancheck, TestCheckFunc, CheckDestroy, ExpectError, import state verification, ephemeral resources, or how to structure test files.

hashicorp/push-to-registry

Push Packer build metadata to HCP Packer registry for tracking and managing image lifecycle. Use when integrating Packer builds with HCP Packer for version control and governance.

hashicorp/refactor-module

Transform monolithic Terraform configurations into reusable, maintainable modules following HashiCorp's module design principles and community best practices.

hashicorp/run-acceptance-tests

Guide for running acceptance tests for a Terraform provider. Use this when asked to run an acceptance test or to run a test with the prefix `TestAcc`.

hashicorp/terraform-search-import

Discover existing cloud resources using Terraform Search queries and bulk import them into Terraform management. Use when bringing unmanaged infrastructure under Terraform control, auditing cloud resources, or migrating to IaC.

hashicorp/terraform-stacks

Comprehensive guide for working with HashiCorp Terraform Stacks. Use when creating, modifying, or validating Terraform Stack configurations (.tfcomponent.hcl, .tfdeploy.hcl files), working with stack components and deployments from local modules, public registry, or private registry sources, managing multi-region or multi-environment infrastructure, or troubleshooting Terraform Stacks syntax and structure.

hashicorp/terraform-style-guide

Generate Terraform HCL code following HashiCorp's official style conventions and best practices. Use when writing, reviewing, or generating Terraform configurations.

hashicorp/terraform-test

Comprehensive guide for writing and running Terraform tests. Use when creating test files (.tftest.hcl), writing test scenarios with run blocks, validating infrastructure behavior with assertions, mocking providers and data sources, testing module outputs and resource configurations, or troubleshooting Terraform test syntax and execution.

hashicorp/windows-builder

Build Windows images with Packer using WinRM communicator and PowerShell provisioners. Use when creating Windows AMIs, Azure images, or VMware templates.

関連スキル