Terraform Infrastructure

aj-geddes/useful-ai-prompts/skills/terraform-infrastructure

作者 aj-geddes3f5182cfd739无许可证355 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Infrastructure as Code using Terraform with modular components, state management, and multi-cloud deployments. Use for provisioning and managing cloud resources.

包含脚本DevOps & Cloud
AI 生成的概览

指导 Terraform 基础设施即代码工作:模块、远程状态与多云资源预置。

功能
该技能为使用 Terraform 构建和管理云基础设施提供指导。内容涵盖模块化配置、带锁定的远程状态、变量与输出,以及跨 AWS、Azure、GCP 和本地资源的多云预置。它附带参考指南、配置起始模板和一个用于检查配置的校验脚本。
适用场景
适用于以代码方式预置或管理云基础设施、管理 dev、staging、prod 等多个环境,或搭建远程状态、模块与部署自动化时。也适用于基础设施版本管理、代码评审和环境复制。
运行要求
需要 Terraform(示例要求 1.0 或更高版本)以及目标平台的云服务商凭据。远程状态示例涉及 S3 和用于锁定的 DynamoDB。附带可执行校验脚本和 YAML 配置模板。

Terraform Infrastructure

Table of Contents

Overview

Build scalable infrastructure as code with Terraform, managing AWS, Azure, GCP, and on-premise resources through declarative configuration, remote state, and automated provisioning.

When to Use

  • Cloud infrastructure provisioning
  • Multi-environment management (dev, staging, prod)
  • Infrastructure versioning and code review
  • Cost tracking and resource optimization
  • Disaster recovery and environment replication
  • Automated infrastructure testing
  • Cross-region deployments

Quick Start

Minimal working example:

hcl
# terraform/main.tfterraform {  required_version = ">= 1.0"
  required_providers {    aws = {      source  = "hashicorp/aws"      version = "~> 5.0"    }  }
  # Remote state configuration  backend "s3" {    bucket         = "terraform-state-prod"    key            = "prod/terraform.tfstate"    region         = "us-east-1"    encrypt        = true    dynamodb_table = "terraform-locks"  }}
provider "aws" {  region = var.aws_region
  default_tags {// ... (see reference guides for full implementation)

Reference Guides

Detailed implementations in the references/ directory:

GuideContents
AWS Infrastructure Module [blocked]AWS Infrastructure Module
Variables and Outputs [blocked]Variables and Outputs
Terraform Deployment Script [blocked]Terraform Deployment Script

Best Practices

✅ DO

  • Use remote state (S3, Terraform Cloud)
  • Implement state locking (DynamoDB)
  • Organize code into modules
  • Use workspaces for environments
  • Apply tags consistently
  • Use variables for flexibility
  • Implement code review before apply
  • Keep sensitive data in separate variable files

❌ DON'T

  • Store state files locally in git
  • Use hardcoded values
  • Mix environments in single state
  • Skip terraform plan review
  • Use root module for everything
  • Store secrets in code
  • Disable state locking

来源与署名

来源:aj-geddes/useful-ai-prompts位于skills/terraform-infrastructure提交3f5182c

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架