provider-actions
Skill0 starsChanged 6 months agoMITView on GitHub
Implement Terraform Provider actions using the Plugin Framework. Use when developing imperative operations that execute at lifecycle events (before/after create, update, destroy).
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- hashicorp/agent-skillsedited, first seen Aug 10, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- hashicorp/agent-skills★ 88349% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository82 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- adding-dbt-unit-testSkill
- adk-agent-builderSkill
- adk-architectureSkill
- adk-debugSkill
- adk-sample-creatorSkill
- adk-setupSkill
- adk-styleSkill
- answering-natural-language-questions-with-dbtSkill
- api-and-interface-designSkill
- auditing-skillsSkill
- aws-ami-builderSkill
- azure-image-builderSkill
- azure-verified-modulesSkill
- babysit-prSkill
- browser-testing-with-devtoolsSkill
- building-dbt-semantic-layerSkill
- ci-cd-and-automationSkill
- code-breaking-changesSkill
- code-review-and-qualitySkill
- code-review-change-sizeSkill
- code-review-contextSkill
- code-reviewSkill
- code-review-testingSkill
- code-simplificationSkill
- codex-pr-bodySkill
- configuring-dbt-mcp-serverSkill
- context-engineeringSkill
- creating-mermaid-dbt-dagSkill
- debugging-and-error-recoverySkill
- deep-agents-coreSkill
- deep-agents-memorySkill
- deep-agents-orchestrationSkill
- deprecation-and-migrationSkill
- documentation-and-adrsSkill
- doubt-driven-developmentSkill
- fetching-dbt-docsSkill
- final-checksSkill
- frontend-ui-engineeringSkill
- gemini-api-devSkill
- gemini-interactions-apiSkill
- gemini-live-api-devSkill
- github-actionsSkill
- githubSkill
- git-workflow-and-versioningSkill
- idea-refineSkill
- incremental-implementationSkill
- interview-meSkill
- karpathy-guidelinesSkill
- migrating-dbt-core-to-fusionSkill
- migrating-dbt-project-across-platformsSkill
- new-terraform-providerSkill
- performance-optimizationSkill
- planning-and-task-breakdownSkill
- provider-docsSkill
- provider-resourcesSkill
- provider-test-patternsSkill
- push-to-registrySkill
- react-native-best-practicesSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
29 rules. About 0 are common, 21 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈21
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 92
Don't mark action inputs as Computed unless they have defaults
- Distinctive: line 102
Use framework-provided region handling when available
- Distinctive: line 103
Don't manually define provider-specific config in schema if framework handles it
- Distinctive: line 106
Use appropriate nested object types for complex structures
- Distinctive: line 107
Ensure nested types are properly defined
- Very specific: line 147
Use resp.SendProgress(action.InvokeProgressEvent{...}) for real-time updates
- Distinctive: line 149
Update progress at key milestones
- Distinctive: line 154
Always include configurable timeout parameter (default: 1800s)
- Very specific: line 155
Use context.WithTimeout() for API calls
- Very specific: line 161
Add diagnostics with resp.Diagnostics.AddError()
- Distinctive: line 165
Document all possible error cases
- Very specific: line 188
Use provider SDK clients from a.Meta().<Service>Client(ctx)
- Distinctive: line 191
Use appropriate error types
- Distinctive: line 195
Use framework validators for input validation
- Distinctive: line 197
Check for conflicting parameters
- Distinctive: line 249
Wait for completion (if synchronous)
- Distinctive: line 302
Test action invocation with valid parameters
- Distinctive: line 305
Verify provider state changes
- Distinctive: line 307
Test with custom parameters
- Distinctive: line 336
Add sweep functions to clean up test resources:
- Distinctive: line 381
Always check for service-specific prerequisites that must be met before actions can succeed
- Distinctive: line 382
Document prerequisites in action documentation and test configurations
- Very specific: line 386
Use flexible regex patterns: regexache.MustCompile(\(?s)Error Title.*key phrase\)
- Distinctive: line 390
Before/After Destroy Tests: Not supported in Terraform 1.14.0
- Distinctive: line 399
Run specific action tests:
- Distinctive: line 404
Run sweep to clean up test resources:
- Very specific: line 441
Run terrafmt fmt before submission
- Very specific: line 446
Create a changelog entry in .changelog/ directory:
- Distinctive: line 459
Before submitting your action implementation:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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:
File Structure
Actions follow the standard service package structure:
internal/service/<service>/
├── <action_name>_action.go # Action implementation
├── <action_name>_action_test.go # Action tests
└── service_package_gen.go # Auto-generated service registrationDocumentation structure:
website/docs/actions/
└── <service>_<action_name>.html.markdown # User-facing documentationChangelog entry:
.changelog/
└── <pr_number_or_description>.txt # Release note entryAction Schema Definition
Actions use the Terraform Plugin Framework with a standard schema pattern:
func (a *actionType) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
// Required configuration parameters
"resource_id": schema.StringAttribute{
Required: true,
Description: "ID of the resource to operate on",
},
// Optional parameters with defaults
"timeout": schema.Int64Attribute{
Optional: true,
Description: "Operation timeout in seconds",
Default: int64default.StaticInt64(1800),
Computed: true,
},
},
}
}Common Schema Issues
Pay special attention to the schema definition - common issues after a first draft:
- Type Mismatches
- Using
types.Stringinstead offwtypes.Stringin model structs - Using
types.StringTypeinstead offwtypes.StringTypein schema - Mixing framework types with plugin-framework types
- Using
- List/Map Element Types
// WRONG - missing ElementType "items": schema.ListAttribute{ Optional: true, } // CORRECT "items": schema.ListAttribute{ Optional: true, ElementType: fwtypes.StringType, } - Computed vs Optional
- Attributes with defaults must be both
Optional: trueandComputed: true - Don't mark action inputs as
Computedunless they have defaults
- Attributes with defaults must be both
- Validator Imports
// Ensure proper imports "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" - Region/Provider Attribute
- Use framework-provided region handling when available
- Don't manually define provider-specific config in schema if framework handles it
- 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:
func (a *actionType) Invoke(ctx context.Context, req action.InvokeRequest, resp *action.InvokeResponse) {
var data actionModel
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
// Create provider client
conn := a.Meta().Client(ctx)
// Progress updates for long-running operations
resp.Progress.Set(ctx, "Starting operation...")
// Implement action logic with error handling
// Use context for timeout management
// Poll for completion if async operation
resp.Progress.Set(ctx, "Operation completed")
}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:
// Handle specific errors
var notFound *types.ResourceNotFoundException
if errors.As(err, ¬Found) {
resp.Diagnostics.AddError(
"Resource Not Found",
fmt.Sprintf("Resource %s was not found", resourceID),
)
return
}
// Generic error handling
resp.Diagnostics.AddError(
"Operation Failed",
fmt.Sprintf("Could not complete operation for %s: %s", resourceID, err),
)4. Provider SDK Integration
- Use provider SDK clients from
a.Meta().<Service>Client(ctx) - 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:
result, err := wait.WaitForStatus(ctx,
func(ctx context.Context) (wait.FetchResult[*ResourceType], error) {
// Fetch current status
resource, err := findResource(ctx, conn, id)
if err != nil {
return wait.FetchResult[*ResourceType]{}, err
}
return wait.FetchResult[*ResourceType]{
Status: wait.Status(resource.Status),
Value: resource,
}, nil
},
wait.Options[*ResourceType]{
Timeout: timeout,
Interval: wait.FixedInterval(5 * time.Second),
SuccessStates: []wait.Status{"AVAILABLE", "COMPLETED"},
TransitionalStates: []wait.Status{"CREATING", "PENDING"},
ProgressInterval: 30 * time.Second,
ProgressSink: func(fr wait.FetchResult[any], meta wait.ProgressMeta) {
resp.SendProgress(action.InvokeProgressEvent{
Message: fmt.Sprintf("Status: %s, Elapsed: %v", fr.Status, meta.Elapsed.Round(time.Second)),
})
},
},
)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:
action "provider_service_action" "name" {
config {
parameter = value
}
}
resource "terraform_data" "trigger" {
lifecycle {
action_trigger {
events = [after_create]
actions = [action.provider_service_action.name]
}
}
}Available Trigger Events
Terraform 1.14.0 Supported Events:
before_create- Before resource creationafter_create- After resource creationbefore_update- Before resource updateafter_update- After resource update
Not Supported in Terraform 1.14.0:
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
func TestAccServiceAction_basic(t *testing.T) {
ctx := acctest.Context(t)
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
TerraformVersionChecks: []tfversion.TerraformVersionCheck{
tfversion.SkipBelow(tfversion.Version1_14_0),
},
Steps: []resource.TestStep{
{
Config: testAccActionConfig_basic(),
Check: resource.ComposeTestCheckFunc(
testAccCheckResourceExists(ctx, "provider_resource.test"),
),
},
},
})
}Test Cleanup with Sweep Functions
Add sweep functions to clean up test resources:
func sweepResources(region string) error {
ctx := context.Background()
client := /* get client for region */
input := &service.ListInput{
// Filter for test resources
}
var sweeperErrs *multierror.Error
pages := service.NewListPaginator(client, input)
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)
if err != nil {
sweeperErrs = multierror.Append(sweeperErrs, err)
continue
}
for _, item := range page.Items {
id := item.Id
// Skip non-test resources
if !strings.HasPrefix(id, "tf-acc-test") {
continue
}
_, err := client.Delete(ctx, &service.DeleteInput{
Id: id,
})
if err != nil {
sweeperErrs = multierror.Append(sweeperErrs, err)
}
}
}
return sweeperErrs.ErrorOrNil()
}Testing Best Practices
Service-Specific Prerequisites
- Always check for service-specific prerequisites that must be met before actions can succeed
- Document prerequisites in action documentation and test configurations
Error Pattern Matching
- Terraform wraps action errors with additional context
- Use flexible regex patterns:
regexache.MustCompile(\(?s)Error Title.*key phrase`)`
Test Patterns Not Applicable to Actions
- Actions trigger on lifecycle events, not config reapplication
- Before/After Destroy Tests: Not supported in Terraform 1.14.0
Running Tests
Compile test to check for errors:
go test -c -o /dev/null ./internal/service/<service>Run specific action tests:
TF_ACC=1 go test ./internal/service/<service> -run TestAccServiceAction_ -vRun sweep to clean up test resources:
TF_ACC=1 go test ./internal/service/<service> -sweep=<region> -vDocumentation Standards
Each action documentation file must include:
- Front Matter
--- subcategory: "Service Name" layout: "provider" page_title: "Provider: provider_service_action" description: |- Brief description of what the action does. --- - Header with Warnings
- Beta/Alpha notice about experimental status
- Warning about potential unintended consequences
- Link to provider documentation
- Example Usage
- Basic usage example
- Advanced usage with all options
- Trigger-based example with
terraform_data - Real-world use case examples
- Argument Reference
- List all required and optional arguments
- Include descriptions and defaults
- Note any validation rules
- Documentation Linting
- Run
terrafmt fmtbefore submission - Verify with
terrafmt diff
- Run
Changelog Entry Format
Create a changelog entry in .changelog/ directory:
.changelog/<pr_number_or_description>.txtContent format:
action/provider_service_action: Brief description of the actionPre-Submission Checklist
Before submitting your action implementation:
- Code compiles:
go build -o /dev/null . - Tests compile:
go test -c -o /dev/null ./internal/service/<service> - Code formatted:
make fmt - Documentation formatted:
terrafmt fmt website/docs/actions/<action>.html.markdown - Changelog entry created
- Schema uses correct types
- All List/Map attributes have ElementType
- Progress updates implemented for long operations
- Error messages include context and resource identifiers
- Documentation includes multiple examples
- Documentation includes prerequisites and warnings
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

