Creates RPC-style endpoint following layered architecture (Controller → Manager → Repository). Use when creating new API endpoints or CRUD operations.
中文简介正在准备中。当前显示原文说明。
Create or extend reusable Terraform modules with proper structure, interfaces, and documentation. Use when building new infrastructure modules or extending existing ones.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Creates or extends reusable Terraform modules following standard conventions for structure, interfaces, and composition.
Ask the user:
rds, ecs-service, s3-bucket)modules/{module-name}/
main.tf # Core resource or locals
variables.tf # All input variables
outputs.tf # All outputs
{resource}.tf # One file per resource type
versions.tf # Provider version constraints
README.md # Auto-generated usage docs
# variables.tf — explicit interfaces, no hardcoded defaults for critical values
variable "name" {
description = "Resource name prefix"
type = string
validation {
condition = can(regex("^[a-z][a-z0-9-]+$", var.name))
error_message = "Name must be lowercase alphanumeric with hyphens."
}
}
variable "vpc_id" {
description = "VPC ID where resources are deployed"
type = string
}
variable "subnet_ids" {
description = "Subnet IDs for resource placement"
type = list(string)
}
variable "tags" {
description = "Additional tags to apply to all resources"
type = map(string)
default = {}
}
# Use object types for grouped config
variable "backup" {
description = "Backup configuration"
type = object({
enabled = bool
retention_days = number
window = optional(string, "03:00-04:00")
})
default = {
enabled = true
retention_days = 7
}
}
# rds.tf — one resource type per file
resource "aws_db_instance" "this" {
identifier = var.name
engine = var.engine
engine_version = var.engine_version
instance_class = var.instance_class
allocated_storage = var.allocated_storage
max_allocated_storage = var.max_allocated_storage
db_name = var.db_name
username = var.master_username
password = var.master_password
db_subnet_group_name = aws_db_subnet_group.this.name
vpc_security_group_ids = [aws_security_group.rds.id]
backup_retention_period = var.backup.retention_days
backup_window = var.backup.window
deletion_protection = var.deletion_protection
tags = merge(var.tags, {
Name = var.name
})
}
resource "aws_db_subnet_group" "this" {
name = "${var.name}-subnet-group"
subnet_ids = var.subnet_ids
tags = merge(var.tags, {
Name = "${var.name}-subnet-group"
})
}
# sg.tf
resource "aws_security_group" "rds" {
name_prefix = "${var.name}-rds-"
vpc_id = var.vpc_id
description = "Security group for ${var.name} RDS instance"
tags = merge(var.tags, {
Name = "${var.name}-rds-sg"
})
lifecycle {
create_before_destroy = true
}
}
resource "aws_security_group_rule" "rds_ingress" {
type = "ingress"
from_port = 5432
to_port = 5432
protocol = "tcp"
security_group_id = aws_security_group.rds.id
source_security_group_id = var.app_security_group_id
description = "Allow access from application"
}
# outputs.tf — expose values that consumers need
output "endpoint" {
description = "Database connection endpoint"
value = aws_db_instance.this.endpoint
}
output "port" {
description = "Database port"
value = aws_db_instance.this.port
}
output "security_group_id" {
description = "Security group ID for the database"
value = aws_security_group.rds.id
}
output "arn" {
description = "ARN of the database instance"
value = aws_db_instance.this.arn
}
# Mark sensitive outputs
output "connection_string" {
description = "Full connection string"
value = "postgresql://${var.master_username}:${var.master_password}@${aws_db_instance.this.endpoint}/${var.db_name}"
sensitive = true
}
# versions.tf
terraform {
required_version = ">= 1.5.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.0"
}
}
}
New modules should be contributed to the c0x12c Terraform Registry:
https://github.com/c0x12c/terraform-aws-{module-name} following the Terraform registry naming conventionversions.tf, variables.tf, outputs.tfgit tag v0.1.0 && git push --tagssource = "c0x12c/{module-name}/aws" with version = "~> 0.1.0"# How consumers call this module — use c0x12c registry
module "database" {
source = "c0x12c/rds/aws"
version = "~> 0.6.6"
name = "${local.name_prefix}-db"
engine = "postgres"
engine_version = "15.4"
instance_class = "db.t3.micro"
allocated_storage = 20
db_name = "myservice"
master_username = "admin"
master_password = var.db_password
vpc_id = local.vpc_id
subnet_ids = local.private_subnet_ids
app_security_group_id = module.ecs_service.security_group_id
deletion_protection = var.env == "prod"
backup = {
enabled = true
retention_days = var.env == "prod" ? 30 : 7
}
tags = local.common_tags
}
this as the resource name for the primary resourcename_prefix over name for security groups (allows create-before-destroy)sensitive = trueobject() types for grouped configurationoptional() for fields with sensible defaultsversions.tf, not main.tfProduces a module directory:
modules/{module-name}/
main.tf
variables.tf
outputs.tf
versions.tf
sg.tf
{resource-1}.tf
{resource-2}.tf
Plus a usage snippet for consumers to copy.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Creates RPC-style endpoint following layered architecture (Controller → Manager → Repository). Use when creating new API endpoints or CRUD operations.
中文简介正在准备中。当前显示原文说明。
Write blog posts, guides, tutorials, and long-form content. Sounds like a real person, not AI. Use when the user wants polished written content.
中文简介正在准备中。当前显示原文说明。
Design RPC-style APIs with layered architecture (Controller → Manager → Repository). Use when creating new API endpoints, designing API contracts, or reviewing API patterns.
中文简介正在准备中。当前显示原文说明。
Run a structured brainstorm session for startup ideas. Takes a theme or problem and generates ideas with quick gut-checks. Use when the user wants to explore a space or generate new ideas.
中文简介正在准备中。当前显示原文说明。
Run real browser QA with Playwright. Use when testing a frontend feature, verifying UI before PR, smoke testing after deploy, or investigating reported visual bugs.
中文简介正在准备中。当前显示原文说明。
CI/CD pipeline patterns for GitHub Actions, PR automation, and deployment workflows. Use when setting up CI, fixing broken pipelines, automating PR checks, or configuring deployment.
中文简介正在准备中。当前显示原文说明。