[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6E25S6MGC1DEXFGTPV0P7BQ":3,"skill-same:01M6E25S6MGC1DEXFGTPV0P7BQ":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":39,"linkOnly":40,"markdownContent":41,"markdownBody":42,"frontMatter":43,"refName":47,"commitSha":48,"skillDirectory":49,"forksCount":50,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":6,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6E25S6MGC1DEXFGTPV0P7BQ","terraform-expert",null,"Expert-level Terraform IaC. Use when writing Terraform configs, providers, modules, state management, workspaces, remote backends, Terragrunt, or managing cloud infrastructure. Also use when the user mentions 'tfstate', 'terraform plan', 'terraform apply', 'module', 'provider', 'backend', 'Terragrunt', or 'infrastructure as code'.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F06-terraform-iac\u002Fterraform-expert\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38],"terraform expert","terraform","expert","use","as","module","provider","workspaces","modules","iac","backend","writing","management","coding","plan","cloud","infrastructure as code","state","code","state management","2026-11-10 10:12:30",false,"---\nauthor: luo-kai\nname: terraform-expert\ndescription: Expert-level Terraform IaC. Use when writing Terraform configs, providers, modules, state management, workspaces, remote backends, Terragrunt, or managing cloud infrastructure. Also use when the user mentions 'tfstate', 'terraform plan', 'terraform apply', 'module', 'provider', 'backend', 'Terragrunt', or 'infrastructure as code'.\nlicense: MIT\nmetadata:\n  author: luokai0\n  version: \"1.0\"\n  category: coding\n---\n\n# Terraform Expert\n\nYou are an expert in Terraform and infrastructure as code with deep knowledge of HCL, module design, state management, and multi-cloud patterns.\n\n## Before Starting\n\n1. **Cloud provider** — AWS, GCP, Azure, or multi-cloud?\n2. **Terraform version** — 1.5, 1.6, 1.7, 1.8, OpenTofu?\n3. **State backend** — S3, GCS, Terraform Cloud, Azure Blob?\n4. **Team size** — solo or multiple engineers sharing state?\n5. **Problem type** — writing configs, module design, state issues, CI\u002FCD?\n\n---\n\n## Core Expertise Areas\n\n- **HCL syntax**: variables, locals, outputs, expressions, functions, dynamic blocks\n- **Providers**: version constraints, aliases, multiple providers in one config\n- **Resources & data sources**: lifecycle, depends_on, count vs for_each, import blocks\n- **Modules**: design patterns, input\u002Foutput, versioning, composition, Terraform Registry\n- **State management**: remote backends, locking, state mv\u002Frm\u002Fimport, workspaces\n- **Functions**: string, collection, numeric, filesystem, encoding, hash functions\n- **Terragrunt**: DRY patterns, dependency blocks, run-all, keep_state\n- **CI\u002FCD**: plan\u002Fapply pipelines, Atlantis, Terraform Cloud, GitHub Actions\n\n---\n\n## Key Patterns & Code\n\n### Project Structure\n```\ninfrastructure\u002F\n  modules\u002F\n    vpc\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n      versions.tf\n    eks\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n    rds\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n  environments\u002F\n    prod\u002F\n      main.tf\n      terraform.tfvars\n      backend.tf\n      versions.tf\n    staging\u002F\n      main.tf\n      terraform.tfvars\n    dev\u002F\n      main.tf\n      terraform.tfvars\n  global\u002F\n    main.tf\n    variables.tf\n```\n\n### versions.tf — Always Pin Versions\n```hcl\nterraform {\n  required_version = \">= 1.6.0, \u003C 2.0.0\"\n\n  required_providers {\n    aws = {\n      source  = \"hashicorp\u002Faws\"\n      version = \"~> 5.0\"\n    }\n    kubernetes = {\n      source  = \"hashicorp\u002Fkubernetes\"\n      version = \"~> 2.0\"\n    }\n    random = {\n      source  = \"hashicorp\u002Frandom\"\n      version = \"~> 3.0\"\n    }\n  }\n}\n```\n\n### backend.tf — Remote State with Locking\n```hcl\nterraform {\n  backend \"s3\" {\n    bucket         = \"my-terraform-state-prod\"\n    key            = \"prod\u002Fmain\u002Fterraform.tfstate\"\n    region         = \"us-east-1\"\n    encrypt        = true\n    dynamodb_table = \"terraform-state-lock\"\n  }\n}\n```\n\n### variables.tf — Best Practices\n```hcl\nvariable \"environment\" {\n  description = \"Deployment environment\"\n  type        = string\n\n  validation {\n    condition     = contains([\"dev\", \"staging\", \"prod\"], var.environment)\n    error_message = \"Must be one of: dev, staging, prod\"\n  }\n}\n\nvariable \"vpc_config\" {\n  description = \"VPC configuration\"\n  type = object({\n    cidr_block           = string\n    availability_zones   = list(string)\n    private_subnet_cidrs = list(string)\n    public_subnet_cidrs  = list(string)\n    enable_nat_gateway   = bool\n  })\n}\n\nvariable \"db_password\" {\n  description = \"Database master password\"\n  type        = string\n  sensitive   = true  # never logged or shown in plan\n}\n```\n\n### locals.tf — Computed Values\n```hcl\nlocals {\n  name_prefix = \"${var.project}-${var.environment}\"\n\n  common_tags = merge(var.tags, {\n    Environment = var.environment\n    ManagedBy   = \"terraform\"\n    Repository  = \"github.com\u002Fmyorg\u002Finfrastructure\"\n  })\n\n  is_production = var.environment == \"prod\"\n  instance_type = local.is_production ? \"m5.large\" : \"t3.medium\"\n  multi_az      = local.is_production ? true : false\n}\n```\n\n### Resources — count vs for_each\n```hcl\n# count: simple numeric repetition\nresource \"aws_instance\" \"web\" {\n  count         = var.instance_count\n  ami           = data.aws_ami.ubuntu.id\n  instance_type = var.instance_type\n\n  tags = merge(local.common_tags, {\n    Name = \"${local.name_prefix}-web-${count.index + 1}\"\n  })\n}\n\n# for_each: preferred for unique resources — no index shifting\nresource \"aws_s3_bucket\" \"data\" {\n  for_each = toset([\"raw\", \"processed\", \"archive\"])\n  bucket   = \"${local.name_prefix}-${each.key}-data\"\n\n  tags = merge(local.common_tags, {\n    Name    = \"${local.name_prefix}-${each.key}\"\n    Purpose = each.key\n  })\n}\n\n# for_each with map — full control over each resource\nresource \"aws_iam_user\" \"team\" {\n  for_each = {\n    alice = \"admin\"\n    bob   = \"developer\"\n    carol = \"readonly\"\n  }\n\n  name = each.key\n  tags = { Role = each.value }\n}\n```\n\n### Dynamic Blocks\n```hcl\nresource \"aws_security_group\" \"api\" {\n  name   = \"${local.name_prefix}-api-sg\"\n  vpc_id = module.vpc.vpc_id\n\n  dynamic \"ingress\" {\n    for_each = var.allowed_ports\n    content {\n      from_port   = ingress.value\n      to_port     = ingress.value\n      protocol    = \"tcp\"\n      cidr_blocks = [\"0.0.0.0\u002F0\"]\n      description = \"Allow port ${ingress.value}\"\n    }\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  lifecycle {\n    create_before_destroy = true\n  }\n\n  tags = local.common_tags\n}\n```\n\n### Module Design Pattern\n```hcl\n# modules\u002Frds\u002Fvariables.tf\nvariable \"identifier\"        { type = string }\nvariable \"instance_class\"    { type = string }\nvariable \"database_name\"     { type = string }\nvariable \"master_username\"   { type = string }\nvariable \"master_password\"   { type = string; sensitive = true }\nvariable \"allocated_storage\" { type = number; default = 20 }\nvariable \"multi_az\"          { type = bool;   default = false }\nvariable \"vpc_id\"            { type = string }\nvariable \"subnet_ids\"        { type = list(string) }\nvariable \"tags\"              { type = map(string); default = {} }\n\n# modules\u002Frds\u002Foutputs.tf\noutput \"endpoint\"    { value = aws_db_instance.this.endpoint }\noutput \"port\"        { value = aws_db_instance.this.port }\noutput \"db_name\"     { value = aws_db_instance.this.db_name }\n\n# modules\u002Frds\u002Fmain.tf\nresource \"aws_db_instance\" \"this\" {\n  identifier     = var.identifier\n  engine         = \"postgres\"\n  engine_version = \"15.4\"\n  instance_class = var.instance_class\n\n  db_name  = var.database_name\n  username = var.master_username\n  password = var.master_password\n\n  allocated_storage     = var.allocated_storage\n  max_allocated_storage = var.allocated_storage * 3\n\n  multi_az               = var.multi_az\n  db_subnet_group_name   = aws_db_subnet_group.this.name\n  vpc_security_group_ids = [aws_security_group.rds.id]\n\n  backup_retention_period  = var.multi_az ? 7 : 1\n  deletion_protection      = var.multi_az\n  skip_final_snapshot      = !var.multi_az\n  performance_insights_enabled = true\n\n  tags = var.tags\n}\n\n# Calling the module from environment\nmodule \"database\" {\n  source = \"..\u002F..\u002Fmodules\u002Frds\"\n\n  identifier      = \"${local.name_prefix}-db\"\n  instance_class  = local.is_production ? \"db.r6g.large\" : \"db.t3.medium\"\n  database_name   = \"myapp\"\n  master_username = \"admin\"\n  master_password = var.db_password\n  multi_az        = local.is_production\n  vpc_id          = module.vpc.vpc_id\n  subnet_ids      = module.vpc.private_subnet_ids\n  tags            = local.common_tags\n}\n```\n\n### State Management Commands\n```bash\n# List all resources in state\nterraform state list\n\n# Show details of a specific resource\nterraform state show aws_instance.web[0]\n\n# Rename a resource without destroying it\nterraform state mv aws_instance.web aws_instance.api\n\n# Remove from state but keep real resource\nterraform state rm aws_s3_bucket.old\n\n# Import existing resource into state\nterraform import aws_s3_bucket.my_bucket my-existing-bucket-name\n\n# Terraform 1.5+ declarative import block\n# import {\n#   to = aws_s3_bucket.my_bucket\n#   id = \"my-existing-bucket-name\"\n# }\n\n# Sync state with real infrastructure\nterraform apply -refresh-only\n\n# Targeted apply — use sparingly\nterraform apply -target=module.vpc\n\n# Plan with var file and save output\nterraform plan -var-file=terraform.tfvars -out=tfplan\n\n# Apply the saved plan\nterraform apply tfplan\n```\n\n### Lifecycle Rules\n```hcl\nresource \"aws_db_instance\" \"prod\" {\n  # ...\n\n  lifecycle {\n    # Never delete this resource via Terraform\n    prevent_destroy = true\n\n    # Ignore changes to these fields (e.g. changed outside Terraform)\n    ignore_changes = [\n      engine_version,\n      snapshot_identifier,\n    ]\n\n    # Create new before destroying old (zero downtime)\n    create_before_destroy = true\n  }\n}\n```\n\n### Data Sources\n```hcl\n# Reference existing resources not managed by this config\ndata \"aws_ami\" \"ubuntu\" {\n  most_recent = true\n  owners      = [\"099720109477\"]\n\n  filter {\n    name   = \"name\"\n    values = [\"ubuntu\u002Fimages\u002Fhvm-ssd\u002Fubuntu-22.04-amd64-server-*\"]\n  }\n}\n\ndata \"aws_vpc\" \"existing\" {\n  tags = { Name = \"production-vpc\" }\n}\n\ndata \"aws_caller_identity\" \"current\" {}\ndata \"aws_region\" \"current\" {}\n\n# Use outputs from another state file\ndata \"terraform_remote_state\" \"network\" {\n  backend = \"s3\"\n  config = {\n    bucket = \"my-terraform-state-prod\"\n    key    = \"prod\u002Fnetwork\u002Fterraform.tfstate\"\n    region = \"us-east-1\"\n  }\n}\n\n# Reference it\nresource \"aws_instance\" \"app\" {\n  subnet_id = data.terraform_remote_state.network.outputs.private_subnet_id\n}\n```\n\n---\n\n## Best Practices\n\n- Always pin provider and Terraform versions — never use open-ended constraints\n- Use for_each over count for resources with unique identities\n- Use modules for any pattern used more than once\n- Use remote state with locking — never local state for team projects\n- Run terraform fmt and terraform validate in CI on every PR\n- Use terraform plan -out=tfplan then apply the saved plan in CI pipelines\n- Never use -auto-approve without a saved verified plan\n- Mark all secret variables as sensitive = true\n- Tag every resource with environment, team, and cost-center\n- Use lifecycle prevent_destroy = true for production databases and critical resources\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| Local state | Lost state, no team sharing | Always use remote backend with locking |\n| No version pinning | Breaking changes from provider updates | Pin all provider and Terraform versions |\n| count for unique resources | Index shift causes recreation | Use for_each with string keys |\n| Secrets in tfvars committed to git | Credentials exposed | Use environment variables or secrets manager |\n| No prevent_destroy | Accidental deletion of prod database | Add lifecycle prevent_destroy to critical resources |\n| Monolithic config | Slow plans, hard to maintain | Split into focused modules |\n| Direct apply in CI | No review of changes | Always plan first, apply saved plan |\n| Ignoring drift | Real infra diverges from state | Run terraform apply -refresh-only regularly |\n\n---\n\n## Related Skills\n\n- **aws-expert**: For AWS-specific Terraform resources\n- **kubernetes-expert**: For Terraform EKS and Helm provider\n- **cicd-expert**: For Terraform in CI\u002FCD pipelines\n- **docker-expert**: For ECR and container infrastructure\n- **monitoring-expert**: For Terraform observability resources\n","# Terraform Expert\n\nYou are an expert in Terraform and infrastructure as code with deep knowledge of HCL, module design, state management, and multi-cloud patterns.\n\n## Before Starting\n\n1. **Cloud provider** — AWS, GCP, Azure, or multi-cloud?\n2. **Terraform version** — 1.5, 1.6, 1.7, 1.8, OpenTofu?\n3. **State backend** — S3, GCS, Terraform Cloud, Azure Blob?\n4. **Team size** — solo or multiple engineers sharing state?\n5. **Problem type** — writing configs, module design, state issues, CI\u002FCD?\n\n---\n\n## Core Expertise Areas\n\n- **HCL syntax**: variables, locals, outputs, expressions, functions, dynamic blocks\n- **Providers**: version constraints, aliases, multiple providers in one config\n- **Resources & data sources**: lifecycle, depends_on, count vs for_each, import blocks\n- **Modules**: design patterns, input\u002Foutput, versioning, composition, Terraform Registry\n- **State management**: remote backends, locking, state mv\u002Frm\u002Fimport, workspaces\n- **Functions**: string, collection, numeric, filesystem, encoding, hash functions\n- **Terragrunt**: DRY patterns, dependency blocks, run-all, keep_state\n- **CI\u002FCD**: plan\u002Fapply pipelines, Atlantis, Terraform Cloud, GitHub Actions\n\n---\n\n## Key Patterns & Code\n\n### Project Structure\n```\ninfrastructure\u002F\n  modules\u002F\n    vpc\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n      versions.tf\n    eks\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n    rds\u002F\n      main.tf\n      variables.tf\n      outputs.tf\n  environments\u002F\n    prod\u002F\n      main.tf\n      terraform.tfvars\n      backend.tf\n      versions.tf\n    staging\u002F\n      main.tf\n      terraform.tfvars\n    dev\u002F\n      main.tf\n      terraform.tfvars\n  global\u002F\n    main.tf\n    variables.tf\n```\n\n### versions.tf — Always Pin Versions\n```hcl\nterraform {\n  required_version = \">= 1.6.0, \u003C 2.0.0\"\n\n  required_providers {\n    aws = {\n      source  = \"hashicorp\u002Faws\"\n      version = \"~> 5.0\"\n    }\n    kubernetes = {\n      source  = \"hashicorp\u002Fkubernetes\"\n      version = \"~> 2.0\"\n    }\n    random = {\n      source  = \"hashicorp\u002Frandom\"\n      version = \"~> 3.0\"\n    }\n  }\n}\n```\n\n### backend.tf — Remote State with Locking\n```hcl\nterraform {\n  backend \"s3\" {\n    bucket         = \"my-terraform-state-prod\"\n    key            = \"prod\u002Fmain\u002Fterraform.tfstate\"\n    region         = \"us-east-1\"\n    encrypt        = true\n    dynamodb_table = \"terraform-state-lock\"\n  }\n}\n```\n\n### variables.tf — Best Practices\n```hcl\nvariable \"environment\" {\n  description = \"Deployment environment\"\n  type        = string\n\n  validation {\n    condition     = contains([\"dev\", \"staging\", \"prod\"], var.environment)\n    error_message = \"Must be one of: dev, staging, prod\"\n  }\n}\n\nvariable \"vpc_config\" {\n  description = \"VPC configuration\"\n  type = object({\n    cidr_block           = string\n    availability_zones   = list(string)\n    private_subnet_cidrs = list(string)\n    public_subnet_cidrs  = list(string)\n    enable_nat_gateway   = bool\n  })\n}\n\nvariable \"db_password\" {\n  description = \"Database master password\"\n  type        = string\n  sensitive   = true  # never logged or shown in plan\n}\n```\n\n### locals.tf — Computed Values\n```hcl\nlocals {\n  name_prefix = \"${var.project}-${var.environment}\"\n\n  common_tags = merge(var.tags, {\n    Environment = var.environment\n    ManagedBy   = \"terraform\"\n    Repository  = \"github.com\u002Fmyorg\u002Finfrastructure\"\n  })\n\n  is_production = var.environment == \"prod\"\n  instance_type = local.is_production ? \"m5.large\" : \"t3.medium\"\n  multi_az      = local.is_production ? true : false\n}\n```\n\n### Resources — count vs for_each\n```hcl\n# count: simple numeric repetition\nresource \"aws_instance\" \"web\" {\n  count         = var.instance_count\n  ami           = data.aws_ami.ubuntu.id\n  instance_type = var.instance_type\n\n  tags = merge(local.common_tags, {\n    Name = \"${local.name_prefix}-web-${count.index + 1}\"\n  })\n}\n\n# for_each: preferred for unique resources — no index shifting\nresource \"aws_s3_bucket\" \"data\" {\n  for_each = toset([\"raw\", \"processed\", \"archive\"])\n  bucket   = \"${local.name_prefix}-${each.key}-data\"\n\n  tags = merge(local.common_tags, {\n    Name    = \"${local.name_prefix}-${each.key}\"\n    Purpose = each.key\n  })\n}\n\n# for_each with map — full control over each resource\nresource \"aws_iam_user\" \"team\" {\n  for_each = {\n    alice = \"admin\"\n    bob   = \"developer\"\n    carol = \"readonly\"\n  }\n\n  name = each.key\n  tags = { Role = each.value }\n}\n```\n\n### Dynamic Blocks\n```hcl\nresource \"aws_security_group\" \"api\" {\n  name   = \"${local.name_prefix}-api-sg\"\n  vpc_id = module.vpc.vpc_id\n\n  dynamic \"ingress\" {\n    for_each = var.allowed_ports\n    content {\n      from_port   = ingress.value\n      to_port     = ingress.value\n      protocol    = \"tcp\"\n      cidr_blocks = [\"0.0.0.0\u002F0\"]\n      description = \"Allow port ${ingress.value}\"\n    }\n  }\n\n  egress {\n    from_port   = 0\n    to_port     = 0\n    protocol    = \"-1\"\n    cidr_blocks = [\"0.0.0.0\u002F0\"]\n  }\n\n  lifecycle {\n    create_before_destroy = true\n  }\n\n  tags = local.common_tags\n}\n```\n\n### Module Design Pattern\n```hcl\n# modules\u002Frds\u002Fvariables.tf\nvariable \"identifier\"        { type = string }\nvariable \"instance_class\"    { type = string }\nvariable \"database_name\"     { type = string }\nvariable \"master_username\"   { type = string }\nvariable \"master_password\"   { type = string; sensitive = true }\nvariable \"allocated_storage\" { type = number; default = 20 }\nvariable \"multi_az\"          { type = bool;   default = false }\nvariable \"vpc_id\"            { type = string }\nvariable \"subnet_ids\"        { type = list(string) }\nvariable \"tags\"              { type = map(string); default = {} }\n\n# modules\u002Frds\u002Foutputs.tf\noutput \"endpoint\"    { value = aws_db_instance.this.endpoint }\noutput \"port\"        { value = aws_db_instance.this.port }\noutput \"db_name\"     { value = aws_db_instance.this.db_name }\n\n# modules\u002Frds\u002Fmain.tf\nresource \"aws_db_instance\" \"this\" {\n  identifier     = var.identifier\n  engine         = \"postgres\"\n  engine_version = \"15.4\"\n  instance_class = var.instance_class\n\n  db_name  = var.database_name\n  username = var.master_username\n  password = var.master_password\n\n  allocated_storage     = var.allocated_storage\n  max_allocated_storage = var.allocated_storage * 3\n\n  multi_az               = var.multi_az\n  db_subnet_group_name   = aws_db_subnet_group.this.name\n  vpc_security_group_ids = [aws_security_group.rds.id]\n\n  backup_retention_period  = var.multi_az ? 7 : 1\n  deletion_protection      = var.multi_az\n  skip_final_snapshot      = !var.multi_az\n  performance_insights_enabled = true\n\n  tags = var.tags\n}\n\n# Calling the module from environment\nmodule \"database\" {\n  source = \"..\u002F..\u002Fmodules\u002Frds\"\n\n  identifier      = \"${local.name_prefix}-db\"\n  instance_class  = local.is_production ? \"db.r6g.large\" : \"db.t3.medium\"\n  database_name   = \"myapp\"\n  master_username = \"admin\"\n  master_password = var.db_password\n  multi_az        = local.is_production\n  vpc_id          = module.vpc.vpc_id\n  subnet_ids      = module.vpc.private_subnet_ids\n  tags            = local.common_tags\n}\n```\n\n### State Management Commands\n```bash\n# List all resources in state\nterraform state list\n\n# Show details of a specific resource\nterraform state show aws_instance.web[0]\n\n# Rename a resource without destroying it\nterraform state mv aws_instance.web aws_instance.api\n\n# Remove from state but keep real resource\nterraform state rm aws_s3_bucket.old\n\n# Import existing resource into state\nterraform import aws_s3_bucket.my_bucket my-existing-bucket-name\n\n# Terraform 1.5+ declarative import block\n# import {\n#   to = aws_s3_bucket.my_bucket\n#   id = \"my-existing-bucket-name\"\n# }\n\n# Sync state with real infrastructure\nterraform apply -refresh-only\n\n# Targeted apply — use sparingly\nterraform apply -target=module.vpc\n\n# Plan with var file and save output\nterraform plan -var-file=terraform.tfvars -out=tfplan\n\n# Apply the saved plan\nterraform apply tfplan\n```\n\n### Lifecycle Rules\n```hcl\nresource \"aws_db_instance\" \"prod\" {\n  # ...\n\n  lifecycle {\n    # Never delete this resource via Terraform\n    prevent_destroy = true\n\n    # Ignore changes to these fields (e.g. changed outside Terraform)\n    ignore_changes = [\n      engine_version,\n      snapshot_identifier,\n    ]\n\n    # Create new before destroying old (zero downtime)\n    create_before_destroy = true\n  }\n}\n```\n\n### Data Sources\n```hcl\n# Reference existing resources not managed by this config\ndata \"aws_ami\" \"ubuntu\" {\n  most_recent = true\n  owners      = [\"099720109477\"]\n\n  filter {\n    name   = \"name\"\n    values = [\"ubuntu\u002Fimages\u002Fhvm-ssd\u002Fubuntu-22.04-amd64-server-*\"]\n  }\n}\n\ndata \"aws_vpc\" \"existing\" {\n  tags = { Name = \"production-vpc\" }\n}\n\ndata \"aws_caller_identity\" \"current\" {}\ndata \"aws_region\" \"current\" {}\n\n# Use outputs from another state file\ndata \"terraform_remote_state\" \"network\" {\n  backend = \"s3\"\n  config = {\n    bucket = \"my-terraform-state-prod\"\n    key    = \"prod\u002Fnetwork\u002Fterraform.tfstate\"\n    region = \"us-east-1\"\n  }\n}\n\n# Reference it\nresource \"aws_instance\" \"app\" {\n  subnet_id = data.terraform_remote_state.network.outputs.private_subnet_id\n}\n```\n\n---\n\n## Best Practices\n\n- Always pin provider and Terraform versions — never use open-ended constraints\n- Use for_each over count for resources with unique identities\n- Use modules for any pattern used more than once\n- Use remote state with locking — never local state for team projects\n- Run terraform fmt and terraform validate in CI on every PR\n- Use terraform plan -out=tfplan then apply the saved plan in CI pipelines\n- Never use -auto-approve without a saved verified plan\n- Mark all secret variables as sensitive = true\n- Tag every resource with environment, team, and cost-center\n- Use lifecycle prevent_destroy = true for production databases and critical resources\n\n---\n\n## Common Pitfalls\n\n| Pitfall | Problem | Fix |\n|---|---|---|\n| Local state | Lost state, no team sharing | Always use remote backend with locking |\n| No version pinning | Breaking changes from provider updates | Pin all provider and Terraform versions |\n| count for unique resources | Index shift causes recreation | Use for_each with string keys |\n| Secrets in tfvars committed to git | Credentials exposed | Use environment variables or secrets manager |\n| No prevent_destroy | Accidental deletion of prod database | Add lifecycle prevent_destroy to critical resources |\n| Monolithic config | Slow plans, hard to maintain | Split into focused modules |\n| Direct apply in CI | No review of changes | Always plan first, apply saved plan |\n| Ignoring drift | Real infra diverges from state | Run terraform apply -refresh-only regularly |\n\n---\n\n## Related Skills\n\n- **aws-expert**: For AWS-specific Terraform resources\n- **kubernetes-expert**: For Terraform EKS and Helm provider\n- **cicd-expert**: For Terraform in CI\u002FCD pipelines\n- **docker-expert**: For ECR and container infrastructure\n- **monitoring-expert**: For Terraform observability resources\n",{"name":5,"author":44,"license":15,"metadata":45,"description":7},"luo-kai",{"author":9,"version":46,"category":32},"1.0","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F06-terraform-iac\u002Fterraform-expert",2,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill terraform-expert",{"tool":61,"command":62},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill terraform-expert",{"tool":64,"command":65},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill terraform-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F05-devops-and-cloud (by Luo Kai)\u002F06-terraform-iac\u002Fterraform-expert\u002FSKILL.md",true,[],[70,97,114,137,163,188],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":39},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":39},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[104,105,106,107,108,109,110,111,112,113],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":120,"publishedAt":39},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[],[121,122,123,124,125,126,127,37,105,128,33,129,77,130,131,132,133,134,135,136],"build","solo","solo build","MCP","workflow","commit","tasks","Bash","read","auto","references","context7","query","scaffolding","ship it","project",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":39},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[],[144,145,146,147,148,149,150,151,152,153,154,155,156,22,157,158,159,160,161,162],"react","email","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","html","resend","visual","emails","rendering","with",{"skillNo":164,"name":165,"nameZh":6,"description":166,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":167,"categories":168,"keywords":169,"publishedAt":39},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[],[170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":194,"publishedAt":39},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[33,195,196,197,198,199,200,83,201,202,203,204,205,22,206,207,162,208],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]