AWS Solution Architect
Design scalable, cost-effective AWS architectures for startups with infrastructure-as-code templates.
Workflow
Step 1: Gather Requirements
Collect application specifications:
CODEBLOCK0
Step 2: Design Architecture
Run the architecture designer to get pattern recommendations:
CODEBLOCK1
Example output:
CODEBLOCK2
Select from recommended patterns:
- - Serverless Web: S3 + CloudFront + API Gateway + Lambda + DynamoDB
- Event-Driven Microservices: EventBridge + Lambda + SQS + Step Functions
- Three-Tier: ALB + ECS Fargate + Aurora + ElastiCache
- GraphQL Backend: AppSync + Lambda + DynamoDB + Cognito
See references/architecture_patterns.md for detailed pattern specifications.
Validation checkpoint: Confirm the recommended pattern matches the team's operational maturity and compliance requirements before proceeding to Step 3.
Step 3: Generate IaC Templates
Create infrastructure-as-code for the selected pattern:
CODEBLOCK3
Example CloudFormation YAML output (core serverless resources):
CODEBLOCK4
Full templates including API Gateway, Cognito, IAM roles, and CloudWatch logging are generated by serverless_stack.py and also available in references/architecture_patterns.md.
Example CDK TypeScript snippet (three-tier pattern):
CODEBLOCK5
Step 4: Review Costs
Analyze estimated costs and optimization opportunities:
CODEBLOCK6
Example output:
CODEBLOCK7
Output includes:
- - Monthly cost breakdown by service
- Right-sizing recommendations
- Savings Plans opportunities
- Potential monthly savings
Step 5: Deploy
Deploy the generated infrastructure:
CODEBLOCK8
Step 6: Validate and Handle Failures
Verify deployment and set up monitoring:
CODEBLOCK9
If stack creation fails:
- 1. Check the failure reason:
aws cloudformation describe-stack-events \
--stack-name my-app-stack \
--query 'StackEvents[?ResourceStatus==`CREATE_FAILED`]'
- 2. Review CloudWatch Logs for Lambda or ECS errors.
- Fix the template or resource configuration.
- Delete the failed stack before retrying:
CODEBLOCK11
Common failure causes:
- - IAM permission errors → verify
--capabilities CAPABILITY_IAM and role trust policies - Resource limit exceeded → request quota increase via Service Quotas console
- Invalid template syntax → run
aws cloudformation validate-template --template-body file://template.yaml before deploying
Tools
architecture_designer.py
Generates architecture patterns based on requirements.
CODEBLOCK12
Input: JSON with app type, scale, budget, compliance needs
Output: Recommended pattern, service stack, cost estimate, pros/cons
serverless_stack.py
Creates serverless CloudFormation templates.
CODEBLOCK13
Output: Production-ready CloudFormation YAML with:
- - API Gateway + Lambda
- DynamoDB table
- Cognito user pool
- IAM roles with least privilege
- CloudWatch logging
cost_optimizer.py
Analyzes costs and recommends optimizations.
CODEBLOCK14
Output: Recommendations for:
- - Idle resource removal
- Instance right-sizing
- Reserved capacity purchases
- Storage tier transitions
- NAT Gateway alternatives
Quick Start
MVP Architecture (< $100/month)
CODEBLOCK15
Scaling Architecture ($500-2000/month)
CODEBLOCK16
Cost Optimization
CODEBLOCK17
IaC Generation
CODEBLOCK18
Input Requirements
Provide these details for architecture design:
| Requirement | Description | Example |
|---|
| Application type | What you're building | SaaS platform, mobile backend |
| Expected scale |
Users, requests/sec | 10k users, 100 RPS |
| Budget | Monthly AWS limit | $500/month max |
| Team context | Size, AWS experience | 3 devs, intermediate |
| Compliance | Regulatory needs | HIPAA, GDPR, SOC 2 |
| Availability | Uptime requirements | 99.9% SLA, 1hr RPO |
JSON Format:
CODEBLOCK19
Output Formats
Architecture Design
- - Pattern recommendation with rationale
- Service stack diagram (ASCII)
- Monthly cost estimate and trade-offs
IaC Templates
- - CloudFormation YAML: Production-ready SAM/CFN templates
- CDK TypeScript: Type-safe infrastructure code
- Terraform HCL: Multi-cloud compatible configs
Cost Analysis
- - Current spend breakdown with optimization recommendations
- Priority action list (high/medium/low) and implementation checklist
Reference Documentation
| Document | Contents |
|---|
| INLINECODE5 | 6 patterns: serverless, microservices, three-tier, data processing, GraphQL, multi-region |
| INLINECODE6 |
Decision matrices for compute, database, storage, messaging |
|
references/best_practices.md | Serverless design, cost optimization, security hardening, scalability |
AWS Solution Architect
为初创公司设计可扩展、成本效益高的AWS架构,并提供基础设施即代码模板。
工作流程
步骤1:收集需求
收集应用程序规格:
- - 应用程序类型(Web应用、移动后端、数据管道、SaaS)
- 预期用户数和每秒请求数
- 预算限制(月度支出上限)
- 团队规模和AWS经验水平
- 合规要求(GDPR、HIPAA、SOC 2)
- 可用性要求(SLA、RPO/RTO)
步骤2:设计架构
运行架构设计器以获取模式推荐:
bash
python scripts/architecture_designer.py --input requirements.json
示例输出:
json
{
recommendedpattern: serverlessweb,
service_stack: [S3, CloudFront, API Gateway, Lambda, DynamoDB, Cognito],
estimatedmonthlycost_usd: 35,
pros: [运维开销低, 按需付费, 自动扩展],
cons: [冷启动, 15分钟Lambda限制, 最终一致性]
}
从推荐模式中选择:
- - 无服务器Web:S3 + CloudFront + API Gateway + Lambda + DynamoDB
- 事件驱动微服务:EventBridge + Lambda + SQS + Step Functions
- 三层架构:ALB + ECS Fargate + Aurora + ElastiCache
- GraphQL后端:AppSync + Lambda + DynamoDB + Cognito
详细模式规格请参见 references/architecture_patterns.md。
验证检查点: 在进入步骤3之前,确认推荐模式符合团队的运维成熟度和合规要求。
步骤3:生成IaC模板
为所选模式创建基础设施即代码:
bash
无服务器堆栈(CloudFormation)
python scripts/serverless_stack.py --app-name my-app --region us-east-1
示例CloudFormation YAML输出(核心无服务器资源):
yaml
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Parameters:
AppName:
Type: String
Default: my-app
Resources:
ApiFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs20.x
MemorySize: 512
Timeout: 30
Environment:
Variables:
TABLE_NAME: !Ref DataTable
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref DataTable
Events:
ApiEvent:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
DataTable:
Type: AWS::DynamoDB::Table
Properties:
BillingMode: PAYPERREQUEST
AttributeDefinitions:
- AttributeName: pk
AttributeType: S
- AttributeName: sk
AttributeType: S
KeySchema:
- AttributeName: pk
KeyType: HASH
- AttributeName: sk
KeyType: RANGE
包括API Gateway、Cognito、IAM角色和CloudWatch日志记录的完整模板由serverlessstack.py生成,也可在references/architecturepatterns.md中找到。
示例CDK TypeScript代码片段(三层模式):
typescript
import * as ecs from aws-cdk-lib/aws-ecs;
import * as ec2 from aws-cdk-lib/aws-ec2;
import * as rds from aws-cdk-lib/aws-rds;
const vpc = new ec2.Vpc(this, AppVpc, { maxAzs: 2 });
const cluster = new ecs.Cluster(this, AppCluster, { vpc });
const db = new rds.ServerlessCluster(this, AppDb, {
engine: rds.DatabaseClusterEngine.auroraPostgres({
version: rds.AuroraPostgresEngineVersion.VER152,
}),
vpc,
scaling: { minCapacity: 0.5, maxCapacity: 4 },
});
步骤4:审查成本
分析预估成本和优化机会:
bash
python scripts/costoptimizer.py --resources currentsetup.json --monthly-spend 2000
示例输出:
json
{
currentmonthlyusd: 2000,
recommendations: [
{ action: 合理调整RDS db.r5.2xlarge → db.r5.large, savings_usd: 420, priority: high },
{ action: 以40%利用率购买1年计算节省计划, savings_usd: 310, priority: high },
{ action: 将超过90天的S3对象移至Glacier即时检索, savings_usd: 85, priority: medium }
],
totalpotentialsavings_usd: 815
}
输出包括:
- - 按服务划分的月度成本明细
- 合理调整建议
- 节省计划机会
- 潜在月度节省
步骤5:部署
部署生成的基础设施:
bash
CloudFormation
aws cloudformation create-stack \
--stack-name my-app-stack \
--template-body file://template.yaml \
--capabilities CAPABILITY_IAM
CDK
cdk deploy
Terraform
terraform init && terraform apply
步骤6:验证和处理故障
验证部署并设置监控:
bash
检查堆栈状态
aws cloudformation describe-stacks --stack-name my-app-stack
设置CloudWatch告警
aws cloudwatch put-metric-alarm --alarm-name high-errors ...
如果堆栈创建失败:
- 1. 检查失败原因:
bash
aws cloudformation describe-stack-events \
--stack-name my-app-stack \
--query StackEvents[?ResourceStatus==CREATE_FAILED]
- 2. 查看CloudWatch日志以查找Lambda或ECS错误。
- 修复模板或资源配置。
- 在重试前删除失败的堆栈:
bash
aws cloudformation delete-stack --stack-name my-app-stack
# 等待删除完成
aws cloudformation wait stack-delete-complete --stack-name my-app-stack
# 重新部署
aws cloudformation create-stack ...
常见失败原因:
- - IAM权限错误 → 验证--capabilities CAPABILITY_IAM和角色信任策略
- 资源限制超限 → 通过Service Quotas控制台请求配额增加
- 无效模板语法 → 部署前运行aws cloudformation validate-template --template-body file://template.yaml
工具
architecture_designer.py
根据需求生成架构模式。
bash
python scripts/architecture_designer.py --input requirements.json --output design.json
输入: 包含应用类型、规模、预算、合规需求的JSON
输出: 推荐模式、服务堆栈、成本估算、优缺点
serverless_stack.py
创建无服务器CloudFormation模板。
bash
python scripts/serverless_stack.py --app-name my-app --region us-east-1
输出: 生产就绪的CloudFormation YAML,包含:
- - API Gateway + Lambda
- DynamoDB表
- Cognito用户池
- 最小权限IAM角色
- CloudWatch日志记录
cost_optimizer.py
分析成本并推荐优化方案。
bash
python scripts/cost_optimizer.py --resources inventory.json --monthly-spend 5000
输出: 针对以下方面的建议:
- - 空闲资源移除
- 实例合理调整
- 预留容量购买
- 存储层级转换
- NAT Gateway替代方案
快速入门
MVP架构(< $100/月)
提问:为拥有1000用户的移动应用设计无服务器MVP后端
结果:
- - Lambda + API Gateway用于API
- DynamoDB按需付费用于数据
- Cognito用于认证
- S3 + CloudFront用于静态资源
- 预估:$20-50/月
扩展架构($500-2000/月)
提问:为拥有5万用户的SaaS平台设计可扩展架构
结果:
- - ECS Fargate用于容器化API
- Aurora Serverless用于关系型数据
- ElastiCache用于会话缓存
- CloudFront用于CDN
- CodePipeline用于CI/CD
- 多可用区部署
成本优化
提问:优化我的AWS配置,将成本降低30%。当前支出:$3000/月
提供:当前资源清单(EC2、RDS、S3等)
结果:
- - 空闲资源识别
- 合理调整建议
- 节省计划分析
- 存储生命周期策略
- 目标节省:$900/月
IaC生成