用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill terraform-troubleshooting命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | terraform-troubleshooting |
| description | >- Use when this capability is needed. |
Turns cryptic failures into actionable next steps. Pair with terraform-refactoring when
the fix is structural and terraform-state when the fix is state surgery.
export TF_LOG=DEBUG
export TF_LOG_PATH=/tmp/terraform.debug.log
terraform plan
Warning: DEBUG may log sensitive values - scrub logs before sharing externally. Revert to INFO
afterwards.
Someone (or CI) holds the lock.
terraform force-unlock <lockid> per runbook - never solo in prod
without evidence.Document lock holder identity in ticket.
terraform plan proving no concurrent mutation expected.Symptoms: “Cycle:” in plan with resource loop.
Mitigations:
depends_on.locals to break?terraform graph helps visualize - keep DOT viewers handy.
Taint is largely legacy - prefer terraform apply -replace=ADDRESS on modern versions. Untaint only
when you understand why resource marked tainted.
AWS RequestLimitExceeded - reduce parallelism:
terraform apply -parallelism=5
Also backoff in CI; consider account-level API quotas increases.
Happened after removing code without removed block/state rm. Options:
import blocks.terraform state rm 'ADDR' if resource intentionally abandoned.removed block to formalize no-management story.Never leave mystery orphans - document decisions.
Symptoms: plan wants to delete everything or create duplicates.
Actions:
terraform workspace list
terraform workspace select prod
Ensure TF_WORKSPACE env not surprising you in CI.
terraform init fails with 403/404:
s3:ListBucket on bucket + prefix.Often provider bug or eventual consistency. Steps:
terraform apply -refresh-only then re-plan.Missing credentials or network path to metadata endpoints - add OIDC env or VPC endpoints for
sts.
Use terraform plan -refresh-only first to separate drift from config changes - then edit code or
fix cloud.
If TF_VAR_* leaked incorrectly, rotate secrets - even if incident seems small.
Collection unknown during plan - depends on resource attributes not computed yet.
Fix patterns:
try/length() restructure - sometimes -target temporary apply (use caution) seeds data.Tokens expired mid-plan - refresh kubeconfig or reduce plan duration; CI may need aws eks update-kubeconfig
each job.
If bad push occurred, restore previous object version with AWS CLI after revoking CI access - treat as incident; update runbooks.
Rare, tactical debugging or partial recovery - not standard operating procedure. If -target needed
often, architecture or state is unhealthy.
Cancel run via UI; verify agent not crashed; check private agent logs if used.
ExternalId wrong, session duration too long, or trust policy mis-scoped - use AWS CLI sts assume-role
outside Terraform to reproduce.
Typo in source, wrong ref tag, or missing credentials to private Git - run git ls-remote manually.
.terraform-version / required_version conflicts - align local/CI.
Backslashes, locked .terraform dirs - run terminal as admin? Prefer Linux CI.
Perhaps wrong directory, stale TF_DATA_DIR, or -refresh=false earlier masked drift - verify commands.
Restore backup state pull, compare JSON, escalate to experts - avoid manual JSON edit unless you enjoy
outages.
Define when Terraform incidents page SRE vs platform vs security - state locking might wait business hours, credential leaks page immediately.
Save TF_LOG excerpts sanitized, plan files, applied commit SHAs - future you needs timeline.
Teach engineers terraform state list | sort muscle memory - sorting reveals duplicates quickly.
Emit OpenTelemetry?? Not native - wrap Terraform in scripts logging duration per stage to your metrics stack if valuable.
Repeated apply attempts worsening partial applies - pause, snapshot state, escalate rested engineers.
Terraform errors look like walls - usually they are puzzles with clues in logs, IAM, and graphs. Systematic wins over random flag toggling.
Re-delete .terraform carefully (not state!) and init again - verify corporate proxy not rewriting
bytes.
Relocate repo closer to C:\src - Terraform + providers + long module names exceed MAX_PATH.
Ensure lock file includes darwin_arm64 - terraform providers lock with explicit platforms.
Version skew between dev Docker and CI - pin same digest everywhere.
Rare parsing issues when files saved wrong encoding - enforce UTF-8 in editorconfigs.
Incident threads get tense - prefer factual bullet updates: impact, hypothesis, next action.
If troubleshooting repeats weekly, schedule refactor sprint - tactical fixes accumulate debt.
Tag resolved incidents Confluence page with error string substring for searchability.
Pre-commit blocking terraform apply without *_ALLOW=1 locally for dangerous roots - prevents habit of
“just applying” during debugging.
When opening HashiCorp/provider tickets, attach minimal reproduction and redacted DEBUG excerpt - speeds triage.
The best troubleshooting is boring: tight versioning, clean modules, peer reviewed state ops, and dashboards that show drift before users do.
Often provider HTTP client timeouts hitting slow endpoints - check corporate proxies, VPC endpoints, or increase provider timeout settings if supported; verify not systemic network outage.
Creates sometimes lag - terraform apply fails then succeeds on retry - wrap CI with limited retry for
known benign cases, but don’t hide real errors - log retries.
count = 0 resources referenced without [0] guards - use one() / try() patterns in modern Terraform
or conditional expressions carefully.
templatefile errors show line numbers - run terraform console with smaller template inputs to bisect.
Provisioner stderr easy to miss - grep logs; prefer replacing provisioners with native resources when possible.
Some APIs return 404 briefly - depends_on alone may be insufficient; use short time_sleep resource
(sparingly) when documented necessary.
Role assignments may fail immediately after SP creation - retry or insert wait resource - coordinate with Azure known issues list.
Clear error with googleapi: Error 403: ... API not enabled - google_project_service ordering must
precede dependents; separate apply waves sometimes needed.
tls_certificate data source must reach sts endpoints - corporate proxies break - document offline
workaround if any.
Read innermost Terraform stderr - wrappers may swallow detail - run plain terraform in same dir with
generated files to compare.
terraform test limitations - ensure values known at plan time or switch assertion timing to post-apply
runs.
Large providers fill /tmp - monitor runner disk; set TMPDIR to larger volume in CI.
Rare stale *.lock.info on local backends - delete cautiously only when sure no concurrent process - prefer
remote backends to avoid this class entirely.
Some provider endpoints may misbehave - verify dual-stack or set correct TF_HTTP_PROXY settings.
NTP drift on VMs breaks AWS signing - ensure hypervisors synced.
Custom CAs must be trusted in Terraform Go TLS - install certs into container images running Terraform.
If troubleshooting tickets exceed team capacity, automation for drift detection and self-service FAQs reduces repeated questions - measure ticket volume weekly.
Blameless postmortems encourage reporting near-misses - those reports prevent future full incidents.
You will still get surprised - that is normal - make surprises rare and recoverable through backups, locks discipline, and calm runbooks.
terraform version
terraform providers
terraform workspace show
terraform state list
terraform state pull > state.json
terraform force-unlock ID # caution
terraform console
Memorize less, bookmark more - consistent URLs in runbooks beat heroic memory.
Copy entire error blocks into tickets - partial screenshots hide causal lines Terraform prints earlier.
Sometimes syntax errors point to previous line missing comma - run terraform fmt to reveal alignment
issues.
Check AWS/Azure/GCP status before deep debugging - hours wasted otherwise.
Stop, snapshot, share logs, involve a peer - the four S’s save production more than frantic clicking.
Source: eclosion-labs/terraform-cursor-plugin — distributed by TomeVault.