Terraform 助手
- 作者仓库星标 0
- 作者仓库 skills-registry
Terraform / Infrastructure as Code
Manage infrastructure with Terraform.
Core Concepts
State Management
- Store state remotely (S3, Terraform Cloud)
- Enable state locking (DynamoDB)
- Never edit state manually (use
terraform statecommands) - Isolate environments with workspaces or directories
Structure
terraform/
├── modules/
│ ├── networking/
│ ├── compute/
│ └── database/
├── environments/
│ ├── dev/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ └── terraform.tfvars
│ ├── staging/
│ └── production/
└── backend.tf
Module Design
Module Interface
# modules/compute/main.tf
variable "instance_type" { type = string }
variable "subnet_id" { type = string }
output "instance_id" { value = aws_instance.app.id }
Module Best Practices
- Input validation (type constraints, validation blocks)
- Outputs for all useful values
- Versioned modules (Git tags, registry)
- Documentation (README per module)
- Test with Terratest
Remote Backend
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "production/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}
Multi-Environment Strategy
- Workspaces: Simple, state separation only
- Directory structure: Full isolation, can diff configs
- Terragrunt: DRY config, repeatable structure
- Always: Plan in CI, approve, then apply
- No manual applies in production
<!-- tomevault:4.0:skill_md:2026-05-22 -->Source: cosmicstack-labs/mercury-agent-skills — distributed by TomeVault.
- 流狐分类
- 运维部署
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 即装即用
- 是否需要外部 API Key
- 未发现要求
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Core Concepts
Core Concepts
State Management
Store state remotely (S3, Terraform Cloud) Enable state locking (DynamoDB) Never edit state manually (use terraform state commands)
Structure
Structure
Module Design
Module Design
Module Interface
Module Interface
Module Best Practices
Input validation (type constraints, validation blocks) Outputs for all useful values Versioned modules (Git tags, registry)
# Terraform / Infrastructure as Code
Manage infrastructure with Terraform.
## Core Concepts
### State Management
- Store state remotely (S3, Terraform Cloud)
- Enable state locking (DynamoDB)
- Never edit state manually (use `terraform state` commands)
- Isolate environments with workspaces or directories
### Structure
```
terraform/
├── modules/
│ ├── networking/
│ ├── compute/
│ └── database/
├── environments/
│ ├── dev/
│ │ ├── main.tf
│ │ ├── variables.tf
│ │ └── terraform.tfvars
│ ├── staging/
│ └── production/
└── backend.tf
```
## Module Design
### Module Interface
```hcl
# modules/compute/main.tf
variable "instance_type" { type = string }
variable "subnet_id" { type = string }
output "instance_id" { value = aws_instance.app.id }
```
### Module Best Practices
- Input validation (type constraints, validation blocks)
- Outputs for all useful values
- Versioned modules (Git tags, registry)
- Documentation (README per module)
- Test with Terratest
## Remote Backend
```hcl
terraform {
backend "s3" {
bucket = "my-terraform-state"
key = "production/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-locks"
encrypt = true
}
}
```
## Multi-Environment Strategy
1. **Workspaces**: Simple, state separation only
2. **Directory structure**: Full isolation, can diff configs
3. **Terragrunt**: DRY config, repeatable structure
4. **Always**: Plan in CI, approve, then apply
5. **No manual applies** in production
---
> Source: [cosmicstack-labs/mercury-agent-skills](https://github.com/cosmicstack-labs/mercury-agent-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 --> 证据边界与执行链路
作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Core Concepts → State Management → Structure → Module Design → Module Interface → Module Best Practices
要点 -> Workspaces · Directory structure · Terragrunt · Always · No manual applies
文件/命令 -> terraform state · modules/compute/main.tf · production/terraform.tfstate · cosmicstack-labs/mercury-agent-skills · github.com/cosmicstack-labs/mercury-agent-skills
内容 SHA-256 -> e6ae34083e24
方法与流程
适用与边界
原文中的明确线索
terraform state、modules/compute/main.tf、production/terraform.tfstate、cosmicstack-labs/mercury-agent-skills、github.com/cosmicstack-labs/mercury-agent-skills