AgentSkillsCN

terraform-module

指导如何在此仓库中创建或修改 Terraform 模块。当被要求更改资源、变量、输出、数据源,或模块时,可使用此技能。

SKILL.md
--- frontmatter
name: terraform-module
description: Guide for creating or modifying Terraform modules in this repository. Use when asked to change resources, variables, outputs, data sources, or modules.

Terraform Module

Context

I need to modify or extend Terraform configuration for GCP governance (custom roles, policies, assignments).

Codebase Discovery

Analyze existing files with #codebase and:

  • #file:src/01_custom_roles/
  • #file:src/02_policy_custom/
  • #file:src/03_policy_assignments/

Input Required

  • Modification type: ${input:type:resource,variable,output,data_source,module}
  • Description: ${input:description}

Conventions

  • Use snake_case for resources and variables
  • Always add description to variables
  • Use try() for optional values
  • Follow the folder naming convention: 0X_{type}/

Provider

hcl
terraform {
  required_version = ">= 1.7.0"

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "6.28.0"
    }
  }

  backend "gcs" {
    bucket = "tfapporg-terraform-state"
    prefix = "gcp-governance"
  }
}

provider "google" {
  project = var.project_id
  region  = "europe-west8"
}

Validations

  • Always add description to variables
  • Use try() for optional values in JSON
  • Check with #problems for any errors after modifications
  • Run terraform fmt before committing

References

Follow conventions in #file:.github/copilot-instructions.md