terraform-testing
Testing Terraform configurations with native tests, Terratest, and validation frameworks
What this skill does
# Terraform Testing Skill
Comprehensive testing patterns for Terraform modules and configurations.
## Native Terraform Test (1.6+)
### Basic Test
```hcl
# tests/vpc_test.tftest.hcl
run "vpc_creation" {
command = plan
variables {
vpc_cidr = "10.0.0.0/16"
environment = "test"
}
assert {
condition = aws_vpc.main.cidr_block == "10.0.0.0/16"
error_message = "VPC CIDR mismatch"
}
assert {
condition = aws_vpc.main.enable_dns_hostnames == true
error_message = "DNS hostnames should be enabled"
}
}
```
### Apply Test
```hcl
run "full_deployment" {
command = apply
variables {
vpc_cidr = "10.0.0.0/16"
environment = "test"
}
assert {
condition = length(aws_subnet.private) == 3
error_message = "Expected 3 private subnets"
}
}
run "cleanup" {
command = apply
destroy = true
}
```
### Mock Providers
```hcl
mock_provider "aws" {
mock_resource "aws_instance" {
defaults = {
id = "i-mock12345"
}
}
}
run "with_mocks" {
providers = {
aws = aws
}
assert {
condition = aws_instance.web.id != ""
error_message = "Instance ID should be set"
}
}
```
## Terratest (Go)
### Basic Module Test
```go
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
func TestVPCModule(t *testing.T) {
t.Parallel()
opts := terraform.WithDefaultRetryableErrors(t, &terraform.Options{
TerraformDir: "../modules/vpc",
Vars: map[string]interface{}{
"vpc_cidr": "10.0.0.0/16",
"environment": "test",
},
})
defer terraform.Destroy(t, opts)
terraform.InitAndApply(t, opts)
vpcId := terraform.Output(t, opts, "vpc_id")
assert.NotEmpty(t, vpcId)
subnets := terraform.OutputList(t, opts, "private_subnet_ids")
assert.Equal(t, 3, len(subnets))
}
```
### Validation Test
```go
func TestInvalidInput(t *testing.T) {
t.Parallel()
opts := &terraform.Options{
TerraformDir: "../modules/vpc",
Vars: map[string]interface{}{
"vpc_cidr": "invalid-cidr",
},
}
_, err := terraform.InitAndPlanE(t, opts)
assert.Error(t, err)
assert.Contains(t, err.Error(), "Must be a valid CIDR")
}
```
### AWS Resource Verification
```go
import (
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/gruntwork-io/terratest/modules/aws"
)
func TestVPCExists(t *testing.T) {
// ... setup and apply ...
vpcId := terraform.Output(t, opts, "vpc_id")
vpc := aws.GetVpcById(t, vpcId, "us-east-1")
assert.Equal(t, "10.0.0.0/16", *vpc.CidrBlock)
assert.True(t, *vpc.EnableDnsHostnames)
}
```
## Validation Commands
```bash
# Syntax validation
terraform validate
# Format check
terraform fmt -check -recursive
# Plan validation
terraform plan -detailed-exitcode
# Native tests
terraform test
# Terratest
go test -v -timeout 30m ./tests/
```
## Pre-commit Hooks
```yaml
# .pre-commit-config.yaml
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.83.6
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_tflint
- id: terraform_docs
```
## Test Organization
```
module/
├── main.tf
├── variables.tf
├── outputs.tf
├── tests/
│ ├── basic.tftest.hcl # Native tests
│ ├── complete.tftest.hcl
│ └── go/
│ ├── module_test.go # Terratest
│ └── go.mod
└── examples/
├── basic/
└── complete/
```
## Troubleshooting
| Error | Cause | Solution |
|-------|-------|----------|
| Test timeout | Slow resource creation | Increase timeout |
| State conflicts | Parallel tests | Use unique names |
| Cleanup failures | Dependencies | Check destroy order |
## Usage
```python
Skill("terraform-testing")
```
## Related
- **Agent**: 08-terraform-advanced (SECONDARY_BOND)
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.