Community生产力与协作github.com

hashicorp/provider-test-patterns

使用 terraform-plugin-testing 结合 Plugin Framework 编写的 Terraform Provider 验收测试模式。涵盖测试结构、TestCase/TestStep 字段、ConfigStateChecks、计划检查、跨步骤断言、配置助手、导入测试、清理器以及场景模式。

provider-test-patterns 是什么?

这是一个专门针对 Terraform Provider 验收测试的 AI 技能,基于 hashicorp/provider-test-patterns 知识库。它提供了使用 terraform-plugin-testing 库与 Plugin Framework 编写测试的完整模式和实践指南。该技能覆盖了 TestCase 和 TestStep 的字段定义、自定义 statecheck.StateCheck 实现的 ConfigStateChecks、plancheck 计划检查、用于跨步骤断言的 CompareValue,以及配置帮助函数。此外,还包括使用 ImportStateKind 进行导入测试、sweepers 清理资源、以及基本、更新、消失、验证和回归等场景模式。对于 ephemeral 资源测试,技能还涵盖了 echoprovider 包的使用。当开发者需要编写、审查或调试 Terraform Provider 验收测试(包括 statecheck、plancheck、TestCheckFunc、CheckDestroy、ExpectError、导入状态验证、ephemeral 资源或测试文件结构等问题)时,此技能非常有用。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/hashicorp/agent-skills/tree/main/skills/provider-test-patterns

Installed? Explore more 生产力与协作 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

provider-test-patterns 是做什么的?

使用 terraform-plugin-testing 结合 Plugin Framework 编写的 Terraform Provider 验收测试模式。涵盖测试结构、TestCase/TestStep 字段、ConfigStateChecks 与自定义 statecheck.StateCheck 实现、计划检查、用于跨步骤断言的 CompareValue、配置帮助函数、使用 ImportStateKind 的导入测试、清理器以及场景模式(基本、更新、消失、验证、回归),以及使用 echoprovider 包的 ephemeral 资源测试。在编写、审查或调试 Provider 验收测试时使用,包括关于 statecheck、plancheck、TestCheckFunc、CheckDestroy、ExpectError、导入状态验证、ephemeral 资源或如何组织测试文件的问题。

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-actions

Implement Terraform Provider actions using the Plugin Framework. Use when developing imperative operations that execute at lifecycle events (before/after create, update, destroy).

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/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.

相关技能