Terraform Infrastructure
Skill Profile
(Select at least one profile to enable specific modules)
Overview
Terraform is an Infrastructure as Code (IaC) tool that allows you to define and provision cloud infrastructure. This skill covers Terraform basics, providers, resources, modules, state management, remote state, workspaces, and best practices for building reproducible, scalable infrastructure.
Why This Matters
Terraform is critical for modern infrastructure because it:
- Enables Infrastructure as Code for reproducible deployments
- Provides version control for infrastructure changes
- Supports multiple providers (AWS, Azure, GCP, etc.)
- Implements state management for tracking resources
- Enables collaboration through shared state
- Provides planning before applying changes
- Supports modules for reusable infrastructure components
Core Concepts
| Concept |
Description |
| Provider |
Plugin for managing resources (AWS, Azure, GCP) |
| Resource |
Infrastructure component to manage |
| Variable |
Input parameters for configuration |
| Output |
Values returned after apply |
| Module |
Reusable collection of resources |
| State |
Mapping of resources to configuration |
| Workspace |
Separate state for different environments |
Inputs / Outputs / Contracts
Skill Composition
- Depends on: git-workflow
- Compatible with: None
- Conflicts with: None
- Related Skills: docker, kubernetes
Quick Start / Implementation Example
- Review requirements and constraints
- Set up development environment
- Implement core functionality following patterns
- Write tests for critical paths
- Run tests and fix issues
- Document any deviations or decisions
# Example implementation following best practices
def example_function():
# Your implementation here
pass
Assumptions
- Cloud provider account is configured with appropriate permissions
- Terraform CLI is installed
- Network connectivity to cloud provider APIs
- Team has basic understanding of cloud infrastructure
- Version control system (Git) is available
Compatibility & Prerequisites
- Supported Versions:
- Python 3.8+
- Node.js 16+
- Modern browsers (Chrome, Firefox, Safari, Edge)
- Required AI Tools:
- Code editor (VS Code recommended)
- Testing framework appropriate for language
- Version control (Git)
- Dependencies:
- Language-specific package manager
- Build tools
- Testing libraries
- Environment Setup:
.env.example keys: API_KEY, DATABASE_URL (no values)
Test Scenario Matrix (QA Strategy)
| Type |
Focus Area |
Required Scenarios / Mocks |
| Unit |
Core Logic |
Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |
| Integration |
DB / API |
All external API calls or database connections must be mocked during unit tests |
| E2E |
User Journey |
Critical user flows to test |
| Performance |
Latency / Load |
Benchmark requirements |
| Security |
Vuln / Auth |
SAST/DAST or dependency audit |
| Frontend |
UX / A11y |
Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |
Technical Guardrails & Security Threat Model
1. Security & Privacy (Threat Model)
- Top Threats: Injection attacks, authentication bypass, data exposure
2. Performance & Resources
3. Architecture & Scalability
4. Observability & Reliability
Agent Directives
When using Terraform:
- Always run
terraform init before other commands
- Validate configuration with
terraform validate
- Review plan with
terraform plan before applying
- Use remote state for team collaboration
- Encrypt sensitive data in state
- Use modules for reusable infrastructure
- Document all changes in commit messages
Definition of Done (DoD) Checklist
Anti-patterns
- Hardcoding Values: Not using variables for configuration
- No Remote State: Using local state for team collaboration
- No State Locking: Multiple users modifying state simultaneously
- Ignoring State Drift: Not refreshing state regularly
- Large Monolithic Files: Not using modules for organization
- Manual Changes: Modifying resources outside Terraform
Reference Links & Examples
- Internal documentation and examples
- Official documentation and best practices
- Community resources and discussions
Versioning & Changelog
- Version: 1.0.0
- Changelog:
- 2026-02-22: Initial version with complete template structure
Source: AmnadTaowsoam/CerebraSkills — distributed by TomeVault.
1---2name: terraform-infrastructure-43description: Terraform is an Infrastructure as Code (IaC) tool that allows you to Use when this capability is needed.4---56# Terraform Infrastructure78## Skill Profile9*(Select at least one profile to enable specific modules)*10- [ ] **DevOps**11- [x] **Backend**12- [ ] **Frontend**13- [ ] **AI-RAG**14- [ ] **Security Critical**1516## Overview17Terraform is an Infrastructure as Code (IaC) tool that allows you to define and provision cloud infrastructure. This skill covers Terraform basics, providers, resources, modules, state management, remote state, workspaces, and best practices for building reproducible, scalable infrastructure.1819## Why This Matters20Terraform is critical for modern infrastructure because it:2122- **Enables Infrastructure as Code** for reproducible deployments23- **Provides version control** for infrastructure changes24- **Supports multiple providers** (AWS, Azure, GCP, etc.)25- **Implements state management** for tracking resources26- **Enables collaboration** through shared state27- **Provides planning** before applying changes28- **Supports modules** for reusable infrastructure components2930---3132## Core Concepts33| Concept | Description |34|---------|-------------|35| **Provider** | Plugin for managing resources (AWS, Azure, GCP) |36| **Resource** | Infrastructure component to manage |37| **Variable** | Input parameters for configuration |38| **Output** | Values returned after apply |39| **Module** | Reusable collection of resources |40| **State** | Mapping of resources to configuration |41| **Workspace** | Separate state for different environments |4243## Inputs / Outputs / Contracts44#4546## Skill Composition47* **Depends on**: [git-workflow](..\..\01-foundations\git-workflow/SKILL.md)48* **Compatible with**: None49* **Conflicts with**: None50* **Related Skills**: [docker](..\docker-compose/SKILL.md), [kubernetes](..\kubernetes-deployment/SKILL.md)5152## Quick Start / Implementation Example53541. Review requirements and constraints552. Set up development environment563. Implement core functionality following patterns574. Write tests for critical paths585. Run tests and fix issues596. Document any deviations or decisions6061```python62# Example implementation following best practices63def example_function():64 # Your implementation here65 pass66```676869## Assumptions70- Cloud provider account is configured with appropriate permissions71- Terraform CLI is installed72- Network connectivity to cloud provider APIs73- Team has basic understanding of cloud infrastructure74- Version control system (Git) is available7576## Compatibility & Prerequisites7778* **Supported Versions**:79 - Python 3.8+80 - Node.js 16+81 - Modern browsers (Chrome, Firefox, Safari, Edge)82* **Required AI Tools**:83 - Code editor (VS Code recommended)84 - Testing framework appropriate for language85 - Version control (Git)86* **Dependencies**:87 - Language-specific package manager88 - Build tools89 - Testing libraries90* **Environment Setup**:91 - `.env.example` keys: `API_KEY`, `DATABASE_URL` (no values)929394## Test Scenario Matrix (QA Strategy)9596| Type | Focus Area | Required Scenarios / Mocks |97| :--- | :--- | :--- |98| **Unit** | Core Logic | Must cover primary logic and at least 3 edge/error cases. Target minimum 80% coverage |99| **Integration** | DB / API | All external API calls or database connections must be mocked during unit tests |100| **E2E** | User Journey | Critical user flows to test |101| **Performance** | Latency / Load | Benchmark requirements |102| **Security** | Vuln / Auth | SAST/DAST or dependency audit |103| **Frontend** | UX / A11y | Accessibility checklist (WCAG), Performance Budget (Lighthouse score) |104105106## Technical Guardrails & Security Threat Model107108### 1. Security & Privacy (Threat Model)109* **Top Threats**: Injection attacks, authentication bypass, data exposure110- [ ] **Data Handling**: Sanitize all user inputs to prevent Injection attacks. Never log raw PII111- [ ] **Secrets Management**: No hardcoded API keys. Use Env Vars/Secrets Manager112- [ ] **Authorization**: Validate user permissions before state changes113114### 2. Performance & Resources115- [ ] **Execution Efficiency**: Consider time complexity for algorithms116- [ ] **Memory Management**: Use streams/pagination for large data117- [ ] **Resource Cleanup**: Close DB connections/file handlers in finally blocks118119### 3. Architecture & Scalability120- [ ] **Design Pattern**: Follow SOLID principles, use Dependency Injection121- [ ] **Modularity**: Decouple logic from UI/Frameworks122123### 4. Observability & Reliability124- [ ] **Logging Standards**: Structured JSON, include trace IDs `request_id`125- [ ] **Metrics**: Track `error_rate`, `latency`, `queue_depth`126- [ ] **Error Handling**: Standardized error codes, no bare except127- [ ] **Observability Artifacts**:128 - **Log Fields**: timestamp, level, message, request_id129 - **Metrics**: request_count, error_count, response_time130 - **Dashboards/Alerts**: High Error Rate > 5%131132133## Agent Directives134When using Terraform:1351361. **Always run `terraform init`** before other commands1372. **Validate configuration** with `terraform validate`1383. **Review plan** with `terraform plan` before applying1394. **Use remote state** for team collaboration1405. **Encrypt sensitive data** in state1416. **Use modules** for reusable infrastructure1427. **Document all changes** in commit messages143144## Definition of Done (DoD) Checklist145146- [ ] Tests passed + coverage met147- [ ] Lint/Typecheck passed148- [ ] Logging/Metrics/Trace implemented149- [ ] Security checks passed150- [ ] Documentation/Changelog updated151- [ ] Accessibility/Performance requirements met (if frontend)152153154## Anti-patterns1551. **Hardcoding Values**: Not using variables for configuration1562. **No Remote State**: Using local state for team collaboration1573. **No State Locking**: Multiple users modifying state simultaneously1584. **Ignoring State Drift**: Not refreshing state regularly1595. **Large Monolithic Files**: Not using modules for organization1606. **Manual Changes**: Modifying resources outside Terraform161162## Reference Links & Examples163164* Internal documentation and examples165* Official documentation and best practices166* Community resources and discussions167168169## Versioning & Changelog170171* **Version**: 1.0.0172* **Changelog**:173 - 2026-02-22: Initial version with complete template structure174175---176> Source: [AmnadTaowsoam/CerebraSkills](https://github.com/AmnadTaowsoam/CerebraSkills) — distributed by [TomeVault](https://tomevault.io).177<!-- tomevault:4.0:skill_md:2026-06-16 -->