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.
Files changed (184) hide show
  1. package/CLAUDE.md +211 -0
  2. package/README.md +5 -5
  3. package/bin/specweave.js +5 -8
  4. package/dist/plugins/specweave-github/lib/CodeValidator.d.ts +1 -1
  5. package/dist/plugins/specweave-github/lib/CodeValidator.js +1 -1
  6. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts +10 -0
  7. package/dist/plugins/specweave-github/lib/github-client-v2.d.ts.map +1 -1
  8. package/dist/plugins/specweave-github/lib/github-client-v2.js +26 -0
  9. package/dist/plugins/specweave-github/lib/github-client-v2.js.map +1 -1
  10. package/dist/plugins/specweave-github/lib/task-sync.d.ts.map +1 -1
  11. package/dist/plugins/specweave-github/lib/task-sync.js +7 -0
  12. package/dist/plugins/specweave-github/lib/task-sync.js.map +1 -1
  13. package/dist/src/cli/commands/migrate-to-profiles.d.ts +1 -0
  14. package/dist/src/cli/commands/migrate-to-profiles.d.ts.map +1 -1
  15. package/dist/src/cli/commands/migrate-to-profiles.js +12 -1
  16. package/dist/src/cli/commands/migrate-to-profiles.js.map +1 -1
  17. package/dist/src/cli/commands/next-command.d.ts +52 -0
  18. package/dist/src/cli/commands/next-command.d.ts.map +1 -0
  19. package/dist/src/cli/commands/next-command.js +204 -0
  20. package/dist/src/cli/commands/next-command.js.map +1 -0
  21. package/dist/src/cli/commands/sync-specs.d.ts +16 -0
  22. package/dist/src/cli/commands/sync-specs.d.ts.map +1 -0
  23. package/dist/src/cli/commands/sync-specs.js +130 -0
  24. package/dist/src/cli/commands/sync-specs.js.map +1 -0
  25. package/dist/src/cli/count-tasks.d.ts +20 -0
  26. package/dist/src/cli/count-tasks.d.ts.map +1 -0
  27. package/dist/src/cli/count-tasks.js +50 -0
  28. package/dist/src/cli/count-tasks.js.map +1 -0
  29. package/dist/src/config/ConfigManager.d.ts.map +1 -1
  30. package/dist/src/config/ConfigManager.js +2 -1
  31. package/dist/src/config/ConfigManager.js.map +1 -1
  32. package/dist/src/config/types.d.ts +50 -50
  33. package/dist/src/core/cicd/state-manager.d.ts +8 -0
  34. package/dist/src/core/cicd/state-manager.d.ts.map +1 -1
  35. package/dist/src/core/cicd/state-manager.js +60 -15
  36. package/dist/src/core/cicd/state-manager.js.map +1 -1
  37. package/dist/src/core/cost-tracker.d.ts.map +1 -1
  38. package/dist/src/core/cost-tracker.js +2 -1
  39. package/dist/src/core/cost-tracker.js.map +1 -1
  40. package/dist/src/core/iac/template-engine.d.ts.map +1 -1
  41. package/dist/src/core/iac/template-engine.js +28 -0
  42. package/dist/src/core/iac/template-engine.js.map +1 -1
  43. package/dist/src/core/iac/template-generator.d.ts +53 -0
  44. package/dist/src/core/iac/template-generator.d.ts.map +1 -0
  45. package/dist/src/core/iac/template-generator.js +125 -0
  46. package/dist/src/core/iac/template-generator.js.map +1 -0
  47. package/dist/src/core/increment/status-auto-transition.js +3 -3
  48. package/dist/src/core/increment/status-auto-transition.js.map +1 -1
  49. package/dist/src/core/living-docs/CodeValidator.js +1 -1
  50. package/dist/src/core/living-docs/CodeValidator.js.map +1 -1
  51. package/dist/src/core/living-docs/content-distributor.d.ts.map +1 -1
  52. package/dist/src/core/living-docs/content-distributor.js +11 -1
  53. package/dist/src/core/living-docs/content-distributor.js.map +1 -1
  54. package/dist/src/core/living-docs/living-docs-sync.d.ts +166 -0
  55. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -0
  56. package/dist/src/core/living-docs/living-docs-sync.js +726 -0
  57. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -0
  58. package/dist/src/core/living-docs/task-project-specific-generator.d.ts +7 -3
  59. package/dist/src/core/living-docs/task-project-specific-generator.d.ts.map +1 -1
  60. package/dist/src/core/living-docs/task-project-specific-generator.js +40 -24
  61. package/dist/src/core/living-docs/task-project-specific-generator.js.map +1 -1
  62. package/dist/src/core/plugin-loader.d.ts +7 -0
  63. package/dist/src/core/plugin-loader.d.ts.map +1 -1
  64. package/dist/src/core/plugin-loader.js +18 -1
  65. package/dist/src/core/plugin-loader.js.map +1 -1
  66. package/dist/src/core/serverless/platform-data-loader.d.ts +8 -0
  67. package/dist/src/core/serverless/platform-data-loader.d.ts.map +1 -1
  68. package/dist/src/core/serverless/platform-data-loader.js +14 -0
  69. package/dist/src/core/serverless/platform-data-loader.js.map +1 -1
  70. package/dist/src/core/serverless/types.d.ts +1 -1
  71. package/dist/src/core/serverless/types.d.ts.map +1 -1
  72. package/dist/src/core/status-line/status-line-manager.d.ts +6 -2
  73. package/dist/src/core/status-line/status-line-manager.d.ts.map +1 -1
  74. package/dist/src/core/status-line/status-line-manager.js +11 -5
  75. package/dist/src/core/status-line/status-line-manager.js.map +1 -1
  76. package/dist/src/core/status-line/task-counter.d.ts +69 -0
  77. package/dist/src/core/status-line/task-counter.d.ts.map +1 -0
  78. package/dist/src/core/status-line/task-counter.js +107 -0
  79. package/dist/src/core/status-line/task-counter.js.map +1 -0
  80. package/dist/src/core/workflow/autonomous-executor.d.ts +111 -0
  81. package/dist/src/core/workflow/autonomous-executor.d.ts.map +1 -0
  82. package/dist/src/core/workflow/autonomous-executor.js +275 -0
  83. package/dist/src/core/workflow/autonomous-executor.js.map +1 -0
  84. package/dist/src/core/workflow/backlog-scanner.d.ts +94 -0
  85. package/dist/src/core/workflow/backlog-scanner.d.ts.map +1 -0
  86. package/dist/src/core/workflow/backlog-scanner.js +170 -0
  87. package/dist/src/core/workflow/backlog-scanner.js.map +1 -0
  88. package/dist/src/core/workflow/command-invoker.d.ts +86 -0
  89. package/dist/src/core/workflow/command-invoker.d.ts.map +1 -0
  90. package/dist/src/core/workflow/command-invoker.js +131 -0
  91. package/dist/src/core/workflow/command-invoker.js.map +1 -0
  92. package/dist/src/core/workflow/cost-estimator.d.ts +120 -0
  93. package/dist/src/core/workflow/cost-estimator.d.ts.map +1 -0
  94. package/dist/src/core/workflow/cost-estimator.js +222 -0
  95. package/dist/src/core/workflow/cost-estimator.js.map +1 -0
  96. package/dist/src/core/workflow/index.d.ts +20 -0
  97. package/dist/src/core/workflow/index.d.ts.map +1 -0
  98. package/dist/src/core/workflow/index.js +24 -0
  99. package/dist/src/core/workflow/index.js.map +1 -0
  100. package/dist/src/core/workflow/state-manager.d.ts +107 -0
  101. package/dist/src/core/workflow/state-manager.d.ts.map +1 -0
  102. package/dist/src/core/workflow/state-manager.js +126 -0
  103. package/dist/src/core/workflow/state-manager.js.map +1 -0
  104. package/dist/src/core/workflow/workflow-orchestrator.d.ts +93 -0
  105. package/dist/src/core/workflow/workflow-orchestrator.d.ts.map +1 -0
  106. package/dist/src/core/workflow/workflow-orchestrator.js +195 -0
  107. package/dist/src/core/workflow/workflow-orchestrator.js.map +1 -0
  108. package/dist/src/init/architecture/types.d.ts +10 -10
  109. package/dist/src/metrics/dora-calculator.js +2 -2
  110. package/dist/src/metrics/dora-calculator.js.map +1 -1
  111. package/dist/src/utils/pricing-constants.d.ts +5 -2
  112. package/dist/src/utils/pricing-constants.d.ts.map +1 -1
  113. package/dist/src/utils/pricing-constants.js +3 -2
  114. package/dist/src/utils/pricing-constants.js.map +1 -1
  115. package/package.json +4 -4
  116. package/plugins/specweave/agents/infrastructure/AGENT.md +88 -46
  117. package/plugins/specweave/agents/pm/AGENT.md +58 -1
  118. package/plugins/specweave/commands/specweave-archive-features.md +1 -1
  119. package/plugins/specweave/commands/specweave-archive-increments.md +1 -1
  120. package/plugins/specweave/commands/specweave-check-hooks.md +5 -0
  121. package/plugins/specweave/commands/specweave-done.md +12 -0
  122. package/plugins/specweave/commands/specweave-plan.md +1 -1
  123. package/plugins/specweave/commands/specweave-progress.md +108 -379
  124. package/plugins/specweave/commands/specweave-reopen.md +1 -1
  125. package/plugins/specweave/commands/specweave-restore-feature.md +1 -1
  126. package/plugins/specweave/commands/specweave-sync-specs.md +20 -48
  127. package/plugins/specweave/hooks/lib/update-status-line.sh +44 -35
  128. package/plugins/specweave/hooks/lib/validate-spec-status.sh +163 -0
  129. package/plugins/specweave/hooks/user-prompt-submit.sh +17 -35
  130. package/plugins/specweave/lib/hooks/update-tasks-md.js +52 -9
  131. package/plugins/specweave/lib/hooks/update-tasks-md.ts +77 -16
  132. package/plugins/specweave/templates/iac/aws-lambda/defaults.json +24 -0
  133. package/plugins/specweave/templates/iac/aws-lambda/templates/README.md.hbs +260 -0
  134. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/dev.tfvars.hbs +34 -0
  135. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/prod.tfvars.hbs +37 -0
  136. package/plugins/specweave/templates/iac/aws-lambda/templates/environments/staging.tfvars.hbs +35 -0
  137. package/plugins/specweave/templates/iac/aws-lambda/templates/outputs.tf.hbs +77 -0
  138. package/plugins/specweave/templates/iac/aws-lambda/templates/providers.tf.hbs +36 -0
  139. package/plugins/specweave/templates/iac/aws-lambda/templates/variables.tf.hbs +115 -0
  140. package/plugins/specweave/templates/iac/azure-functions/defaults.json +25 -0
  141. package/plugins/specweave/templates/iac/azure-functions/templates/README.md.hbs +268 -0
  142. package/plugins/specweave/templates/iac/azure-functions/templates/environments/dev.tfvars.hbs +34 -0
  143. package/plugins/specweave/templates/iac/azure-functions/templates/environments/prod.tfvars.hbs +46 -0
  144. package/plugins/specweave/templates/iac/azure-functions/templates/environments/staging.tfvars.hbs +34 -0
  145. package/plugins/specweave/templates/iac/azure-functions/templates/main.tf.hbs +225 -0
  146. package/plugins/specweave/templates/iac/azure-functions/templates/outputs.tf.hbs +89 -0
  147. package/plugins/specweave/templates/iac/azure-functions/templates/provider.tf.hbs +27 -0
  148. package/plugins/specweave/templates/iac/azure-functions/templates/providers.tf.hbs +35 -0
  149. package/plugins/specweave/templates/iac/azure-functions/templates/variables.tf.hbs +124 -0
  150. package/plugins/specweave/templates/iac/firebase/defaults.json +29 -0
  151. package/plugins/specweave/templates/iac/firebase/templates/README.md.hbs +35 -0
  152. package/plugins/specweave/templates/iac/firebase/templates/environments/dev.tfvars.hbs +7 -0
  153. package/plugins/specweave/templates/iac/firebase/templates/environments/prod.tfvars.hbs +7 -0
  154. package/plugins/specweave/templates/iac/firebase/templates/environments/staging.tfvars.hbs +7 -0
  155. package/plugins/specweave/templates/iac/firebase/templates/main.tf.hbs +90 -0
  156. package/plugins/specweave/templates/iac/firebase/templates/outputs.tf.hbs +15 -0
  157. package/plugins/specweave/templates/iac/firebase/templates/providers.tf.hbs +23 -0
  158. package/plugins/specweave/templates/iac/firebase/templates/variables.tf.hbs +42 -0
  159. package/plugins/specweave/templates/iac/gcp-cloud-functions/defaults.json +26 -0
  160. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/README.md.hbs +299 -0
  161. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/dev.tfvars.hbs +36 -0
  162. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/prod.tfvars.hbs +48 -0
  163. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/environments/staging.tfvars.hbs +41 -0
  164. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/main.tf.hbs +192 -0
  165. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/outputs.tf.hbs +66 -0
  166. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/providers.tf.hbs +25 -0
  167. package/plugins/specweave/templates/iac/gcp-cloud-functions/templates/variables.tf.hbs +119 -0
  168. package/plugins/specweave/templates/iac/supabase/defaults.json +15 -0
  169. package/plugins/specweave/templates/iac/supabase/templates/README.md.hbs +46 -0
  170. package/plugins/specweave/templates/iac/supabase/templates/main.tf.hbs +50 -0
  171. package/plugins/specweave-github/agents/github-manager/AGENT.md +39 -7
  172. package/plugins/specweave-github/commands/specweave-github-create-issue.md +5 -5
  173. package/plugins/specweave-github/lib/CodeValidator.ts +1 -1
  174. package/plugins/specweave-github/lib/github-client-v2.js +29 -0
  175. package/plugins/specweave-github/lib/github-client-v2.ts +30 -0
  176. package/plugins/specweave-github/lib/task-sync.js +4 -0
  177. package/plugins/specweave-github/lib/task-sync.ts +7 -0
  178. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  179. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +2022 -0
  180. package/src/templates/CLAUDE.md.template +31 -0
  181. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts +0 -116
  182. package/dist/src/core/living-docs/ThreeLayerSyncManager.d.ts.map +0 -1
  183. package/dist/src/core/living-docs/ThreeLayerSyncManager.js +0 -356
  184. package/dist/src/core/living-docs/ThreeLayerSyncManager.js.map +0 -1
@@ -0,0 +1,268 @@
1
+ # Azure Functions + Cosmos DB Terraform Configuration
2
+
3
+ **Generated by SpecWeave Serverless Architecture Intelligence**
4
+
5
+ This Terraform configuration deploys:
6
+ - Azure Function App ({{runtime}} {{runtimeVersion}} on {{osType}})
7
+ - Azure Cosmos DB (SQL API)
8
+ - Azure Storage Account (required for Function App)
9
+ - App Service Plan ({{skuName}} SKU)
10
+ {{#if enableApplicationInsights}}- Application Insights for monitoring{{/if}}
11
+ {{#if enableKeyVault}}- Azure Key Vault for secrets management{{/if}}
12
+
13
+ ## Architecture
14
+
15
+ ```
16
+ Azure Function App ({{functionName}})
17
+ ├── Runtime: {{runtime}} {{runtimeVersion}}
18
+ ├── Plan: {{skuName}} ({{#if (eq skuName "Y1")}}Consumption{{else}}Premium{{/if}})
19
+ └── Storage: {{functionName}}storage
20
+
21
+ Cosmos DB ({{databaseAccountName}})
22
+ ├── Database: {{databaseName}}
23
+ ├── Container: {{containerName}}
24
+ ├── Partition Key: {{partitionKey}}
25
+ └── Throughput: {{throughput}} RU/s
26
+
27
+ {{#if enableApplicationInsights}}
28
+ Application Insights ({{functionName}}-insights)
29
+ └── Type: web
30
+ {{/if}}
31
+
32
+ {{#if enableKeyVault}}
33
+ Key Vault ({{functionName}}-kv)
34
+ └── Secrets: Managed by Function App identity
35
+ {{/if}}
36
+ ```
37
+
38
+ ## Prerequisites
39
+
40
+ 1. **Azure CLI** installed and authenticated:
41
+ ```bash
42
+ az login
43
+ az account set --subscription "YOUR_SUBSCRIPTION_ID"
44
+ ```
45
+
46
+ 2. **Terraform** v1.5.0+ installed:
47
+ ```bash
48
+ terraform version
49
+ ```
50
+
51
+ 3. **Function App code** ready to deploy:
52
+ - Node.js: `package.json`, `index.js`, etc.
53
+ - Python: `requirements.txt`, `__init__.py`, etc.
54
+
55
+ ## Deployment Instructions
56
+
57
+ ### 1. Initialize Terraform
58
+
59
+ ```bash
60
+ terraform init
61
+ ```
62
+
63
+ ### 2. Review the Plan
64
+
65
+ ```bash
66
+ terraform plan
67
+ ```
68
+
69
+ **Expected resources**: ~{{#if enableKeyVault}}10{{else if enableApplicationInsights}}8{{else}}6{{/if}} resources will be created
70
+
71
+ ### 3. Deploy Infrastructure
72
+
73
+ **Development**:
74
+ ```bash
75
+ terraform apply -var-file="environments/dev.tfvars"
76
+ ```
77
+
78
+ **Staging**:
79
+ ```bash
80
+ terraform apply -var-file="environments/staging.tfvars"
81
+ ```
82
+
83
+ **Production**:
84
+ ```bash
85
+ terraform apply -var-file="environments/prod.tfvars"
86
+ ```
87
+
88
+ ### 4. Deploy Function Code
89
+
90
+ After infrastructure is deployed, deploy your function code:
91
+
92
+ ```bash
93
+ # Zip your function code
94
+ cd ../src # Navigate to your function source code
95
+ zip -r function.zip .
96
+
97
+ # Deploy using Azure CLI
98
+ az functionapp deployment source config-zip \
99
+ --resource-group {{resourceGroupName}} \
100
+ --name {{functionName}} \
101
+ --src function.zip
102
+ ```
103
+
104
+ ### 5. Test Your Function
105
+
106
+ ```bash
107
+ # Get function URL
108
+ FUNCTION_URL=$(terraform output -raw function_app_url)
109
+
110
+ # Test HTTP trigger (example)
111
+ curl "${FUNCTION_URL}/api/hello?name=World"
112
+ ```
113
+
114
+ ## Cost Estimation
115
+
116
+ ### Development Environment
117
+
118
+ **Azure Function App (Consumption Plan)**:
119
+ - Execution: 1M requests/month = Free (2M free tier)
120
+ - Execution time: 100,000 GB-s/month = Free (400,000 GB-s free tier)
121
+ - **Total**: $0/month (within free tier)
122
+
123
+ **Cosmos DB**:
124
+ - Throughput: {{throughput}} RU/s × $0.008/hour = ${{multiply throughput 0.008 720}}/month
125
+ - Storage: 1 GB = Free (25 GB free tier)
126
+ - **Total**: ~${{multiply throughput 0.008 720}}/month
127
+
128
+ **Storage Account**:
129
+ - LRS storage: 1 GB = ~$0.02/month
130
+ - Transactions: Minimal cost
131
+ - **Total**: ~$0.50/month
132
+
133
+ **Application Insights**:
134
+ - First 5 GB = Free
135
+ - **Total**: $0/month (within free tier)
136
+
137
+ **Total Monthly Cost (Dev)**: ~${{add (multiply throughput 0.008 720) 0.5}}/month
138
+
139
+ {{#if (eq environment "prod")}}
140
+ ### Production Environment (Estimated)
141
+
142
+ **Note**: Production costs depend on actual usage. Estimate above assumes:
143
+ - 10M requests/month
144
+ - {{throughput}} RU/s Cosmos DB throughput
145
+ - ~10 GB storage
146
+
147
+ For accurate production estimates, use [Azure Pricing Calculator](https://azure.microsoft.com/pricing/calculator/).
148
+ {{/if}}
149
+
150
+ ## Free Tier Optimization Tips
151
+
152
+ 1. **Function App**:
153
+ - Use Consumption Plan (Y1) for variable workloads
154
+ - Stay under 1M executions/month for free tier
155
+ - Optimize memory allocation (lower = cheaper)
156
+
157
+ 2. **Cosmos DB**:
158
+ - Start with 400 RU/s (minimum)
159
+ - Use autoscale for variable workloads
160
+ - Monitor RU consumption in Azure Portal
161
+
162
+ 3. **Application Insights**:
163
+ - First 5 GB/month is free
164
+ - Use sampling to reduce data volume
165
+ - Set retention to 90 days
166
+
167
+ 4. **Storage Account**:
168
+ - Use LRS (cheapest replication)
169
+ - Clean up old blobs and logs
170
+ - Enable lifecycle management
171
+
172
+ ## Monitoring
173
+
174
+ {{#if enableApplicationInsights}}
175
+ **Application Insights** is enabled. View metrics at:
176
+ ```
177
+ https://portal.azure.com/#@/resource${terraform output -raw application_insights_id}/overview
178
+ ```
179
+
180
+ Key metrics to monitor:
181
+ - Request rate and response times
182
+ - Failed requests
183
+ - Cosmos DB RU consumption
184
+ - Function execution count and duration
185
+ {{else}}
186
+ **Application Insights** is not enabled. To enable monitoring:
187
+ 1. Set `enableApplicationInsights = true` in `defaults.json`
188
+ 2. Re-apply Terraform configuration
189
+ {{/if}}
190
+
191
+ ## Security Best Practices
192
+
193
+ 1. **Managed Identity**: Function App uses System-Assigned Managed Identity
194
+ - No credentials in code
195
+ - Automatic rotation
196
+ - Azure RBAC for access control
197
+
198
+ 2. **Secrets Management**:
199
+ {{#if enableKeyVault}}
200
+ - ✅ Key Vault enabled for secrets
201
+ - Store connection strings in Key Vault
202
+ - Reference via `@Microsoft.KeyVault(SecretUri=...)`
203
+ {{else}}
204
+ - ⚠️ Key Vault not enabled
205
+ - Enable with `enableKeyVault = true`
206
+ {{/if}}
207
+
208
+ 3. **HTTPS Only**: Function App enforces HTTPS
209
+ 4. **CORS**: Configured for origins: {{corsOrigins}}
210
+ 5. **Network Security**:
211
+ {{#if enableVnet}}
212
+ - ✅ VNet integration enabled
213
+ {{else}}
214
+ - ⚠️ VNet integration not enabled (public access)
215
+ - Enable with `enableVnet = true`
216
+ {{/if}}
217
+
218
+ ## Cleanup
219
+
220
+ To destroy all resources:
221
+
222
+ ```bash
223
+ terraform destroy
224
+ ```
225
+
226
+ **Warning**: This will permanently delete:
227
+ - Function App and all deployed code
228
+ - Cosmos DB and all data
229
+ - Storage Account and all blobs
230
+ - Application Insights telemetry data
231
+
232
+ ## Troubleshooting
233
+
234
+ ### "Resource name already exists"
235
+ - Azure resource names must be globally unique
236
+ - Modify `appName` in `defaults.json` or `*.tfvars`
237
+
238
+ ### "Insufficient permissions"
239
+ - Ensure you have Owner/Contributor role on subscription
240
+ - Run `az account show` to verify correct subscription
241
+
242
+ ### "Cosmos DB throughput too low"
243
+ - Minimum throughput is 400 RU/s
244
+ - Adjust `throughput` in `defaults.json` or `*.tfvars`
245
+
246
+ ### "Function App not responding"
247
+ - Check Application Insights for errors
248
+ - Verify function code is deployed (`az functionapp deployment list-publishing-credentials`)
249
+ - Check CORS settings if calling from browser
250
+
251
+ ## Next Steps
252
+
253
+ 1. **Deploy your function code** (see step 4 above)
254
+ 2. **Set up CI/CD** with Azure DevOps or GitHub Actions
255
+ 3. **Configure custom domains** for production
256
+ 4. **Set up monitoring alerts** in Application Insights
257
+ 5. **Enable backup** for Cosmos DB (set `enableBackup = true`)
258
+
259
+ ## Support
260
+
261
+ - **Azure Documentation**: https://docs.microsoft.com/azure/azure-functions/
262
+ - **Terraform Azure Provider**: https://registry.terraform.io/providers/hashicorp/azurerm/
263
+ - **SpecWeave**: https://spec-weave.com
264
+
265
+ ---
266
+
267
+ **Generated**: {{currentDate}}
268
+ **SpecWeave Version**: {{specweaveVersion}}
@@ -0,0 +1,34 @@
1
+ # Development Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-dev-rg"
6
+ app_name = "{{projectName}}-dev-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "Y1" # Consumption Plan (free tier eligible)
11
+ environment = "dev"
12
+
13
+ # Cosmos DB (optimized for dev - minimum cost)
14
+ database_account_name = "{{projectName}}-dev-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 400 # Minimum (cheapest)
19
+
20
+ # CORS (allow all for development)
21
+ cors_origins = ["*"]
22
+
23
+ # Storage Account (cheapest options)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "LRS" # Locally Redundant Storage (cheapest)
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Free tier optimization
31
+ # - Consumption Plan (Y1) for Function App
32
+ # - 400 RU/s Cosmos DB (minimum, stays within free tier for low usage)
33
+ # - LRS storage (cheapest)
34
+ # - Application Insights first 5 GB free
@@ -0,0 +1,46 @@
1
+ # Production Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-prod-rg"
6
+ app_name = "{{projectName}}-prod-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "EP2" # Elastic Premium EP2 (production-grade)
11
+ environment = "prod"
12
+
13
+ # Cosmos DB (production settings with backup)
14
+ database_account_name = "{{projectName}}-prod-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 4000 # Higher throughput for production
19
+
20
+ # CORS (restrict to production domain only)
21
+ cors_origins = ["https://{{projectName}}.com"]
22
+
23
+ # Storage Account (GRS for geo-redundancy)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "GRS" # Geo-Redundant Storage
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Production features (uncomment to enable)
31
+ # enable_automatic_failover = true
32
+ # enable_multi_region = true
33
+ # secondary_regions = ["westus2", "northeurope"]
34
+ # enable_backup = true
35
+ # enable_key_vault = true
36
+ # enable_vnet = true
37
+
38
+ # Production optimizations
39
+ # - Elastic Premium (EP2) for high performance and VNet support
40
+ # - 4000 RU/s Cosmos DB with autoscale option
41
+ # - GRS storage for disaster recovery
42
+ # - Multi-region Cosmos DB (optional, comment out to enable)
43
+ # - Automatic failover enabled (optional)
44
+ # - Continuous backup (optional)
45
+ # - Key Vault for secrets (optional)
46
+ # - VNet integration for secure networking (optional)
@@ -0,0 +1,34 @@
1
+ # Staging Environment Variables for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ location = "eastus"
5
+ resource_group_name = "{{projectName}}-staging-rg"
6
+ app_name = "{{projectName}}-staging-app"
7
+ runtime = "{{runtime}}"
8
+ runtime_version = "{{runtimeVersion}}"
9
+ os_type = "Linux"
10
+ sku_name = "EP1" # Elastic Premium (better performance than Consumption)
11
+ environment = "staging"
12
+
13
+ # Cosmos DB (moderate settings)
14
+ database_account_name = "{{projectName}}-staging-cosmos"
15
+ database_name = "{{databaseName}}"
16
+ container_name = "{{containerName}}"
17
+ partition_key = "{{partitionKey}}"
18
+ throughput = 1000 # Higher throughput for staging tests
19
+
20
+ # CORS (restrict to known origins)
21
+ cors_origins = ["https://staging.{{projectName}}.com"]
22
+
23
+ # Storage Account (ZRS for better durability)
24
+ storage_account_tier = "Standard"
25
+ storage_account_replication = "ZRS" # Zone-Redundant Storage
26
+
27
+ # Project tagging
28
+ project_name = "{{projectName}}"
29
+
30
+ # Staging optimizations
31
+ # - Elastic Premium (EP1) for consistent performance
32
+ # - 1000 RU/s Cosmos DB for realistic load testing
33
+ # - ZRS storage for better durability
34
+ # - Single region deployment
@@ -0,0 +1,225 @@
1
+ # Azure Functions + Cosmos DB Terraform Configuration
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ # Resource Group
5
+ resource "azurerm_resource_group" "{{snakeCase resourceGroupName}}" {
6
+ name = "{{resourceGroupName}}"
7
+ location = "{{location}}"
8
+
9
+ tags = {
10
+ Environment = "{{environment}}"
11
+ ManagedBy = "Terraform"
12
+ Project = "{{projectName}}"
13
+ }
14
+ }
15
+
16
+ # Storage Account (required for Function App)
17
+ resource "azurerm_storage_account" "{{snakeCase functionName}}" {
18
+ name = "{{snakeCase functionName}}storage"
19
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
20
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
21
+ account_tier = "{{storageAccountTier}}"
22
+ account_replication_type = "{{storageAccountReplication}}"
23
+
24
+ tags = {
25
+ Environment = "{{environment}}"
26
+ ManagedBy = "Terraform"
27
+ Project = "{{projectName}}"
28
+ }
29
+ }
30
+
31
+ # App Service Plan (Consumption Plan)
32
+ resource "azurerm_service_plan" "{{snakeCase functionName}}" {
33
+ name = "{{appName}}-plan"
34
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
35
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
36
+ os_type = "{{osType}}"
37
+ sku_name = "{{skuName}}"
38
+
39
+ tags = {
40
+ Environment = "{{environment}}"
41
+ ManagedBy = "Terraform"
42
+ Project = "{{projectName}}"
43
+ }
44
+ }
45
+
46
+ {{#if enableApplicationInsights}}
47
+ # Application Insights
48
+ resource "azurerm_application_insights" "{{snakeCase functionName}}" {
49
+ name = "{{appName}}-insights"
50
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
51
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
52
+ application_type = "web"
53
+
54
+ tags = {
55
+ Environment = "{{environment}}"
56
+ ManagedBy = "Terraform"
57
+ Project = "{{projectName}}"
58
+ }
59
+ }
60
+ {{/if}}
61
+
62
+ # Linux Function App
63
+ resource "azurerm_linux_function_app" "{{snakeCase functionName}}" {
64
+ name = "{{appName}}"
65
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
66
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
67
+
68
+ storage_account_name = azurerm_storage_account.{{snakeCase functionName}}.name
69
+ storage_account_access_key = azurerm_storage_account.{{snakeCase functionName}}.primary_access_key
70
+ service_plan_id = azurerm_service_plan.{{snakeCase functionName}}.id
71
+
72
+ site_config {
73
+ application_stack {
74
+ {{#if (eq runtime "node")}}
75
+ node_version = "{{runtimeVersion}}"
76
+ {{else if (eq runtime "python")}}
77
+ python_version = "{{runtimeVersion}}"
78
+ {{else if (eq runtime "dotnet")}}
79
+ dotnet_version = "{{runtimeVersion}}"
80
+ {{/if}}
81
+ }
82
+
83
+ cors {
84
+ allowed_origins = {{tfList corsOrigins}}
85
+ }
86
+
87
+ {{#if enableApplicationInsights}}
88
+ application_insights_key = azurerm_application_insights.{{snakeCase functionName}}.instrumentation_key
89
+ application_insights_connection_string = azurerm_application_insights.{{snakeCase functionName}}.connection_string
90
+ {{/if}}
91
+ }
92
+
93
+ app_settings = {
94
+ "ENVIRONMENT" = "{{environment}}"
95
+ "COSMOS_DB_ENDPOINT" = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.endpoint
96
+ "COSMOS_DB_KEY" = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.primary_key
97
+ "COSMOS_DB_DATABASE" = azurerm_cosmosdb_sql_database.{{snakeCase databaseName}}.name
98
+ "COSMOS_DB_CONTAINER" = azurerm_cosmosdb_sql_container.{{snakeCase containerName}}.name
99
+ "FUNCTIONS_WORKER_RUNTIME" = "{{runtime}}"
100
+ {{#if customAppSettings}}
101
+ {{#each customAppSettings}}
102
+ "{{@key}}" = "{{this}}"
103
+ {{/each}}
104
+ {{/if}}
105
+ }
106
+
107
+ identity {
108
+ type = "SystemAssigned"
109
+ }
110
+
111
+ tags = {
112
+ Environment = "{{environment}}"
113
+ ManagedBy = "Terraform"
114
+ Project = "{{projectName}}"
115
+ }
116
+ }
117
+
118
+ # Cosmos DB Account
119
+ resource "azurerm_cosmosdb_account" "{{snakeCase databaseAccountName}}" {
120
+ name = "{{databaseAccountName}}"
121
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
122
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
123
+ offer_type = "Standard"
124
+ kind = "GlobalDocumentDB"
125
+
126
+ consistency_policy {
127
+ consistency_level = "Session"
128
+ max_interval_in_seconds = 5
129
+ max_staleness_prefix = 100
130
+ }
131
+
132
+ geo_location {
133
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
134
+ failover_priority = 0
135
+ }
136
+
137
+ {{#if enableMultiRegion}}
138
+ {{#each secondaryRegions}}
139
+ geo_location {
140
+ location = "{{this}}"
141
+ failover_priority = {{@index}}
142
+ }
143
+ {{/each}}
144
+ {{/if}}
145
+
146
+ {{#if enableAutomaticFailover}}
147
+ enable_automatic_failover = true
148
+ {{/if}}
149
+
150
+ {{#if enableBackup}}
151
+ backup {
152
+ type = "Continuous"
153
+ interval_in_minutes = 240
154
+ retention_in_hours = 8
155
+ }
156
+ {{/if}}
157
+
158
+ tags = {
159
+ Environment = "{{environment}}"
160
+ ManagedBy = "Terraform"
161
+ Project = "{{projectName}}"
162
+ }
163
+ }
164
+
165
+ # Cosmos DB SQL Database
166
+ resource "azurerm_cosmosdb_sql_database" "{{snakeCase databaseName}}" {
167
+ name = "{{databaseName}}"
168
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
169
+ account_name = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.name
170
+ }
171
+
172
+ # Cosmos DB SQL Container
173
+ resource "azurerm_cosmosdb_sql_container" "{{snakeCase containerName}}" {
174
+ name = "{{containerName}}"
175
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
176
+ account_name = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.name
177
+ database_name = azurerm_cosmosdb_sql_database.{{snakeCase databaseName}}.name
178
+ partition_key_path = "{{partitionKey}}"
179
+ partition_key_version = 1
180
+ throughput = {{throughput}}
181
+
182
+ indexing_policy {
183
+ indexing_mode = "consistent"
184
+
185
+ included_path {
186
+ path = "/*"
187
+ }
188
+
189
+ excluded_path {
190
+ path = "/\"_etag\"/?"
191
+ }
192
+ }
193
+ }
194
+
195
+ {{#if enableKeyVault}}
196
+ # Key Vault
197
+ resource "azurerm_key_vault" "{{snakeCase functionName}}" {
198
+ name = "{{appName}}-kv"
199
+ resource_group_name = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
200
+ location = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
201
+ tenant_id = data.azurerm_client_config.current.tenant_id
202
+ sku_name = "standard"
203
+ soft_delete_retention_days = 7
204
+ purge_protection_enabled = false
205
+
206
+ access_policy {
207
+ tenant_id = data.azurerm_client_config.current.tenant_id
208
+ object_id = azurerm_linux_function_app.{{snakeCase functionName}}.identity[0].principal_id
209
+
210
+ secret_permissions = [
211
+ "Get",
212
+ "List"
213
+ ]
214
+ }
215
+
216
+ tags = {
217
+ Environment = "{{environment}}"
218
+ ManagedBy = "Terraform"
219
+ Project = "{{projectName}}"
220
+ }
221
+ }
222
+
223
+ # Data source for current Azure client config
224
+ data "azurerm_client_config" "current" {}
225
+ {{/if}}
@@ -0,0 +1,89 @@
1
+ # Output Values for Azure Functions + Cosmos DB
2
+ # Generated by SpecWeave Serverless Architecture Intelligence
3
+
4
+ output "resource_group_name" {
5
+ description = "Resource group name"
6
+ value = azurerm_resource_group.{{snakeCase resourceGroupName}}.name
7
+ }
8
+
9
+ output "resource_group_location" {
10
+ description = "Resource group location"
11
+ value = azurerm_resource_group.{{snakeCase resourceGroupName}}.location
12
+ }
13
+
14
+ output "function_app_name" {
15
+ description = "Function App name"
16
+ value = azurerm_linux_function_app.{{snakeCase functionName}}.name
17
+ }
18
+
19
+ output "function_app_id" {
20
+ description = "Function App ID"
21
+ value = azurerm_linux_function_app.{{snakeCase functionName}}.id
22
+ }
23
+
24
+ output "function_app_default_hostname" {
25
+ description = "Function App default hostname (URL)"
26
+ value = azurerm_linux_function_app.{{snakeCase functionName}}.default_hostname
27
+ }
28
+
29
+ output "function_app_url" {
30
+ description = "Function App HTTPS URL"
31
+ value = "https://${azurerm_linux_function_app.{{snakeCase functionName}}.default_hostname}"
32
+ }
33
+
34
+ output "function_app_principal_id" {
35
+ description = "Function App managed identity principal ID"
36
+ value = azurerm_linux_function_app.{{snakeCase functionName}}.identity[0].principal_id
37
+ }
38
+
39
+ output "cosmos_db_endpoint" {
40
+ description = "Cosmos DB endpoint URL"
41
+ value = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.endpoint
42
+ }
43
+
44
+ output "cosmos_db_id" {
45
+ description = "Cosmos DB account ID"
46
+ value = azurerm_cosmosdb_account.{{snakeCase databaseAccountName}}.id
47
+ }
48
+
49
+ output "cosmos_db_database_name" {
50
+ description = "Cosmos DB database name"
51
+ value = azurerm_cosmosdb_sql_database.{{snakeCase databaseName}}.name
52
+ }
53
+
54
+ output "cosmos_db_container_name" {
55
+ description = "Cosmos DB container name"
56
+ value = azurerm_cosmosdb_sql_container.{{snakeCase containerName}}.name
57
+ }
58
+
59
+ output "storage_account_name" {
60
+ description = "Storage account name"
61
+ value = azurerm_storage_account.{{snakeCase functionName}}.name
62
+ }
63
+
64
+ output "storage_account_primary_connection_string" {
65
+ description = "Storage account primary connection string"
66
+ value = azurerm_storage_account.{{snakeCase functionName}}.primary_connection_string
67
+ sensitive = true
68
+ }
69
+
70
+ {{#if enableApplicationInsights}}
71
+ output "application_insights_instrumentation_key" {
72
+ description = "Application Insights instrumentation key"
73
+ value = azurerm_application_insights.{{snakeCase functionName}}.instrumentation_key
74
+ sensitive = true
75
+ }
76
+
77
+ output "application_insights_connection_string" {
78
+ description = "Application Insights connection string"
79
+ value = azurerm_application_insights.{{snakeCase functionName}}.connection_string
80
+ sensitive = true
81
+ }
82
+ {{/if}}
83
+
84
+ {{#if enableKeyVault}}
85
+ output "key_vault_uri" {
86
+ description = "Key Vault URI"
87
+ value = azurerm_key_vault.{{snakeCase functionName}}.vault_uri
88
+ }
89
+ {{/if}}