specweave 0.22.0 → 0.22.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +211 -0
- package/README.md +5 -5
- package/bin/specweave.js +5 -8
- package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +1 -1
- package/dist/plugins/specweave-github/lib/CodeValidator.js +1 -1
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
- package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
- package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
- package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
- package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
- package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
- package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
- package/dist/src/cli/commands/next-command.d.ts +52 -0
- package/dist/src/cli/commands/next-command.d.ts.map +1 -0
- package/dist/src/cli/commands/next-command.js +204 -0
- package/dist/src/cli/commands/next-command.js.map +1 -0
- package/dist/src/cli/commands/sync-specs.d.ts +16 -0
- package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
- package/dist/src/cli/commands/sync-specs.js +130 -0
- package/dist/src/cli/commands/sync-specs.js.map +1 -0
- package/dist/src/cli/count-tasks.d.ts +20 -0
- package/dist/src/cli/count-tasks.d.ts.map +1 -0
- package/dist/src/cli/count-tasks.js +50 -0
- package/dist/src/cli/count-tasks.js.map +1 -0
- package/dist/src/config/ConfigManager.d.ts.map +1 -1
- package/dist/src/config/ConfigManager.js +2 -1
- package/dist/src/config/ConfigManager.js.map +1 -1
- package/dist/src/config/types.d.ts +50 -50
- package/dist/src/core/cicd/state-manager.d.ts +8 -0
- package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
- package/dist/src/core/cicd/state-manager.js +60 -15
- package/dist/src/core/cicd/state-manager.js.map +1 -1
- package/dist/src/core/cost-tracker.d.ts.map +1 -1
- package/dist/src/core/cost-tracker.js +2 -1
- package/dist/src/core/cost-tracker.js.map +1 -1
- package/dist/src/core/iac/template-engine.d.ts.map +1 -1
- package/dist/src/core/iac/template-engine.js +28 -0
- package/dist/src/core/iac/template-engine.js.map +1 -1
- package/dist/src/core/iac/template-generator.d.ts +53 -0
- package/dist/src/core/iac/template-generator.d.ts.map +1 -0
- package/dist/src/core/iac/template-generator.js +125 -0
- package/dist/src/core/iac/template-generator.js.map +1 -0
- package/dist/src/core/increment/status-auto-transition.js +3 -3
- package/dist/src/core/increment/status-auto-transition.js.map +1 -1
- package/dist/src/core/living-docs/CodeValidator.js +1 -1
- package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
- package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
- package/dist/src/core/living-docs/content-distributor.js +11 -1
- package/dist/src/core/living-docs/content-distributor.js.map +1 -1
- package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
- package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
- package/dist/src/core/living-docs/living-docs-sync.js +726 -0
- package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
- package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
- package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
- package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
- package/dist/src/core/plugin-loader.d.ts +7 -0
- package/dist/src/core/plugin-loader.d.ts.map +1 -1
- package/dist/src/core/plugin-loader.js +18 -1
- package/dist/src/core/plugin-loader.js.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
- package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
- package/dist/src/core/serverless/platform-data-loader.js +14 -0
- package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
- package/dist/src/core/serverless/types.d.ts +1 -1
- package/dist/src/core/serverless/types.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.d.ts +6 -2
- package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
- package/dist/src/core/status-line/status-line-manager.js +11 -5
- package/dist/src/core/status-line/status-line-manager.js.map +1 -1
- package/dist/src/core/status-line/task-counter.d.ts +69 -0
- package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
- package/dist/src/core/status-line/task-counter.js +107 -0
- package/dist/src/core/status-line/task-counter.js.map +1 -0
- package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
- package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
- package/dist/src/core/workflow/autonomous-executor.js +275 -0
- package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
- package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
- package/dist/src/core/workflow/backlog-scanner.js +170 -0
- package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
- package/dist/src/core/workflow/command-invoker.d.ts +86 -0
- package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
- package/dist/src/core/workflow/command-invoker.js +131 -0
- package/dist/src/core/workflow/command-invoker.js.map +1 -0
- package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
- package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
- package/dist/src/core/workflow/cost-estimator.js +222 -0
- package/dist/src/core/workflow/cost-estimator.js.map +1 -0
- package/dist/src/core/workflow/index.d.ts +20 -0
- package/dist/src/core/workflow/index.d.ts.map +1 -0
- package/dist/src/core/workflow/index.js +24 -0
- package/dist/src/core/workflow/index.js.map +1 -0
- package/dist/src/core/workflow/state-manager.d.ts +107 -0
- package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
- package/dist/src/core/workflow/state-manager.js +126 -0
- package/dist/src/core/workflow/state-manager.js.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
- package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
- package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
- package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
- package/dist/src/init/architecture/types.d.ts +10 -10
- package/dist/src/metrics/dora-calculator.js +2 -2
- package/dist/src/metrics/dora-calculator.js.map +1 -1
- package/dist/src/utils/pricing-constants.d.ts +5 -2
- package/dist/src/utils/pricing-constants.d.ts.map +1 -1
- package/dist/src/utils/pricing-constants.js +3 -2
- package/dist/src/utils/pricing-constants.js.map +1 -1
- package/package.json +4 -4
- package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
- package/plugins/specweave/agents/pm/AGENT.md +58 -1
- package/plugins/specweave/commands/specweave-archive-features.md +1 -1
- package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
- package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
- package/plugins/specweave/commands/specweave-done.md +12 -0
- package/plugins/specweave/commands/specweave-plan.md +1 -1
- package/plugins/specweave/commands/specweave-progress.md +108 -379
- package/plugins/specweave/commands/specweave-reopen.md +1 -1
- package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
- package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
- package/plugins/specweave/hooks/lib/update-status-line.sh +44 -35
- package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
- package/plugins/specweave/hooks/user-prompt-submit.sh +17 -35
- package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
- package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
- package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
- package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
- package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
- package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
- package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
- package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
- package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
- package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
- package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
- package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
- package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
- package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
- package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
- package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
- package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
- package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
- package/plugins/specweave-github/lib/CodeValidator.ts +1 -1
- package/plugins/specweave-github/lib/github-client-v2.js +29 -0
- package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
- package/plugins/specweave-github/lib/task-sync.js +4 -0
- package/plugins/specweave-github/lib/task-sync.ts +7 -0
- package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +2022 -0
- package/src/templates/CLAUDE.md.template +31 -0
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
- package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
- package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# {{functionName}} - AWS Lambda Serverless Infrastructure
|
|
2
|
+
|
|
3
|
+
**Generated by SpecWeave Serverless Architecture Intelligence**
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This Terraform configuration deploys a complete serverless application stack on AWS:
|
|
8
|
+
|
|
9
|
+
- **Lambda Function**: `{{functionName}}` ({{runtime}}, {{memorySize}}MB memory, {{timeout}}s timeout)
|
|
10
|
+
- **API Gateway**: HTTP API with CORS support
|
|
11
|
+
- **DynamoDB**: NoSQL database table `{{databaseName}}`
|
|
12
|
+
- **CloudWatch Logs**: Centralized logging with {{logRetentionDays}}-day retention
|
|
13
|
+
{{#if enableVpc}}- **VPC Integration**: Secure network isolation{{/if}}
|
|
14
|
+
{{#if enableXray}}- **X-Ray Tracing**: Distributed tracing enabled{{/if}}
|
|
15
|
+
{{#if enableSecretsManager}}- **Secrets Manager**: Secure secret storage{{/if}}
|
|
16
|
+
|
|
17
|
+
## Architecture
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────┐
|
|
21
|
+
│ Client │
|
|
22
|
+
└──────┬──────┘
|
|
23
|
+
│ HTTPS
|
|
24
|
+
v
|
|
25
|
+
┌─────────────────┐
|
|
26
|
+
│ API Gateway │
|
|
27
|
+
│ (HTTP API) │
|
|
28
|
+
└──────┬──────────┘
|
|
29
|
+
│
|
|
30
|
+
v
|
|
31
|
+
┌────────────────────┐ ┌──────────────┐
|
|
32
|
+
│ Lambda Function │─────>│ DynamoDB │
|
|
33
|
+
│ {{functionName}} │ │ {{databaseName}} │
|
|
34
|
+
└────────────────────┘ └──────────────┘
|
|
35
|
+
│
|
|
36
|
+
v
|
|
37
|
+
┌────────────────────┐
|
|
38
|
+
│ CloudWatch Logs │
|
|
39
|
+
└────────────────────┘
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Prerequisites
|
|
43
|
+
|
|
44
|
+
1. **AWS CLI** configured with credentials:
|
|
45
|
+
```bash
|
|
46
|
+
aws configure
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
2. **Terraform** v1.5.0 or higher:
|
|
50
|
+
```bash
|
|
51
|
+
terraform version
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. **Lambda deployment package** ({{functionName}}.zip):
|
|
55
|
+
- Create your Lambda function code
|
|
56
|
+
- Package as {{functionName}}.zip
|
|
57
|
+
- Place in the same directory as this README
|
|
58
|
+
|
|
59
|
+
## Deployment Instructions
|
|
60
|
+
|
|
61
|
+
### Step 1: Initialize Terraform
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
terraform init
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
This downloads the AWS provider and initializes the backend.
|
|
68
|
+
|
|
69
|
+
### Step 2: Review Configuration
|
|
70
|
+
|
|
71
|
+
Edit `terraform.tfvars` (or create environment-specific files like `dev.tfvars`) to customize:
|
|
72
|
+
|
|
73
|
+
```hcl
|
|
74
|
+
aws_region = "{{region}}"
|
|
75
|
+
function_name = "{{functionName}}"
|
|
76
|
+
environment = "{{environment}}"
|
|
77
|
+
runtime = "{{runtime}}"
|
|
78
|
+
memory_size = {{memorySize}}
|
|
79
|
+
timeout = {{timeout}}
|
|
80
|
+
database_name = "{{databaseName}}"
|
|
81
|
+
primary_key = "{{primaryKey}}"
|
|
82
|
+
project_name = "{{projectName}}"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 3: Plan Deployment
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
terraform plan
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Review the resources that will be created:
|
|
92
|
+
- 1× Lambda Function
|
|
93
|
+
- 1× API Gateway HTTP API
|
|
94
|
+
- 1× DynamoDB Table
|
|
95
|
+
- 2× CloudWatch Log Groups
|
|
96
|
+
- 1× IAM Role + Policies
|
|
97
|
+
{{#if enableVpc}}- 1× Security Group (VPC){{/if}}
|
|
98
|
+
|
|
99
|
+
### Step 4: Deploy
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
terraform apply
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Type `yes` when prompted to confirm deployment.
|
|
106
|
+
|
|
107
|
+
### Step 5: Verify Deployment
|
|
108
|
+
|
|
109
|
+
After successful deployment, Terraform will output:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
api_endpoint = "https://xxxxxxxxxx.execute-api.{{region}}.amazonaws.com/{{apiStageName}}"
|
|
113
|
+
function_name = "{{functionName}}"
|
|
114
|
+
table_name = "{{databaseName}}"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Test your API:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
curl https://xxxxxxxxxx.execute-api.{{region}}.amazonaws.com/{{apiStageName}}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Environment-Specific Deployments
|
|
124
|
+
|
|
125
|
+
Deploy to different environments using tfvars files:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Development
|
|
129
|
+
terraform apply -var-file="environments/dev.tfvars"
|
|
130
|
+
|
|
131
|
+
# Staging
|
|
132
|
+
terraform apply -var-file="environments/staging.tfvars"
|
|
133
|
+
|
|
134
|
+
# Production
|
|
135
|
+
terraform apply -var-file="environments/prod.tfvars"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Cost Optimization
|
|
139
|
+
|
|
140
|
+
### Free Tier Limits (First 12 Months)
|
|
141
|
+
|
|
142
|
+
- **Lambda**: 1M requests/month + 400,000 GB-seconds compute
|
|
143
|
+
- **API Gateway**: 1M API calls/month (first 12 months)
|
|
144
|
+
- **DynamoDB**: 25GB storage + 25 WCU + 25 RCU (always free)
|
|
145
|
+
- **CloudWatch Logs**: 5GB ingestion + 5GB storage
|
|
146
|
+
|
|
147
|
+
### Estimated Monthly Cost (After Free Tier)
|
|
148
|
+
|
|
149
|
+
**{{environment}} Environment**:
|
|
150
|
+
{{#if eq environment "dev"}}
|
|
151
|
+
- **Lambda**: ~$0.20/month (10K requests, 128MB, 1s avg duration)
|
|
152
|
+
- **API Gateway**: ~$0.10/month (10K requests)
|
|
153
|
+
- **DynamoDB**: $0.00/month (PAY_PER_REQUEST under free tier)
|
|
154
|
+
- **CloudWatch Logs**: ~$0.50/month (1GB logs)
|
|
155
|
+
- **Total**: ~$0.80/month
|
|
156
|
+
{{else}}{{#if eq environment "staging"}}
|
|
157
|
+
- **Lambda**: ~$2.00/month (100K requests, 256MB, 1s avg duration)
|
|
158
|
+
- **API Gateway**: ~$1.00/month (100K requests)
|
|
159
|
+
- **DynamoDB**: ~$1.25/month (PAY_PER_REQUEST, light usage)
|
|
160
|
+
- **CloudWatch Logs**: ~$1.00/month (2GB logs)
|
|
161
|
+
- **Total**: ~$5.25/month
|
|
162
|
+
{{else}}
|
|
163
|
+
- **Lambda**: ~$20.00/month (1M requests, 512MB, 1s avg duration)
|
|
164
|
+
- **API Gateway**: ~$10.00/month (1M requests)
|
|
165
|
+
- **DynamoDB**: ~$12.50/month (PROVISIONED, 5 RCU/WCU)
|
|
166
|
+
- **CloudWatch Logs**: ~$5.00/month (10GB logs)
|
|
167
|
+
- **Total**: ~$47.50/month
|
|
168
|
+
{{/if}}{{/if}}
|
|
169
|
+
|
|
170
|
+
### Cost Optimization Tips
|
|
171
|
+
|
|
172
|
+
1. **Right-size memory**: Test with different memory settings (128MB, 256MB, 512MB)
|
|
173
|
+
2. **Optimize timeout**: Reduce timeout to actual function duration
|
|
174
|
+
3. **Use PAY_PER_REQUEST**: For low-traffic apps (<100K requests/month)
|
|
175
|
+
4. **Enable CloudWatch Logs retention**: Delete old logs automatically
|
|
176
|
+
5. **Monitor cold starts**: Use Provisioned Concurrency if needed ($$)
|
|
177
|
+
|
|
178
|
+
## Security Best Practices
|
|
179
|
+
|
|
180
|
+
✅ **Implemented**:
|
|
181
|
+
- IAM least privilege roles
|
|
182
|
+
- HTTPS-only API Gateway
|
|
183
|
+
- CloudWatch Logs encryption
|
|
184
|
+
- DynamoDB encryption at rest (if enabled)
|
|
185
|
+
- Secrets Manager for sensitive data (if enabled)
|
|
186
|
+
|
|
187
|
+
⚠️ **Additional Recommendations**:
|
|
188
|
+
- Enable AWS WAF for API Gateway
|
|
189
|
+
- Implement rate limiting
|
|
190
|
+
- Use AWS Shield for DDoS protection
|
|
191
|
+
- Enable VPC for database access
|
|
192
|
+
- Rotate secrets regularly
|
|
193
|
+
|
|
194
|
+
## Monitoring and Logging
|
|
195
|
+
|
|
196
|
+
### CloudWatch Logs
|
|
197
|
+
|
|
198
|
+
View Lambda logs:
|
|
199
|
+
```bash
|
|
200
|
+
aws logs tail /aws/lambda/{{functionName}} --follow
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
View API Gateway logs:
|
|
204
|
+
```bash
|
|
205
|
+
aws logs tail /aws/apigateway/{{apiName}}-{{environment}} --follow
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### CloudWatch Metrics
|
|
209
|
+
|
|
210
|
+
Monitor in AWS Console:
|
|
211
|
+
- Lambda: Invocations, Duration, Errors, Throttles
|
|
212
|
+
- API Gateway: Count, Latency, 4XX/5XX errors
|
|
213
|
+
- DynamoDB: Read/Write capacity, Throttled requests
|
|
214
|
+
|
|
215
|
+
## Cleanup
|
|
216
|
+
|
|
217
|
+
To destroy all resources:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
terraform destroy
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Type `yes` to confirm deletion.
|
|
224
|
+
|
|
225
|
+
**Warning**: This will permanently delete:
|
|
226
|
+
- Lambda function
|
|
227
|
+
- API Gateway
|
|
228
|
+
- DynamoDB table (and all data)
|
|
229
|
+
- CloudWatch Logs
|
|
230
|
+
|
|
231
|
+
## Troubleshooting
|
|
232
|
+
|
|
233
|
+
### Lambda Function Not Working
|
|
234
|
+
|
|
235
|
+
1. Check CloudWatch Logs for errors
|
|
236
|
+
2. Verify IAM role permissions
|
|
237
|
+
3. Test function locally with AWS SAM
|
|
238
|
+
|
|
239
|
+
### API Gateway 403 Errors
|
|
240
|
+
|
|
241
|
+
1. Verify Lambda permission for API Gateway
|
|
242
|
+
2. Check CORS configuration
|
|
243
|
+
3. Review API Gateway execution logs
|
|
244
|
+
|
|
245
|
+
### DynamoDB Access Denied
|
|
246
|
+
|
|
247
|
+
1. Verify Lambda IAM role has DynamoDB permissions
|
|
248
|
+
2. Check table name matches environment variable
|
|
249
|
+
3. Verify primary key schema
|
|
250
|
+
|
|
251
|
+
## Support
|
|
252
|
+
|
|
253
|
+
For issues with this Terraform configuration, contact your SpecWeave administrator or file an issue at https://github.com/anton-abyzov/specweave/issues.
|
|
254
|
+
|
|
255
|
+
## Additional Resources
|
|
256
|
+
|
|
257
|
+
- [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/)
|
|
258
|
+
- [API Gateway HTTP API Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html)
|
|
259
|
+
- [DynamoDB Developer Guide](https://docs.aws.amazon.com/dynamodb/)
|
|
260
|
+
- [Terraform AWS Provider](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Development Environment Configuration
|
|
2
|
+
# Optimized for free tier and minimal costs
|
|
3
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
4
|
+
|
|
5
|
+
aws_region = "{{region}}"
|
|
6
|
+
environment = "dev"
|
|
7
|
+
function_name = "{{functionName}}-dev"
|
|
8
|
+
runtime = "{{runtime}}"
|
|
9
|
+
|
|
10
|
+
# Free tier optimized settings
|
|
11
|
+
memory_size = 128 # Smallest memory size (free tier eligible)
|
|
12
|
+
timeout = 30 # Conservative timeout
|
|
13
|
+
|
|
14
|
+
# Database configuration
|
|
15
|
+
database_name = "{{databaseName}}-dev"
|
|
16
|
+
primary_key = "{{primaryKey}}"
|
|
17
|
+
{{#if sortKey}}
|
|
18
|
+
sort_key = "{{sortKey}}"
|
|
19
|
+
{{/if}}
|
|
20
|
+
|
|
21
|
+
# Logging (keep retention short in dev)
|
|
22
|
+
log_retention_days = 7
|
|
23
|
+
|
|
24
|
+
# CORS (allow localhost for development)
|
|
25
|
+
cors_origins = ["http://localhost:3000", "http://localhost:8080"]
|
|
26
|
+
|
|
27
|
+
# Project metadata
|
|
28
|
+
project_name = "{{projectName}}"
|
|
29
|
+
|
|
30
|
+
# Additional tags
|
|
31
|
+
tags = {
|
|
32
|
+
CostCenter = "Development"
|
|
33
|
+
AutoDelete = "true" # Mark for cleanup scripts
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Production Environment Configuration
|
|
2
|
+
# High availability, performance, and security
|
|
3
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
4
|
+
|
|
5
|
+
aws_region = "{{region}}"
|
|
6
|
+
environment = "prod"
|
|
7
|
+
function_name = "{{functionName}}-prod"
|
|
8
|
+
runtime = "{{runtime}}"
|
|
9
|
+
|
|
10
|
+
# Production-optimized settings
|
|
11
|
+
memory_size = 512 # Higher memory for better performance
|
|
12
|
+
timeout = 300 # 5-minute timeout for complex operations
|
|
13
|
+
|
|
14
|
+
# Database configuration
|
|
15
|
+
database_name = "{{databaseName}}-prod"
|
|
16
|
+
primary_key = "{{primaryKey}}"
|
|
17
|
+
{{#if sortKey}}
|
|
18
|
+
sort_key = "{{sortKey}}"
|
|
19
|
+
{{/if}}
|
|
20
|
+
|
|
21
|
+
# Logging (long retention for compliance)
|
|
22
|
+
log_retention_days = 90
|
|
23
|
+
|
|
24
|
+
# CORS (production domains only)
|
|
25
|
+
cors_origins = ["https://{{projectName}}.com", "https://www.{{projectName}}.com", "https://api.{{projectName}}.com"]
|
|
26
|
+
|
|
27
|
+
# Project metadata
|
|
28
|
+
project_name = "{{projectName}}"
|
|
29
|
+
|
|
30
|
+
# Additional tags
|
|
31
|
+
tags = {
|
|
32
|
+
CostCenter = "Production"
|
|
33
|
+
AutoDelete = "false"
|
|
34
|
+
Backup = "true"
|
|
35
|
+
DisasterRecovery = "true"
|
|
36
|
+
Compliance = "SOC2"
|
|
37
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Staging Environment Configuration
|
|
2
|
+
# Medium-tier resources for pre-production testing
|
|
3
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
4
|
+
|
|
5
|
+
aws_region = "{{region}}"
|
|
6
|
+
environment = "staging"
|
|
7
|
+
function_name = "{{functionName}}-staging"
|
|
8
|
+
runtime = "{{runtime}}"
|
|
9
|
+
|
|
10
|
+
# Medium-tier settings
|
|
11
|
+
memory_size = 256 # Double dev memory for realistic testing
|
|
12
|
+
timeout = 60 # Higher timeout for complex operations
|
|
13
|
+
|
|
14
|
+
# Database configuration
|
|
15
|
+
database_name = "{{databaseName}}-staging"
|
|
16
|
+
primary_key = "{{primaryKey}}"
|
|
17
|
+
{{#if sortKey}}
|
|
18
|
+
sort_key = "{{sortKey}}"
|
|
19
|
+
{{/if}}
|
|
20
|
+
|
|
21
|
+
# Logging (moderate retention for staging)
|
|
22
|
+
log_retention_days = 30
|
|
23
|
+
|
|
24
|
+
# CORS (allow staging domains)
|
|
25
|
+
cors_origins = ["https://staging.{{projectName}}.com", "http://localhost:3000"]
|
|
26
|
+
|
|
27
|
+
# Project metadata
|
|
28
|
+
project_name = "{{projectName}}"
|
|
29
|
+
|
|
30
|
+
# Additional tags
|
|
31
|
+
tags = {
|
|
32
|
+
CostCenter = "Staging"
|
|
33
|
+
AutoDelete = "false"
|
|
34
|
+
Backup = "true"
|
|
35
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Outputs for AWS Lambda + API Gateway + DynamoDB
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
output "api_endpoint" {
|
|
5
|
+
description = "API Gateway endpoint URL"
|
|
6
|
+
value = aws_apigatewayv2_stage.{{snakeCase apiStageName}}.invoke_url
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
output "api_id" {
|
|
10
|
+
description = "API Gateway ID"
|
|
11
|
+
value = aws_apigatewayv2_api.{{snakeCase apiName}}.id
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
output "function_name" {
|
|
15
|
+
description = "Lambda function name"
|
|
16
|
+
value = aws_lambda_function.{{snakeCase functionName}}.function_name
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
output "function_arn" {
|
|
20
|
+
description = "Lambda function ARN"
|
|
21
|
+
value = aws_lambda_function.{{snakeCase functionName}}.arn
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
output "function_invoke_arn" {
|
|
25
|
+
description = "Lambda function invoke ARN"
|
|
26
|
+
value = aws_lambda_function.{{snakeCase functionName}}.invoke_arn
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
output "table_name" {
|
|
30
|
+
description = "DynamoDB table name"
|
|
31
|
+
value = aws_dynamodb_table.{{snakeCase databaseName}}.name
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
output "table_arn" {
|
|
35
|
+
description = "DynamoDB table ARN"
|
|
36
|
+
value = aws_dynamodb_table.{{snakeCase databaseName}}.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
{{#if enableStreams}}
|
|
40
|
+
output "table_stream_arn" {
|
|
41
|
+
description = "DynamoDB stream ARN"
|
|
42
|
+
value = aws_dynamodb_table.{{snakeCase databaseName}}.stream_arn
|
|
43
|
+
}
|
|
44
|
+
{{/if}}
|
|
45
|
+
|
|
46
|
+
output "lambda_role_arn" {
|
|
47
|
+
description = "Lambda execution role ARN"
|
|
48
|
+
value = aws_iam_role.lambda_exec.arn
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
output "lambda_logs_group" {
|
|
52
|
+
description = "CloudWatch Logs group for Lambda"
|
|
53
|
+
value = aws_cloudwatch_log_group.lambda_logs.name
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
output "api_logs_group" {
|
|
57
|
+
description = "CloudWatch Logs group for API Gateway"
|
|
58
|
+
value = aws_cloudwatch_log_group.api_logs.name
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
{{#if enableVpc}}
|
|
62
|
+
output "lambda_security_group_id" {
|
|
63
|
+
description = "Security group ID for Lambda function"
|
|
64
|
+
value = aws_security_group.lambda_sg.id
|
|
65
|
+
}
|
|
66
|
+
{{/if}}
|
|
67
|
+
|
|
68
|
+
output "deployment_summary" {
|
|
69
|
+
description = "Summary of deployed resources"
|
|
70
|
+
value = {
|
|
71
|
+
api_endpoint = aws_apigatewayv2_stage.{{snakeCase apiStageName}}.invoke_url
|
|
72
|
+
function_name = aws_lambda_function.{{snakeCase functionName}}.function_name
|
|
73
|
+
table_name = aws_dynamodb_table.{{snakeCase databaseName}}.name
|
|
74
|
+
environment = var.environment
|
|
75
|
+
region = var.aws_region
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Terraform and AWS Provider Configuration
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
terraform {
|
|
5
|
+
required_version = ">= 1.5.0"
|
|
6
|
+
|
|
7
|
+
required_providers {
|
|
8
|
+
aws = {
|
|
9
|
+
source = "hashicorp/aws"
|
|
10
|
+
version = "~> 5.0"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
{{#if enableRemoteState}}
|
|
15
|
+
backend "s3" {
|
|
16
|
+
bucket = "{{terraformStateBucket}}"
|
|
17
|
+
key = "{{functionName}}/terraform.tfstate"
|
|
18
|
+
region = "{{region}}"
|
|
19
|
+
encrypt = true
|
|
20
|
+
dynamodb_table = "{{terraformLockTable}}"
|
|
21
|
+
}
|
|
22
|
+
{{/if}}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
provider "aws" {
|
|
26
|
+
region = var.aws_region
|
|
27
|
+
|
|
28
|
+
default_tags {
|
|
29
|
+
tags = {
|
|
30
|
+
Project = var.project_name
|
|
31
|
+
Environment = var.environment
|
|
32
|
+
ManagedBy = "Terraform"
|
|
33
|
+
CreatedBy = "SpecWeave"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Input Variables for AWS Lambda + API Gateway + DynamoDB
|
|
2
|
+
# Generated by SpecWeave Serverless Architecture Intelligence
|
|
3
|
+
|
|
4
|
+
variable "aws_region" {
|
|
5
|
+
description = "AWS region for all resources"
|
|
6
|
+
type = string
|
|
7
|
+
default = "{{region}}"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
variable "function_name" {
|
|
11
|
+
description = "Lambda function name"
|
|
12
|
+
type = string
|
|
13
|
+
default = "{{functionName}}"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "runtime" {
|
|
17
|
+
description = "Lambda runtime (nodejs20.x, python3.12, etc.)"
|
|
18
|
+
type = string
|
|
19
|
+
default = "{{runtime}}"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
variable "memory_size" {
|
|
23
|
+
description = "Lambda memory size in MB (128-10240)"
|
|
24
|
+
type = number
|
|
25
|
+
default = {{memorySize}}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
variable "timeout" {
|
|
29
|
+
description = "Lambda timeout in seconds (1-900)"
|
|
30
|
+
type = number
|
|
31
|
+
default = {{timeout}}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
variable "environment" {
|
|
35
|
+
description = "Environment name (dev, staging, prod)"
|
|
36
|
+
type = string
|
|
37
|
+
default = "{{environment}}"
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
variable "handler" {
|
|
41
|
+
description = "Lambda function handler"
|
|
42
|
+
type = string
|
|
43
|
+
default = "{{handler}}"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
variable "database_name" {
|
|
47
|
+
description = "DynamoDB table name"
|
|
48
|
+
type = string
|
|
49
|
+
default = "{{databaseName}}"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
variable "primary_key" {
|
|
53
|
+
description = "DynamoDB primary key (partition key)"
|
|
54
|
+
type = string
|
|
55
|
+
default = "{{primaryKey}}"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
{{#if sortKey}}
|
|
59
|
+
variable "sort_key" {
|
|
60
|
+
description = "DynamoDB sort key (range key)"
|
|
61
|
+
type = string
|
|
62
|
+
default = "{{sortKey}}"
|
|
63
|
+
}
|
|
64
|
+
{{/if}}
|
|
65
|
+
|
|
66
|
+
variable "log_retention_days" {
|
|
67
|
+
description = "CloudWatch Logs retention in days"
|
|
68
|
+
type = number
|
|
69
|
+
default = {{logRetentionDays}}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
variable "cors_origins" {
|
|
73
|
+
description = "List of allowed CORS origins for API Gateway"
|
|
74
|
+
type = list(string)
|
|
75
|
+
default = {{tfList corsOrigins}}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
{{#if enableVpc}}
|
|
79
|
+
variable "vpc_id" {
|
|
80
|
+
description = "VPC ID for Lambda function (if VPC enabled)"
|
|
81
|
+
type = string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
variable "subnet_ids" {
|
|
85
|
+
description = "Subnet IDs for Lambda function (if VPC enabled)"
|
|
86
|
+
type = list(string)
|
|
87
|
+
}
|
|
88
|
+
{{/if}}
|
|
89
|
+
|
|
90
|
+
{{#if enableSecretsManager}}
|
|
91
|
+
variable "secrets_manager_arns" {
|
|
92
|
+
description = "ARNs of Secrets Manager secrets to access"
|
|
93
|
+
type = list(string)
|
|
94
|
+
default = []
|
|
95
|
+
}
|
|
96
|
+
{{/if}}
|
|
97
|
+
|
|
98
|
+
{{#if enableKms}}
|
|
99
|
+
variable "kms_key_arn" {
|
|
100
|
+
description = "KMS key ARN for encryption"
|
|
101
|
+
type = string
|
|
102
|
+
}
|
|
103
|
+
{{/if}}
|
|
104
|
+
|
|
105
|
+
variable "project_name" {
|
|
106
|
+
description = "Project name for resource tagging"
|
|
107
|
+
type = string
|
|
108
|
+
default = "{{projectName}}"
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
variable "tags" {
|
|
112
|
+
description = "Additional tags for all resources"
|
|
113
|
+
type = map(string)
|
|
114
|
+
default = {}
|
|
115
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"location": "eastus",
|
|
3
|
+
"resourceGroupName": "my-functions-rg",
|
|
4
|
+
"functionName": "my-function-app",
|
|
5
|
+
"runtime": "node",
|
|
6
|
+
"runtimeVersion": "20",
|
|
7
|
+
"osType": "linux",
|
|
8
|
+
"skuName": "Y1",
|
|
9
|
+
"environment": "dev",
|
|
10
|
+
"databaseAccountName": "my-cosmosdb-account",
|
|
11
|
+
"databaseName": "my-database",
|
|
12
|
+
"containerName": "my-container",
|
|
13
|
+
"partitionKey": "/id",
|
|
14
|
+
"throughput": 400,
|
|
15
|
+
"corsOrigins": ["*"],
|
|
16
|
+
"projectName": "my-project",
|
|
17
|
+
"enableApplicationInsights": true,
|
|
18
|
+
"enableKeyVault": false,
|
|
19
|
+
"enableVnet": false,
|
|
20
|
+
"enableBackup": false,
|
|
21
|
+
"enableAutomaticFailover": false,
|
|
22
|
+
"enableMultiRegion": false,
|
|
23
|
+
"storageAccountTier": "Standard",
|
|
24
|
+
"storageAccountReplication": "LRS"
|
|
25
|
+
}
|