Community생산성 & 협업github.com

hashicorp/provider-actions

Plugin Framework를 사용하여 Terraform Provider 액션을 구현합니다. 생성, 업데이트, 삭제와 같은 라이프사이클 이벤트 전후에 실행되는 명령형 작업을 개발할 때 사용하세요.

provider-actions란 무엇인가요?

이 스킬은 Terraform Provider 개발 시 Plugin Framework를 활용하여 리소스 라이프사이클 이벤트(생성, 업데이트, 삭제) 전후에 실행되는 명령형 액션을 구현하는 방법을 제공합니다. Terraform Provider의 기본 CRUD 동작 외에 추가적인 사전/사후 처리가 필요한 경우 유용하며, 특히 외부 시스템과의 동기화, 유효성 검사, 로깅, 또는 상태 변경 같은 부수 효과(side effects)를 처리해야 할 때 사용합니다. 공식 HashiCorp Terraform Plugin Framework를 기반으로 하며, `terraform-plugin-framework` 리소스에 대한 `BeforeCreate`, `AfterCreate`, `BeforeUpdate`, `AfterUpdate`, `BeforeDelete`, `AfterDelete` 등의 타이밍 훅을 지원합니다. 사용자는 Go 코드 내에서 해당 함수 시그니처를 따르는 액션 핸들러를 정의하고, 리소스 정의에 등록하는 방식으로 동작합니다. 이 스킬은 Terraform Provider를 개발하는 DevOps 엔지니어나 Go 개발자에게 필수적입니다.

지원 대상~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은(는) 무엇을 하나요?

Plugin Framework를 사용하여 Terraform Provider 액션을 구현합니다. 생성, 업데이트, 삭제와 같은 라이프사이클 이벤트 전후에 실행되는 명령형 작업을 개발할 때 사용하세요.

개요

Terraform Provider 개발 시, 리소스의 생성, 읽기, 업데이트, 삭제(CRUD) 외에도 특정 라이프사이클 이벤트 시점에 추가적인 로직을 실행해야 할 필요가 있습니다. hashicorp/provider-actions 스킬은 이러한 명령형 액션을 Plugin Framework에서 정의하고 등록하는 방법을 안내합니다.

지원 기능

다음과 같은 라이프사이클 훅을 지원합니다:

  • BeforeCreate - 리소스 생성 전 실행
  • AfterCreate - 리소스 생성 후 실행
  • BeforeUpdate - 리소스 업데이트 전 실행
  • AfterUpdate - 리소스 업데이트 후 실행
  • BeforeDelete - 리소스 삭제 전 실행
  • AfterDelete - 리소스 삭제 후 실행

사용 방법

  1. 액션 핸들러 정의: 적절한 함수 시그니처를 따르는 액션 핸들러를 Go 코드로 작성합니다.

    func (r *SomeResource) BeforeCreate(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
        // 사전 처리 로직
    }
    
  2. 리소스에 액션 등록: 리소스 정의에서 해당 액션 함수를 등록합니다.

    func (r *SomeResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
        // 기본 생성 로직과 함께 액션 호출
        r.BeforeCreate(ctx, req, resp)
        // ... 기본 CRUD 구현 ...
        r.AfterCreate(ctx, req, resp)
    }
    

예시

아래는 외부 API 호출 전에 유효성을 검사하는 BeforeCreate 액션의 예시입니다:

func (r *exampleResource) BeforeCreate(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
    var data ExampleModel
    diags := req.Plan.Get(ctx, &data)
    resp.Diagnostics.Append(diags...)
    if resp.Diagnostics.HasError() {
        return
    }

    if data.Name.ValueString() == "" {
        resp.Diagnostics.AddError("Validation Error", "Name must not be empty")
        return
    }

    // 추가 검증 또는 전처리 로직
}

참고사항

  • 액션 함수는 동기적으로 실행되므로, 블로킹 작업은 주의해서 사용해야 합니다.
  • 오류가 발생하면 resp.Diagnostics에 추가하여 Terraform이 적절히 처리할 수 있도록 합니다.
  • 액션 내에서 리소스 상태를 읽거나 수정할 수 있지만, CRUD 주체 로직과의 충돌을 방지하기 위해 주의해야 합니다.

관련 문서

라이선스

이 스킬은 Apache 2.0 라이선스 하에 제공됩니다.

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.

관련 스킬