hashicorp/agent-skills/provider-actions
Claude Code and agent skill by hashicorp/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Implement Terraform Provider actions using the Plugin Framework. Use when developing imperative operations that execute at lifecycle events (before/after create, update, destroy).
Install
npx vskill@latest install hashicorp/agent-skills/provider-actionsSKILL.md
The same SKILL.md was published earlier as hashicorp/agent-skills/provider-actions.
Terraform Provider Actions Implementation Guide
Overview
Terraform Actions enable imperative operations during the Terraform lifecycle. Actions are experimental features that allow performing provider operations at specific lifecycle events (before/after create, update, destroy).
References:
First Action Setup
When adding the first action to a provider that has never had one, several one-time scaffolding steps are required:
- Implement `ProviderWithActions` — add an
Actions()method to the provider that returns[]func() action.Action. - Set `ActionData` in `Configure` — the provider's
Configuremethod must setresp.ActionData = valongside the existingResourceData,DataSourceData, andEphemeralResourceDataassignments. - Create `ActionWithConfigure` base type — if the provider uses embedded base types (e.g.
ResourceWithConfigure), create an equivalentActionWithConfiguretype implementingaction.ConfigureRequest/action.ConfigureResponse. - Action-schema helper variants — if the provider injects common schema attributes (e.g.
namespace) via helper functions, action-schema variants are needed sinceaction/schematypes differ fromresource/schematypes.
File Structure
Most providers keep actions alongside resources in the provider package:
(Large multi-service providers use internal/service/<service>/ packages instead — follow the target repository's layout.)
Documentation lives with the other generated docs:
(Some older, large providers hand-write website/docs/actions/<name>.html.markdown instead — match the repo.)
Action Schema Definition
Actions use the Terraform Plugin Framework with a standard schema pattern:
Common Schema Issues
Pay special attention to the schema definition - common issues after a first draft:
- Type Mismatches
- Model structs use
types.String/types.Int64and schemas use
types.StringType from github.com/hashicorp/terraform-plugin-framework/types — don't mix in types from other packages
- Some large providers layer their own custom type package on top (e.g.
terraform-provider-aws's internal fwtypes); inside such a repo, follow its convention consistently instead of the plain types
- List/Map Element Types
```go // WRONG - missing ElementType "items": schema.ListAttribute{ Optional: true, }
// CORRECT "items": schema.ListAttribute{ Optional: true, ElementType: types.StringType, } ```
- Computed vs Optional
- Attributes with defaults must be both
Optional: trueandComputed: true - Don't mark action inputs as
Computedunless they have defaults
- Validator Imports
``go // Ensure proper imports "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" ``
- Region/Provider Attribute (multi-region providers, e.g. AWS)
- Use the provider's shared region handling when it has one
- Don't manually re-define provider-level configuration in an action schema
- Nested Attributes
- Use appropriate nested object types for complex structures
- Ensure nested types are properly defined
Schema Validation Checklist
Before submitting, verify:
- [ ] All attributes have descriptions
- [ ] List/Map attributes have ElementType defined
- [ ] Validators are imported and applied correctly
- [ ] Model struct uses correct framework types
- [ ] Optional attributes with defaults are marked Computed
- [ ] Code compiles without type errors
- [ ] Run
go buildto catch type mismatches
Action Invoke Method
The Invoke method contains the action logic:
Key Implementation Requirements
1. Progress Reporting
- Use
resp.SendProgress(action.InvokeProgressEvent{...})for real-time updates - Provide meaningful progress messages during long operations
- Update progress at key milestones
- Include elapsed time for long operations
2. Timeout Management
- Always include configurable timeout parameter (default: 1800s)
- Use
context.WithTimeout()for API calls - Handle timeout errors gracefully
- Validate timeout ranges (typically 60-7200 seconds)
3. Error Handling
- Add diagnostics with
resp.Diagnostics.AddError() - Provide clear error messages with context
- Include API error details when relevant
- Map provider error types to user-friendly messages
- Document all possible error cases
Example error handling:
4. Provider SDK Integration
- Use the API client stored at Configure time (
a.client), shared with
resources and data sources
- Handle pagination for list operations
- Implement retry logic for transient failures
- Use appropriate error types
5. Parameter Validation
- Use framework validators for input validation
- Validate resource existence before operations
- Check for conflicting parameters
- Validate against provider naming requirements
6. Polling and Waiting
For operations that require waiting for completion, poll on a ticker under a context deadline, reporting progress as you go. (Alternatively use retry.StateChangeConf from github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry, the same waiter primitive resources use.)
Common Action Patterns
Batch Operations
- Process items in configurable batches
- Report progress per batch
- Handle partial failures gracefully
- Support prefix/filter parameters
Command Execution
- Submit command and get operation ID
- Poll for completion status
- Retrieve and report output
- Handle timeout during polling
- Validate resources exist before execution
Service Invocation
- Invoke service with parameters
- Wait for completion (if synchronous)
- Return output/results
- Handle service-specific errors
Resource State Changes
- Validate current state
- Apply state change
- Poll for target state
- Handle transitional states
Async Job Submission
- Submit job with configuration
- Get job ID
- Optionally wait for completion
- Report job status
Action Triggers
Actions are invoked via action_trigger lifecycle blocks in Terraform configurations. A standalone action block without a corresponding trigger is declared but never executed.
HCL Syntax
Action parameters must be wrapped in a config {} block. Trigger references use the action. prefix, and actions is a list. Events are bare identifiers, not quoted strings.
Available Trigger Events
Supported events (as of Terraform 1.14):
before_create- Before resource creationafter_create- After resource creationbefore_update- Before resource updateafter_update- After resource update
Not supported (as of Terraform 1.14; check current release notes):
before_destroy- Not available (will cause validation error)after_destroy- Not available (will cause validation error)
Testing Actions
Acceptance Tests
- Test action invocation with valid parameters
- Test timeout scenarios
- Test error conditions
- Verify provider state changes
- Test progress reporting
- Test with custom parameters
- Test trigger-based invocation
Test Pattern
Test Cleanup with Sweep Functions
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 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 repositoryCheckingplugins/terraform/skills/provider-actions/SKILL.md
Popularity
- Repository stars
- 819
- Repository forks
- 120
- 7-day trend score
- 34
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/hashicorp/agent-skills/provider-actions)