nuxt-terraform
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNuxt + Terraform Scaffold Skill
Nuxt + Terraform 脚手架 Skill
Generate files for Nuxt + AWS infrastructure projects. This skill replaces the CLI — generate all files directly.
为 Nuxt + AWS 基础设施项目生成所需文件。该 Skill 可替代 CLI,直接生成全部所需文件。
Pre-Requisites
前置要求
Read for (PascalCase), , and custom paths. If no config exists, ask the user for these values.
terraform-scaffold.config.tsfunctionPrefixenvironments读取 中的 (PascalCase 格式)、 以及自定义路径。如果不存在配置文件,需向用户询问这些参数值。
terraform-scaffold.config.tsfunctionPrefixenvironmentsNaming Conventions
命名约定
| Concept | Convention | Example |
|---|---|---|
| Function prefix | PascalCase | |
| Full Lambda name | | |
| Resolver name | camelCase | |
| GraphQL constant | SCREAMING_SNAKE_CASE | |
| TF module name | | |
| TF lambda module | | |
| Composable file | | |
| GraphQL file | | |
| TF file per model | | |
| DynamoDB datasource | | |
| DynamoDB table | | |
| Query index | | |
String conversions: splits on uppercase, joins with , uppercases. capitalizes first letter. lowercases first letter.
toScreamingSnake_toPascallcfirst| 概念 | 约定规则 | 示例 |
|---|---|---|
| 函数前缀 | PascalCase | |
| Lambda完整名称 | | |
| 解析器名称 | camelCase | |
| GraphQL常量 | SCREAMING_SNAKE_CASE | |
| TF模块名称 | | |
| TF Lambda模块 | | |
| 可组合函数文件 | | |
| GraphQL文件 | | |
| 单模型对应的TF文件 | | |
| DynamoDB数据源 | | |
| DynamoDB表 | | |
| 查询索引 | | |
字符串转换规则: 按大写字母拆分,用 拼接后全部转为大写; 将首字母大写; 将首字母小写。
toScreamingSnake_toPascallcfirstCommand 1: Init
命令1:初始化
Ask user for: project name, function prefix (PascalCase), AWS profile, AWS region (default: ), S3 state bucket, DynamoDB lock table.
ap-southeast-2AWS Profile Selection: Parse and for profile names. Present numbered list. Allow "add new" via .
~/.aws/credentials~/.aws/configaws configure --profile <name>Read references/init-workflow.md for directory structure, template placeholders, static files, scripts, and package.json entries. Consult references/terraform-modules.md for all 18 reusable module signatures.
需要向用户询问以下信息:项目名称、函数前缀(PascalCase格式)、AWS配置文件、AWS区域(默认值:)、S3状态存储桶、DynamoDB锁表。
ap-southeast-2AWS配置文件选择:解析 和 中的配置文件名称,展示编号列表,允许用户通过 添加新配置。
~/.aws/credentials~/.aws/configaws configure --profile <名称>阅读 references/init-workflow.md 了解目录结构、模板占位符、静态文件、脚本和package.json配置项。参考 references/terraform-modules.md 查看全部18个可复用模块的签名。
Command 2: GraphQL Resolver
命令2:GraphQL 解析器
Ask user for:
- Model name — type from
@model(PascalCase)schema.graphql - Resolver type — or
querymutation - Resolver name — camelCase (e.g. )
productById - Runtime — or
APPSYNC_JSLAMBDA - DynamoDB operation (APPSYNC_JS only) — ,
GetItem,Query,PutItem,UpdateItem,ScanBatchDeleteItem - Fields — model fields as arguments + optional extras (,
payload: AWSJSON,filter: AWSJSON,limit: Int)nextToken: String
Read references/resolver-workflow.md for all generation templates: schema injection, GraphQL constant, Terraform modules (APPSYNC_JS and LAMBDA), dependency modules, AppSync JS functions, Lambda source, and composable generation.
需要向用户询问以下信息:
- 模型名称 — 中的
schema.graphql类型(PascalCase格式)@model - 解析器类型 — 或
querymutation - 解析器名称 — camelCase格式(例如 )
productById - 运行时 — 或
APPSYNC_JSLAMBDA - DynamoDB操作(仅APPSYNC_JS运行时需要) — 、
GetItem、Query、PutItem、UpdateItem、ScanBatchDeleteItem - 字段 — 作为参数的模型字段 + 可选额外字段(、
payload: AWSJSON、filter: AWSJSON、limit: Int)nextToken: String
阅读 references/resolver-workflow.md 了解所有生成模板:schema注入、GraphQL常量、Terraform模块(APPSYNC_JS和LAMBDA两种)、依赖模块、AppSync JS函数、Lambda源码、可组合函数生成。
Command 3: Lambda Function
命令3:Lambda 函数
Ask user for:
- Name — PascalCase suffix (e.g. )
RedeemNow - Type — or
standardcron - Schedule (cron only) — EventBridge expression (e.g. )
rate(5 minutes)
Read references/lambda-workflow.md for Lambda source files, TF module block, cron resources, and dependency checks.
需要向用户询问以下信息:
- 名称 — PascalCase格式的后缀(例如 )
RedeemNow - 类型 — 或
standardcron - 调度规则(仅cron类型需要) — EventBridge表达式(例如 )
rate(5 minutes)
阅读 references/lambda-workflow.md 了解Lambda源文件、TF模块块、cron资源和依赖检查规则。
Rules
规则
Idempotency — never overwrite existing files during init. Skip if TF module, schema field, GraphQL constant, composable function, or Lambda source already exists. When appending, trim trailing whitespace and add newline before new content.
Pre-generation checklist:
- Read for
terraform-scaffold.config.tsfunctionPrefix - Read for existing models and fields
schema.graphql - Check TF files, graphql/ files, and composables for duplicates
- Follow exact naming conventions from the table above
- Verify module dependencies exist; generate if missing (see resolver-workflow.md dependency modules section)
Post-generation validation: Run on modified files, then . If providers not initialized, skip and inform user to run first.
terraform fmt.tfterraform validateterraform init幂等性 — 初始化过程中永远不要覆盖已有文件。如果TF模块、schema字段、GraphQL常量、可组合函数或Lambda源码已存在则跳过。追加内容时,修剪尾部空白,在新内容前添加换行符。
生成前检查清单:
- 读取 获取
terraform-scaffold.config.tsfunctionPrefix - 读取 获取现有模型和字段
schema.graphql - 检查TF文件、graphql/目录下文件、可组合函数是否有重复
- 严格遵守上表中的命名约定
- 验证模块依赖是否存在,缺失则生成(参考resolver-workflow.md的依赖模块章节)
生成后校验:对修改过的 文件执行 ,然后执行 。如果provider未初始化,跳过校验并告知用户先运行 。
.tfterraform fmtterraform validateterraform init