用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill terraform-iac命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | terraform-iac |
| description | > Use when this capability is needed. |
"If you can't reproduce your infrastructure from code, it's not infrastructure."
Invoked when provisioning cloud infrastructure. Generates Terraform modules following best practices for state management, security, and reusability.
Steps:
terraform/
├── main.tf # Resource definitions
├── variables.tf # Input variables
├── outputs.tf # Output values
├── providers.tf # Provider configuration
├── versions.tf # Terraform and provider version constraints
└── terraform.tfvars # (gitignored) Environment-specific values
Steps:
terraform.tfstate or .tfvars with secrets.Steps:
environments/
├── dev/
│ ├── main.tf → ../../modules/
│ └── terraform.tfvars
├── staging/
└── production/
Steps:
tfsec or checkov to scan for misconfigurations.terraform plan in CI, require approval for apply.| Field | Type | Description |
|---|---|---|
modules | string[] | Generated Terraform module files |
env_configs | string[] | Environment-specific configurations |
state_config | string | Backend configuration |
scan_results | string | Security scan output |
terraform plantfsec, checkov, or trivy configci-pipeline; this skill produces the IaC files the pipeline deploys)kubernetes-helm)terraform.tfstate, .tfvars files with secrets, or provider credentials to version control.apply operation.versions.tf to prevent unexpected upgrades.project, environment, managed-by=terraform.terraform fmt and terraform validate before committing any changes.tfsec / checkov) on every change; do not merge with unresolved critical findings.data sources to reference existing resources — never recreate resources managed outside this configuration.sensitive = true and must never appear in plan output or logs.terraform plan output review in CI before any terraform apply execution.| Situation | Action |
|---|---|
| Single cloud provider, simple project | Use flat module structure with terraform.workspace for env separation |
| Multi-environment with divergent configs | Use directory-per-environment pattern with shared modules |
| Many environments with DRY config needs | Recommend Terragrunt for hierarchical variable inheritance |
| Existing resources not managed by IaC | Use terraform import and generate corresponding resource blocks |
Drift detected in terraform plan | Investigate cause; if intentional manual change, update code to match; if accidental, apply to restore |
| Module is reused across 3+ projects | Publish module to a private registry with semantic versioning |
| Security scanner reports critical finding | Block merge; remediate finding before proceeding |
| State file is corrupted or locked | Use terraform force-unlock (with caution); restore state from backup if corrupted |
| Provider needs upgrading | Pin new version in versions.tf; run terraform init -upgrade; review plan for breaking changes |
terraform validate and terraform fmt checksterraform plan shows expected changes with zero unexpected resource modificationstfsec/checkov) reports zero critical findingsproject, environment, and managed-by labelsvariables.tf and outputs.tf with descriptions for every variablesensitive = true and excluded from logs| Failure | Symptom | Mitigation |
|---|---|---|
| State lock contention | terraform apply fails with "state locked by another process" | Verify no other apply is running; use terraform force-unlock <lock-id> as last resort |
| State drift | terraform plan shows unexpected changes to resources | Run terraform refresh; compare with cloud console; update code or apply to reconcile |
| Provider version incompatibility | terraform init fails or plan shows deprecated resource arguments | Pin compatible provider version in versions.tf; consult provider changelog |
| Secrets committed to repo | .tfvars with credentials appears in git history | Rotate compromised credentials immediately; use git filter-branch or BFG to purge; move secrets to vault |
| Circular module dependency | terraform validate reports cycle in module references | Refactor modules to break circular dependency; use data sources for cross-module references |
| Resource already exists | apply fails with "resource already exists" error | Import existing resource with terraform import; add matching resource block |
| Insufficient permissions | apply fails with "access denied" on resource creation | Verify IAM role/policy attached to Terraform execution identity; follow least-privilege principle |
[timestamp] module-generated: Created Terraform module at <path> for <resource-type> on <provider>[timestamp] state-backend-configured: Set up <backend-type> backend with encryption=<bool>, locking=<bool>[timestamp] environment-created: Generated environment config for <env-name> using <separation-strategy>[timestamp] drift-detected: terraform plan shows <n> unexpected changes in <environment>[timestamp] security-scanned: Ran <scanner> — <critical> critical, <high> high findings[timestamp] resource-imported: Imported <resource-type>.<resource-name> with ID <resource-id>[timestamp] plan-approved: terraform plan reviewed and approved for <environment> with <n> changesSource: dhruvinrsoni/agentskills-garden — distributed by TomeVault.