Loading...
Loading...
Compare original and translation side by side
project-root/
├── bin/
│ └── app.ts # Entry point: load config → instantiate stacks
├── config/ # DATA LAYER — pure TypeScript data, no AWS constructs
│ ├── types.ts # All configuration interfaces
│ ├── environments.ts # Environment registry: Record<string, EnvironmentConfig>
│ ├── shared/ # Constants shared across all environments
│ └── [env]/ # One folder per environment (sandbox, dev, uat, prod…)
│ ├── index.ts # Merges per-resource configs into EnvironmentConfig
│ ├── env.ts # IntraEnvConfig (envName, prefix, account, region, tags)
│ ├── vpc.ts # VPC settings
│ ├── alb.ts # ALB settings
│ └── … # One file per resource type
├── lib/ # LOGIC LAYER — reusable stacks & constructs
│ ├── common/ # (optional) Shared aspects, extended L2 constructs
│ ├── network-stack.ts # One file per stack — flat layout
│ └── database-stack.ts
├── test/ # QUALITY LAYER — fine-grained assertion tests
│ ├── network-stack.test.ts # One test file per stack
│ └── config.test.ts # Config validation tests
├── .gitignore
├── .eslintrc.json
├── .prettierrc
├── jest.config.js
├── tsconfig.json
└── package.jsonreferences/structure.mdproject-root/
├── bin/
│ └── app.ts # 入口文件:加载配置 → 实例化堆栈
├── config/ # 数据层 — 纯TypeScript数据,无AWS构造
│ ├── types.ts # 所有配置接口
│ ├── environments.ts # 环境注册表:Record<string, EnvironmentConfig>
│ ├── shared/ # 所有环境共享的常量
│ └── [env]/ # 每个环境对应一个文件夹(sandbox、dev、uat、prod…)
│ ├── index.ts # 将各资源配置合并为EnvironmentConfig
│ ├── env.ts # IntraEnvConfig(环境名称、前缀、账号、区域、标签)
│ ├── vpc.ts # VPC设置
│ ├── alb.ts # ALB设置
│ └── … # 每种资源类型对应一个文件
├── lib/ # 逻辑层 — 可复用的堆栈与构造
│ ├── common/ # (可选)共享组件、扩展的L2构造
│ ├── network-stack.ts # 每个堆栈对应一个文件 — 扁平化布局
│ └── database-stack.ts
├── test/ # 质量层 — 细粒度断言测试
│ ├── network-stack.test.ts # 每个堆栈对应一个测试文件
│ └── config.test.ts # 配置验证测试
├── .gitignore
├── .eslintrc.json
├── .prettierrc
├── jest.config.js
├── tsconfig.json
└── package.jsonreferences/structure.mdconfig/references/structure.mdreferences/constructs.mdconfig/[env]/enabledbin/app.tsIntraEnvConfigreferences/config-pattern.mdcdk-nagAwsSolutionsChecksuatpreprodprodreferences/security.mdTemplate.fromStack()references/testing.mdreferences/versions.mdreferences/versions.mdreferences/versions.mdnpm run clean.js.d.tsCfnOutputFn.importValuedesigns/<app-name>/design.mdreferences/design-handoff.mdprojects/<app-name>/config/references/structure.mdreferences/constructs.mdconfig/[env]/bin/app.tsenabledIntraEnvConfigreferences/config-pattern.mdcdk-nagAwsSolutionsChecksuatpreprodprodreferences/security.mdTemplate.fromStack()references/testing.mdreferences/versions.mdreferences/versions.mdreferences/versions.mdnpm run clean.js.d.tsCfnOutputFn.importValuedesigns/<app-name>/design.mdreferences/design-handoff.mdprojects/<app-name>/config/lib/bin/anyconfig/types.tsconfig.[resource].enabledbin/app.tslib/config/[env]/vpc.tsalb.tsaurora.tsreferences/versions.mdconfig/[env]/${projectName}-${envName}-<resource>-<purpose>myproject-dev-ecs-clustermyproject-dev-sqs-order-queue${projectName}-${envName}-s3-<purpose>-${account}myproject-dev-s3-assets-123456789012<purpose>IntraEnvConfiglib/pre-prodfrontendfereferences/naming-limits.mdcdk bootstrap aws://<account>/<region>cdk deploy[!TIP] Need more details? Read:
— Project layout, layer responsibilities, config patternsreferences/structure.md — Construct hierarchy, L2-First rule, escape hatches, custom resourcesreferences/constructs.md — TypeScript best practices, naming conventions, interfaces, utility typesreferences/config-pattern.md — TDD approach, fine-grained assertions, unit test templatesreferences/testing.md — cdk-nag, Checkov, documentation with TypeDoc, versioning & releasereferences/security.md — Pinned dependency versions, standardized configs, upgrade/downgrade proceduresreferences/versions.md — Design doc handoff patterns: multi-service, existing VPC/ALB, CloudFront, DNS, SG, IAM, WAFreferences/design-handoff.md
config/lib/bin/anyconfig/types.tsbin/app.tsconfig.[resource].enabledlib/config/[env]/vpc.tsalb.tsaurora.tsreferences/versions.mdconfig/[env]/${projectName}-${envName}-<resource>-<purpose>myproject-dev-ecs-clustermyproject-dev-sqs-order-queue${projectName}-${envName}-s3-<purpose>-${account}myproject-dev-s3-assets-123456789012<purpose>IntraEnvConfiglib/pre-prodfrontendfereferences/naming-limits.mdcdk deploycdk bootstrap aws://<account>/<region>[!提示] 需要更多细节?请阅读:
— 项目布局、层级职责、配置模式references/structure.md — 构造层级、优先使用L2规则、逃逸舱、自定义资源references/constructs.md — TypeScript最佳实践、命名规范、接口、工具类型references/config-pattern.md — 测试驱动开发(TDD)方法、细粒度断言、单元测试模板references/testing.md — cdk-nag、Checkov、TypeDoc文档、版本管理与发布references/security.md — 固定依赖版本、标准化配置、升级/降级流程references/versions.md — 设计文档交接模式:多服务、现有VPC/ALB、CloudFront、DNS、安全组、IAM、WAFreferences/design-handoff.md
designs/<app-name>/design.mddesigns/<app-name>/design.md| Design Doc Section | CDK Output |
|---|---|
| App Identity | |
| Services table | |
| Environment Matrix | per-env folders with correct enabled flags |
| Existing Infrastructure | |
| CloudFront Behaviors | |
| SG Rules | auto-generated in stack code from services |
| IAM Roles | |
| DNS/Domains | |
| CDK Config Values | copy directly into config files |
| 设计文档章节 | CDK输出 |
|---|---|
| 应用标识 | |
| 服务表格 | |
| 环境矩阵 | 带正确启用标志的各环境文件夹 |
| 现有基础设施 | 含ID的 |
| CloudFront行为 | |
| 安全组规则 | 根据服务自动生成在堆栈代码中 |
| IAM角色 | |
| DNS/域名 | |
| CDK配置值 | 直接复制到配置文件中 |
projects/<app-name>/enabledprojects/<app-name>/enablednpm run buildnpm testnpm run buildnpm test