用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill terraform-module-design命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | terraform-module-design |
| description | >- Use when this capability is needed. |
You guide the structure and interface design of Terraform modules in the Catalyst infrastructure/modules/ tree. You enforce the leaf/composite split from AGENTS.md §6 and naming conventions from AGENTS.md.
Leaf modules wrap a single AWS resource type with hardened defaults:
infrastructure/modules/leaf/
kms-key/ # One CMK + alias + rotation + key policy
s3-secure-bucket/ # One bucket + BPA + SSE-KMS + versioning + TLS policy
dynamodb-table/ # One table + on-demand + PITR + KMS + tags
iam-role/ # One role + inline policy via data source
sg-base/ # One SG with named rules
cw-log-group/ # One log group + KMS + retention
sns-topic-encrypted/ # One topic + KMS + subscription policy
Composite modules compose multiple leaf modules and AWS resources into a functional unit:
infrastructure/modules/composite/
network/ # VPC + subnets + endpoints + NAT + flow logs
aurora-serverless-v2/ # Cluster + IAM auth + param group + secret
ecs-fargate-service/ # Cluster + task def + service + ALB + autoscaling + logs
lambda-python-fn/ # Function + role + log group + alias + alarms
...
Rule: a leaf module should have one primary resource and its directly coupled dependencies (e.g., a bucket + its policy + its ACL config). If you're composing 3+ leaf modules, that's a composite.
# variables.tf — inputs
variable "name" {
description = "Resource name (kebab-case, used in AWS identifiers)"
type = string
validation {
condition = can(regex("^[a-z0-9-]+$", var.name))
error_message = "Name must be kebab-case (lowercase alphanumeric and hyphens)."
}
}
variable "environment" {
description = "Deployment environment (dev, stage, prod)"
type = string
validation {
condition = contains(["dev", "stage", "prod"], var.environment)
error_message = "Environment must be dev, stage, or prod."
}
}
variable "kms_key_arn" {
description = "ARN of the KMS key for encryption at rest"
type = string
}
variable "tags" {
description = "Tags to apply to all resources"
type = map(string)
default = {}
}
# outputs.tf — contracts
output "arn" {
description = "ARN of the created resource"
value = aws_s3_bucket.this.arn
}
output "id" {
description = "ID of the created resource"
value = aws_s3_bucket.this.id
}
| What | Convention | Example |
|---|---|---|
| Resource names (DNS, IAM, CW) | kebab-case | catalyst-api-task-role |
| Terraform variables | snake_case | kms_key_arn |
| Terraform locals | snake_case | common_tags |
| Module directory names | kebab-case | s3-secure-bucket |
| Resource labels in HCL | this for the primary resource | aws_s3_bucket.this |
Every module merges caller-provided tags with mandatory defaults:
locals {
common_tags = merge(
{
Project = "catalyst"
Environment = var.environment
ManagedBy = "terraform"
Module = basename(path.module)
},
var.tags,
)
}
Per Platform Engineering for Architects Ch 8 (pp 271-275): tagging is not optional — it drives cost allocation, security scoping (aws:ResourceTag conditions), and observability dimensions.
# Never hardcode account ID or region
data "aws_caller_identity" "current" {}
data "aws_region" "current" {}
locals {
account_id = data.aws_caller_identity.current.account_id
region = data.aws_region.current.name
}
infrastructure/modules/leaf/s3-secure-bucket/
main.tf # Primary resource(s)
variables.tf # Input variables with validation
outputs.tf # Output contracts
versions.tf # required_providers + terraform version constraint
s3-secure-bucket.tftest.hcl # Native test file
README.md # One-paragraph description (auto-generated is fine)
# infrastructure/modules/composite/ecs-fargate-service/main.tf
module "log_group" {
source = "../../leaf/cw-log-group"
name = var.service_name
environment = var.environment
kms_key_arn = var.log_kms_key_arn
tags = local.common_tags
}
module "task_role" {
source = "../../leaf/iam-role"
name = "${var.service_name}-task-role"
trust_principal = "ecs-tasks.amazonaws.com"
policy_document = data.aws_iam_policy_document.task_permissions.json
tags = local.common_tags
}
module "execution_role" {
source = "../../leaf/iam-role"
name = "${var.service_name}-execution-role"
trust_principal = "ecs-tasks.amazonaws.com"
policy_document = data.aws_iam_policy_document.execution_permissions.json
tags = local.common_tags
}
# Task role != execution role — always separate (AGENTS.md §7)
# versions.tf
terraform {
required_version = ">= 1.10"
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
}
main.tf + variables.tf + outputs.tf + versions.tf + .tftest.hclmodule blocks referencing leaf modules*.tfvars in git — environments use per-env files, gitignored.validation block.terraform fmt -check must pass — the CI gate enforces this.Source: Cloud-Byte-Consulting/Catalyst — distributed by TomeVault.