
Provider Actions
Implement experimental Terraform Provider Actions in Go when you need imperative hooks at create, update, or destroy lifecycle events.
Install
npx skills add https://github.com/hashicorp/agent-skills --skill provider-actionsWhat is this skill?
- Maps Terraform Actions RFC lifecycle hooks (before/after create, update, destroy) to Plugin Framework action types.
- Standard internal/service layout: action implementation, tests, and generated service registration.
- User-facing website/docs/actions markdown plus .changelog release-note entries.
- Schema-driven action definition pattern aligned with HashiCorp Plugin Framework docs.
Adoption & trust: 1.6k installs on skills.sh; 654 GitHub stars; 3/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Provider action code is written while building or extending infrastructure-as-code integrations, before providers ship to users. Actions extend provider–Terraform protocol behavior, which fits the integrations shelf alongside other connector and plugin work.
Common Questions / FAQ
Is Provider Actions safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - 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:** - [Terraform Plugin Framework](https://developer.hashicorp.com/terraform/plugin/framework) - [Terraform Actions RFC](https://github.com/hashicorp/terraform/blob/main/docs/plugin-protocol/actions.md) ## 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 registration ``` Documentation structure: ``` website/docs/actions/ └── <service>_<action_name>.html.markdown # User-facing documentation ``` Changelog entry: ``` .changelog/ └── <pr_number_or_description>.txt # Release note entry ``` ## Action Schema Definition Actions use the Terraform Plugin Framework with a standard schema pattern: ```go 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: 1. **Type Mismatches** - Using `types.String` instead of `fwtypes.String` in model structs - Using `types.StringType` instead of `fwtypes.StringType` in schema - Mixing framework types with plugin-framework types 2. **List/Map Element Types** ```go // WRONG - missing ElementType "items": schema.ListAttribute{ Optional: true, } // CORRECT "items": schema.ListAttribute{ Optional: true, ElementType: fwtypes.StringType, } ``` 3. **Computed vs Optional** - Attributes with defaults must be both `Optional: true` and `Computed: true` - Don't mark action inputs as `Computed` unless they have defaults 4. **Validator Imports** ```go // Ensure proper imports "github.com/hashicorp/terraform-plugin-framework-validators/int64validator" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" ``` 5. **Region/Provider Attribute** - Use framework-provided region handling when available - Don't manually define provider-specific config in schema if framework handles it 6. **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 build` to catch type mismatches ## Action Invoke Method The Invoke method contains the action logic: ```go func (a *actionType) Invoke(ctx context.Context, re