@deftai/directive-content 0.55.0
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/.agents/skills/deft/SKILL.md +6 -0
- package/.agents/skills/deft-directive-article-review/SKILL.md +11 -0
- package/.agents/skills/deft-directive-build/SKILL.md +10 -0
- package/.agents/skills/deft-directive-cost/SKILL.md +12 -0
- package/.agents/skills/deft-directive-debug/SKILL.md +13 -0
- package/.agents/skills/deft-directive-gh-arch/SKILL.md +11 -0
- package/.agents/skills/deft-directive-gh-slice/SKILL.md +10 -0
- package/.agents/skills/deft-directive-glossary/SKILL.md +10 -0
- package/.agents/skills/deft-directive-interview/SKILL.md +9 -0
- package/.agents/skills/deft-directive-pre-pr/SKILL.md +9 -0
- package/.agents/skills/deft-directive-refinement/SKILL.md +10 -0
- package/.agents/skills/deft-directive-release/SKILL.md +12 -0
- package/.agents/skills/deft-directive-review-cycle/SKILL.md +10 -0
- package/.agents/skills/deft-directive-setup/SKILL.md +10 -0
- package/.agents/skills/deft-directive-swarm/SKILL.md +10 -0
- package/.agents/skills/deft-directive-sync/SKILL.md +9 -0
- package/.agents/skills/deft-directive-triage/SKILL.md +9 -0
- package/.agents/skills/deft-directive-write-skill/SKILL.md +9 -0
- package/LICENSE.md +22 -0
- package/QUICK-START.md +167 -0
- package/UPGRADING.md +517 -0
- package/coding/build-output.md +28 -0
- package/coding/coding.md +235 -0
- package/coding/debugging.md +110 -0
- package/coding/holzmann.md +96 -0
- package/coding/hygiene.md +127 -0
- package/coding/security.md +158 -0
- package/coding/testing.md +162 -0
- package/coding/toolchain.md +44 -0
- package/commands.md +300 -0
- package/context/context.md +57 -0
- package/context/deterministic-split.md +67 -0
- package/context/examples.md +26 -0
- package/context/fractal-summaries.md +69 -0
- package/context/long-horizon.md +46 -0
- package/context/spec-deltas.md +177 -0
- package/context/tool-design.md +34 -0
- package/context/working-memory.md +62 -0
- package/contracts/boundary-maps.md +65 -0
- package/contracts/deterministic-questions.md +59 -0
- package/contracts/hierarchy.md +77 -0
- package/conventions/content-manifest.json +399 -0
- package/conventions/machine-generated-banner.md +130 -0
- package/conventions/references.md +120 -0
- package/conventions/rule-ownership.json +382 -0
- package/conventions/task-caching.md +43 -0
- package/conventions/vbrief-filenames.md +70 -0
- package/deployments/README.md +37 -0
- package/deployments/agentuity/README.md +138 -0
- package/deployments/agentuity/via-cli.md +380 -0
- package/deployments/agentuity/via-cloud.md +425 -0
- package/deployments/agentuity/via-github-actions.md +664 -0
- package/deployments/agentuity/via-gravity-network.md +606 -0
- package/deployments/agentuity/via-vpc.md +607 -0
- package/deployments/aws/README.md +38 -0
- package/deployments/aws/via-app-runner.md +612 -0
- package/deployments/aws/via-ecs-fargate.md +561 -0
- package/deployments/aws/via-elastic-beanstalk.md +628 -0
- package/deployments/aws/via-lambda.md +649 -0
- package/deployments/azure/README.md +37 -0
- package/deployments/azure/via-aks.md +390 -0
- package/deployments/azure/via-app-service.md +564 -0
- package/deployments/azure/via-container-apps.md +599 -0
- package/deployments/azure/via-functions.md +552 -0
- package/deployments/cloud-gov/README.md +63 -0
- package/deployments/cloud-gov/agents/compliance-docs.md +154 -0
- package/deployments/cloud-gov/agents.md +39 -0
- package/deployments/cloud-gov/cicd.md +64 -0
- package/deployments/cloud-gov/deployment.md +150 -0
- package/deployments/cloud-gov/logging.md +43 -0
- package/deployments/cloud-gov/manifest.md +121 -0
- package/deployments/cloud-gov/overview.md +58 -0
- package/deployments/cloud-gov/security.md +46 -0
- package/deployments/cloud-gov/services.md +72 -0
- package/deployments/cloud-gov/upstream/README.md +18 -0
- package/deployments/cloudflare/README.md +33 -0
- package/deployments/cloudflare/via-dashboard.md +83 -0
- package/deployments/cloudflare/via-git.md +90 -0
- package/deployments/cloudflare/via-github-actions.md +185 -0
- package/deployments/cloudflare/via-terraform.md +157 -0
- package/deployments/cloudflare/via-wrangler.md +165 -0
- package/deployments/fly-io/README.md +37 -0
- package/deployments/fly-io/via-dockerfile.md +648 -0
- package/deployments/fly-io/via-flyctl.md +653 -0
- package/deployments/fly-io/via-github-actions.md +695 -0
- package/deployments/fly-io/via-multi-region.md +598 -0
- package/deployments/google/README.md +34 -0
- package/deployments/google/via-app-engine.md +42 -0
- package/deployments/google/via-cloud-functions.md +23 -0
- package/deployments/google/via-cloud-run.md +330 -0
- package/deployments/google/via-gke.md +23 -0
- package/deployments/netlify/README.md +99 -0
- package/deployments/netlify/via-cli.md +17 -0
- package/deployments/netlify/via-functions.md +19 -0
- package/deployments/netlify/via-git.md +25 -0
- package/deployments/vercel/README.md +90 -0
- package/deployments/vercel/via-api.md +16 -0
- package/deployments/vercel/via-cli.md +17 -0
- package/deployments/vercel/via-git.md +24 -0
- package/docs/BROWNFIELD.md +179 -0
- package/docs/getting-started.md +137 -0
- package/docs/good-agents-md.md +137 -0
- package/events/README.md +89 -0
- package/events/event-record.schema.json +26 -0
- package/events/registry.json +166 -0
- package/events/registry.schema.json +71 -0
- package/glossary.md +145 -0
- package/incidents/README.md +81 -0
- package/incidents/_template.md +38 -0
- package/interfaces/cli.md +104 -0
- package/interfaces/rest.md +212 -0
- package/interfaces/tui.md +242 -0
- package/interfaces/web.md +123 -0
- package/languages/6502-DASM.md +132 -0
- package/languages/c.md +235 -0
- package/languages/commands.md +23 -0
- package/languages/cpp.md +132 -0
- package/languages/csharp.md +259 -0
- package/languages/dart.md +183 -0
- package/languages/delphi.md +218 -0
- package/languages/elixir.md +208 -0
- package/languages/go.md +78 -0
- package/languages/java.md +278 -0
- package/languages/javascript.md +163 -0
- package/languages/julia.md +175 -0
- package/languages/kotlin.md +193 -0
- package/languages/markdown.md +168 -0
- package/languages/mermaid.md +146 -0
- package/languages/officejs.md +392 -0
- package/languages/python.md +209 -0
- package/languages/r.md +163 -0
- package/languages/rust.md +216 -0
- package/languages/sql.md +216 -0
- package/languages/swift.md +153 -0
- package/languages/typescript.md +132 -0
- package/languages/vba.md +279 -0
- package/languages/vhdl.md +180 -0
- package/languages/visual-basic.md +151 -0
- package/languages/zig.md +196 -0
- package/meta/SOUL.md +27 -0
- package/meta/code-field.md +44 -0
- package/meta/morals.md +40 -0
- package/meta/philosophy.md +39 -0
- package/meta/project.md +49 -0
- package/meta/ralph.md +223 -0
- package/meta/security.md +80 -0
- package/meta/versioning.md +326 -0
- package/package.json +22 -0
- package/packs/lessons/lessons-pack-0.1.json +553 -0
- package/packs/patterns/patterns-pack-0.1.json +57 -0
- package/packs/rules/rules-pack-0.1.json +4767 -0
- package/packs/skills/skills-pack-0.1.json +262 -0
- package/packs/strategies/strategies-pack-0.1.json +167 -0
- package/packs/swarm-spec/swarm-spec-pack-0.1.json +17 -0
- package/patterns/executor-layer-credentials.md +227 -0
- package/patterns/llm-app.md +156 -0
- package/patterns/multi-agent.md +278 -0
- package/patterns/prompt-assembly-layer-ordering.md +154 -0
- package/patterns/role-as-overlay.md +179 -0
- package/platforms/2600.md +137 -0
- package/platforms/unity.md +329 -0
- package/references/composer-skill-porting.md +152 -0
- package/references/cost-models.md +163 -0
- package/references/ip-risk.md +246 -0
- package/references/plain-english-ux.md +275 -0
- package/resilience/context-pruning.md +67 -0
- package/resilience/continue-here.md +62 -0
- package/scm/changelog.md +276 -0
- package/scm/git.md +139 -0
- package/scm/github.md +265 -0
- package/secrets/.gitkeep +0 -0
- package/skills/deft-build/SKILL.md +20 -0
- package/skills/deft-directive-article-review/SKILL.md +156 -0
- package/skills/deft-directive-build/SKILL.md +302 -0
- package/skills/deft-directive-cost/SKILL.md +201 -0
- package/skills/deft-directive-debug/SKILL.md +140 -0
- package/skills/deft-directive-decompose/SKILL.md +96 -0
- package/skills/deft-directive-gh-arch/SKILL.md +160 -0
- package/skills/deft-directive-gh-slice/SKILL.md +199 -0
- package/skills/deft-directive-glossary/SKILL.md +118 -0
- package/skills/deft-directive-interview/SKILL.md +528 -0
- package/skills/deft-directive-pre-pr/SKILL.md +131 -0
- package/skills/deft-directive-probe/SKILL.md +127 -0
- package/skills/deft-directive-refinement/SKILL.md +403 -0
- package/skills/deft-directive-release/SKILL.md +266 -0
- package/skills/deft-directive-review-cycle/SKILL.md +401 -0
- package/skills/deft-directive-setup/SKILL.md +717 -0
- package/skills/deft-directive-swarm/SKILL.md +989 -0
- package/skills/deft-directive-sync/SKILL.md +288 -0
- package/skills/deft-directive-triage/SKILL.md +137 -0
- package/skills/deft-directive-write-skill/SKILL.md +169 -0
- package/skills/deft-interview/SKILL.md +16 -0
- package/skills/deft-pre-pr/SKILL.md +16 -0
- package/skills/deft-review-cycle/SKILL.md +16 -0
- package/skills/deft-roadmap-refresh/SKILL.md +16 -0
- package/skills/deft-setup/SKILL.md +20 -0
- package/skills/deft-swarm/SKILL.md +16 -0
- package/skills/deft-sync/SKILL.md +16 -0
- package/strategies/README.md +83 -0
- package/strategies/artifact-guards.md +85 -0
- package/strategies/bdd.md +115 -0
- package/strategies/brownfield.md +7 -0
- package/strategies/discuss.md +129 -0
- package/strategies/emit-hints.md +69 -0
- package/strategies/enterprise.md +193 -0
- package/strategies/interview.md +551 -0
- package/strategies/map.md +179 -0
- package/strategies/probe.md +151 -0
- package/strategies/rapid.md +155 -0
- package/strategies/research.md +155 -0
- package/strategies/roadmap.md +9 -0
- package/strategies/speckit.md +437 -0
- package/strategies/v0-20-contract.md +134 -0
- package/strategies/yolo.md +169 -0
- package/swarm/swarm.md +300 -0
- package/templates/COST-ESTIMATE.md +114 -0
- package/templates/PULL_REQUEST_TEMPLATE.md +35 -0
- package/templates/agent-prompt-preamble.md +409 -0
- package/templates/agents-entry.md +211 -0
- package/templates/agents-entry.placeholders.md +75 -0
- package/templates/embed.go +20 -0
- package/templates/embed_test.go +36 -0
- package/templates/make-spec-example.md +9 -0
- package/templates/make-spec.md +246 -0
- package/templates/project.md.template +52 -0
- package/templates/specification.md +1 -0
- package/templates/swarm-greptile-poller-prompt.md +556 -0
- package/templates/user.md.template +31 -0
- package/tools/RWLDL.md +80 -0
- package/tools/greptile.md +141 -0
- package/tools/installer.md +23 -0
- package/tools/taskfile-migration.md +32 -0
- package/tools/taskfile.md +185 -0
- package/tools/telemetry.md +285 -0
- package/vbrief/schemas/cache-meta.schema.json +137 -0
- package/vbrief/schemas/candidates.schema.json +130 -0
- package/vbrief/schemas/codebase-map.schema.json +213 -0
- package/vbrief/schemas/lessons-pack.schema.json +134 -0
- package/vbrief/schemas/patterns-pack.schema.json +84 -0
- package/vbrief/schemas/rules-pack.schema.json +105 -0
- package/vbrief/schemas/skills-pack.schema.json +94 -0
- package/vbrief/schemas/slices.schema.json +87 -0
- package/vbrief/schemas/strategies-pack.schema.json +89 -0
- package/vbrief/schemas/swarm-spec-pack.schema.json +84 -0
- package/vbrief/schemas/vbrief-core.schema.json +1022 -0
- package/vbrief/vbrief.md +684 -0
- package/verification/integration.md +76 -0
- package/verification/plan-checking.md +85 -0
- package/verification/uat.md +60 -0
- package/verification/verification.md +117 -0
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
# Deploy via AWS Lambda
|
|
2
|
+
|
|
3
|
+
Deploy serverless functions and APIs using AWS Lambda with SAM (Serverless Application Model) or Serverless Framework. Event-driven compute without managing servers.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
AWS Lambda lets you run code in response to events:
|
|
8
|
+
- **Pay-per-use**: Only pay for compute time used
|
|
9
|
+
- **Auto-scaling**: Scales automatically with load
|
|
10
|
+
- **Event-driven**: Trigger from 200+ AWS services
|
|
11
|
+
- **Multiple Runtimes**: Python, Node.js, Java, Go, Ruby, .NET
|
|
12
|
+
- **Managed Infrastructure**: No servers to manage
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
|
|
16
|
+
- AWS account with appropriate IAM permissions
|
|
17
|
+
- AWS CLI installed and configured
|
|
18
|
+
- SAM CLI or Serverless Framework installed
|
|
19
|
+
- Application code
|
|
20
|
+
|
|
21
|
+
## Quick Start with SAM
|
|
22
|
+
|
|
23
|
+
### 1. Install SAM CLI
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# macOS
|
|
27
|
+
brew install aws-sam-cli
|
|
28
|
+
|
|
29
|
+
# Or via pip
|
|
30
|
+
pip install aws-sam-cli
|
|
31
|
+
|
|
32
|
+
# Verify installation
|
|
33
|
+
sam --version
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Initialize Project
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Create new SAM project
|
|
40
|
+
sam init
|
|
41
|
+
|
|
42
|
+
# Follow prompts:
|
|
43
|
+
# - Template: Hello World
|
|
44
|
+
# - Runtime: python3.11, nodejs18.x, etc.
|
|
45
|
+
# - Dependency manager: pip, npm, etc.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Project Structure
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
my-app/
|
|
52
|
+
├── template.yaml # SAM/CloudFormation template
|
|
53
|
+
├── samconfig.toml # SAM configuration
|
|
54
|
+
├── hello_world/
|
|
55
|
+
│ ├── app.py # Lambda function code
|
|
56
|
+
│ └── requirements.txt
|
|
57
|
+
└── tests/
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 4. Deploy
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Build
|
|
64
|
+
sam build
|
|
65
|
+
|
|
66
|
+
# Deploy (guided first time)
|
|
67
|
+
sam deploy --guided
|
|
68
|
+
|
|
69
|
+
# Subsequent deploys
|
|
70
|
+
sam deploy
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## SAM Template Example
|
|
74
|
+
|
|
75
|
+
### Simple HTTP API
|
|
76
|
+
|
|
77
|
+
```yaml
|
|
78
|
+
# template.yaml
|
|
79
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
|
80
|
+
Transform: AWS::Serverless-2016-10-31
|
|
81
|
+
Description: Simple HTTP API
|
|
82
|
+
|
|
83
|
+
Globals:
|
|
84
|
+
Function:
|
|
85
|
+
Timeout: 30
|
|
86
|
+
MemorySize: 512
|
|
87
|
+
Runtime: python3.11
|
|
88
|
+
Environment:
|
|
89
|
+
Variables:
|
|
90
|
+
STAGE: prod
|
|
91
|
+
|
|
92
|
+
Resources:
|
|
93
|
+
ApiFunction:
|
|
94
|
+
Type: AWS::Serverless::Function
|
|
95
|
+
Properties:
|
|
96
|
+
CodeUri: src/
|
|
97
|
+
Handler: app.lambda_handler
|
|
98
|
+
Events:
|
|
99
|
+
GetApi:
|
|
100
|
+
Type: HttpApi
|
|
101
|
+
Properties:
|
|
102
|
+
Path: /hello
|
|
103
|
+
Method: get
|
|
104
|
+
|
|
105
|
+
# DynamoDB table
|
|
106
|
+
DataTable:
|
|
107
|
+
Type: AWS::DynamoDB::Table
|
|
108
|
+
Properties:
|
|
109
|
+
TableName: !Sub ${AWS::StackName}-data
|
|
110
|
+
BillingMode: PAY_PER_REQUEST
|
|
111
|
+
AttributeDefinitions:
|
|
112
|
+
- AttributeName: id
|
|
113
|
+
AttributeType: S
|
|
114
|
+
KeySchema:
|
|
115
|
+
- AttributeName: id
|
|
116
|
+
KeyType: HASH
|
|
117
|
+
|
|
118
|
+
Outputs:
|
|
119
|
+
ApiUrl:
|
|
120
|
+
Description: API Gateway endpoint URL
|
|
121
|
+
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Lambda Function Code
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# src/app.py
|
|
128
|
+
import json
|
|
129
|
+
import boto3
|
|
130
|
+
import os
|
|
131
|
+
|
|
132
|
+
dynamodb = boto3.resource('dynamodb')
|
|
133
|
+
table_name = os.environ['TABLE_NAME']
|
|
134
|
+
|
|
135
|
+
def lambda_handler(event, context):
|
|
136
|
+
"""
|
|
137
|
+
Lambda function handler for HTTP API
|
|
138
|
+
"""
|
|
139
|
+
try:
|
|
140
|
+
# Parse request
|
|
141
|
+
body = json.loads(event.get('body', '{}'))
|
|
142
|
+
|
|
143
|
+
# Business logic here
|
|
144
|
+
result = process_data(body)
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
'statusCode': 200,
|
|
148
|
+
'headers': {
|
|
149
|
+
'Content-Type': 'application/json',
|
|
150
|
+
'Access-Control-Allow-Origin': '*'
|
|
151
|
+
},
|
|
152
|
+
'body': json.dumps(result)
|
|
153
|
+
}
|
|
154
|
+
except Exception as e:
|
|
155
|
+
return {
|
|
156
|
+
'statusCode': 500,
|
|
157
|
+
'body': json.dumps({'error': str(e)})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
def process_data(data):
|
|
161
|
+
# Your business logic
|
|
162
|
+
return {'message': 'Success', 'data': data}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Advanced SAM Patterns
|
|
166
|
+
|
|
167
|
+
### Multi-Function API
|
|
168
|
+
|
|
169
|
+
```yaml
|
|
170
|
+
Resources:
|
|
171
|
+
# GET /users
|
|
172
|
+
GetUsersFunction:
|
|
173
|
+
Type: AWS::Serverless::Function
|
|
174
|
+
Properties:
|
|
175
|
+
CodeUri: src/users/
|
|
176
|
+
Handler: get.handler
|
|
177
|
+
Events:
|
|
178
|
+
GetUsers:
|
|
179
|
+
Type: HttpApi
|
|
180
|
+
Properties:
|
|
181
|
+
Path: /users
|
|
182
|
+
Method: get
|
|
183
|
+
|
|
184
|
+
# POST /users
|
|
185
|
+
CreateUserFunction:
|
|
186
|
+
Type: AWS::Serverless::Function
|
|
187
|
+
Properties:
|
|
188
|
+
CodeUri: src/users/
|
|
189
|
+
Handler: create.handler
|
|
190
|
+
Events:
|
|
191
|
+
CreateUser:
|
|
192
|
+
Type: HttpApi
|
|
193
|
+
Properties:
|
|
194
|
+
Path: /users
|
|
195
|
+
Method: post
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### With VPC Access
|
|
199
|
+
|
|
200
|
+
```yaml
|
|
201
|
+
Resources:
|
|
202
|
+
VpcFunction:
|
|
203
|
+
Type: AWS::Serverless::Function
|
|
204
|
+
Properties:
|
|
205
|
+
CodeUri: src/
|
|
206
|
+
Handler: app.handler
|
|
207
|
+
VpcConfig:
|
|
208
|
+
SecurityGroupIds:
|
|
209
|
+
- !Ref LambdaSecurityGroup
|
|
210
|
+
SubnetIds:
|
|
211
|
+
- !Ref PrivateSubnet1
|
|
212
|
+
- !Ref PrivateSubnet2
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### With Layers
|
|
216
|
+
|
|
217
|
+
```yaml
|
|
218
|
+
Resources:
|
|
219
|
+
SharedLayer:
|
|
220
|
+
Type: AWS::Serverless::LayerVersion
|
|
221
|
+
Properties:
|
|
222
|
+
LayerName: shared-dependencies
|
|
223
|
+
ContentUri: layers/shared/
|
|
224
|
+
CompatibleRuntimes:
|
|
225
|
+
- python3.11
|
|
226
|
+
|
|
227
|
+
MyFunction:
|
|
228
|
+
Type: AWS::Serverless::Function
|
|
229
|
+
Properties:
|
|
230
|
+
CodeUri: src/
|
|
231
|
+
Handler: app.handler
|
|
232
|
+
Layers:
|
|
233
|
+
- !Ref SharedLayer
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Serverless Framework Alternative
|
|
237
|
+
|
|
238
|
+
### Installation
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
npm install -g serverless
|
|
242
|
+
|
|
243
|
+
# Create new project
|
|
244
|
+
serverless create --template aws-nodejs --path my-service
|
|
245
|
+
|
|
246
|
+
cd my-service
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### serverless.yml Configuration
|
|
250
|
+
|
|
251
|
+
```yaml
|
|
252
|
+
service: my-api
|
|
253
|
+
|
|
254
|
+
provider:
|
|
255
|
+
name: aws
|
|
256
|
+
runtime: nodejs18.x
|
|
257
|
+
region: us-east-1
|
|
258
|
+
stage: ${opt:stage, 'dev'}
|
|
259
|
+
environment:
|
|
260
|
+
STAGE: ${self:provider.stage}
|
|
261
|
+
TABLE_NAME: ${self:service}-${self:provider.stage}-data
|
|
262
|
+
|
|
263
|
+
iam:
|
|
264
|
+
role:
|
|
265
|
+
statements:
|
|
266
|
+
- Effect: Allow
|
|
267
|
+
Action:
|
|
268
|
+
- dynamodb:Query
|
|
269
|
+
- dynamodb:Scan
|
|
270
|
+
- dynamodb:GetItem
|
|
271
|
+
- dynamodb:PutItem
|
|
272
|
+
Resource: !GetAtt DataTable.Arn
|
|
273
|
+
|
|
274
|
+
functions:
|
|
275
|
+
hello:
|
|
276
|
+
handler: handler.hello
|
|
277
|
+
events:
|
|
278
|
+
- httpApi:
|
|
279
|
+
path: /hello
|
|
280
|
+
method: get
|
|
281
|
+
|
|
282
|
+
create:
|
|
283
|
+
handler: handler.create
|
|
284
|
+
events:
|
|
285
|
+
- httpApi:
|
|
286
|
+
path: /items
|
|
287
|
+
method: post
|
|
288
|
+
|
|
289
|
+
resources:
|
|
290
|
+
Resources:
|
|
291
|
+
DataTable:
|
|
292
|
+
Type: AWS::DynamoDB::Table
|
|
293
|
+
Properties:
|
|
294
|
+
TableName: ${self:provider.environment.TABLE_NAME}
|
|
295
|
+
BillingMode: PAY_PER_REQUEST
|
|
296
|
+
AttributeDefinitions:
|
|
297
|
+
- AttributeName: id
|
|
298
|
+
AttributeType: S
|
|
299
|
+
KeySchema:
|
|
300
|
+
- AttributeName: id
|
|
301
|
+
KeyType: HASH
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Deploy with Serverless Framework
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# Deploy all
|
|
308
|
+
serverless deploy
|
|
309
|
+
|
|
310
|
+
# Deploy single function
|
|
311
|
+
serverless deploy function -f hello
|
|
312
|
+
|
|
313
|
+
# Remove stack
|
|
314
|
+
serverless remove
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Event Sources
|
|
318
|
+
|
|
319
|
+
### API Gateway HTTP API
|
|
320
|
+
|
|
321
|
+
```yaml
|
|
322
|
+
Events:
|
|
323
|
+
HttpApi:
|
|
324
|
+
Type: HttpApi
|
|
325
|
+
Properties:
|
|
326
|
+
Path: /users/{id}
|
|
327
|
+
Method: get
|
|
328
|
+
Auth:
|
|
329
|
+
Authorizer: NONE
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### API Gateway REST API
|
|
333
|
+
|
|
334
|
+
```yaml
|
|
335
|
+
Events:
|
|
336
|
+
RestApi:
|
|
337
|
+
Type: Api
|
|
338
|
+
Properties:
|
|
339
|
+
Path: /users/{id}
|
|
340
|
+
Method: get
|
|
341
|
+
RestApiId: !Ref MyRestApi
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### S3 Events
|
|
345
|
+
|
|
346
|
+
```yaml
|
|
347
|
+
Events:
|
|
348
|
+
S3Upload:
|
|
349
|
+
Type: S3
|
|
350
|
+
Properties:
|
|
351
|
+
Bucket: !Ref UploadBucket
|
|
352
|
+
Events: s3:ObjectCreated:*
|
|
353
|
+
Filter:
|
|
354
|
+
S3Key:
|
|
355
|
+
Rules:
|
|
356
|
+
- Name: suffix
|
|
357
|
+
Value: .jpg
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### DynamoDB Streams
|
|
361
|
+
|
|
362
|
+
```yaml
|
|
363
|
+
Events:
|
|
364
|
+
DynamoStream:
|
|
365
|
+
Type: DynamoDB
|
|
366
|
+
Properties:
|
|
367
|
+
Stream: !GetAtt DataTable.StreamArn
|
|
368
|
+
StartingPosition: TRIM_HORIZON
|
|
369
|
+
BatchSize: 10
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### EventBridge (CloudWatch Events)
|
|
373
|
+
|
|
374
|
+
```yaml
|
|
375
|
+
Events:
|
|
376
|
+
Schedule:
|
|
377
|
+
Type: Schedule
|
|
378
|
+
Properties:
|
|
379
|
+
Schedule: rate(5 minutes)
|
|
380
|
+
Input: '{"key": "value"}'
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### SQS Queue
|
|
384
|
+
|
|
385
|
+
```yaml
|
|
386
|
+
Events:
|
|
387
|
+
QueueProcessor:
|
|
388
|
+
Type: SQS
|
|
389
|
+
Properties:
|
|
390
|
+
Queue: !GetAtt MyQueue.Arn
|
|
391
|
+
BatchSize: 10
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
## Configuration Management
|
|
395
|
+
|
|
396
|
+
### Environment Variables
|
|
397
|
+
|
|
398
|
+
```yaml
|
|
399
|
+
# template.yaml
|
|
400
|
+
Resources:
|
|
401
|
+
MyFunction:
|
|
402
|
+
Type: AWS::Serverless::Function
|
|
403
|
+
Properties:
|
|
404
|
+
Environment:
|
|
405
|
+
Variables:
|
|
406
|
+
DATABASE_URL: !Sub "{{resolve:secretsmanager:${DatabaseSecret}:SecretString:url}}"
|
|
407
|
+
API_KEY: !Sub "{{resolve:ssm:/${AWS::StackName}/api-key}}"
|
|
408
|
+
STAGE: !Ref Stage
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### Parameter Store
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
# Store secrets
|
|
415
|
+
aws ssm put-parameter \
|
|
416
|
+
--name "/my-app/api-key" \
|
|
417
|
+
--value "secret-value" \
|
|
418
|
+
--type SecureString
|
|
419
|
+
|
|
420
|
+
# Reference in template
|
|
421
|
+
DATABASE_URL: !Sub "{{resolve:ssm:/my-app/db-url}}"
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
### Secrets Manager
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
# Store secret
|
|
428
|
+
aws secretsmanager create-secret \
|
|
429
|
+
--name my-app/db-credentials \
|
|
430
|
+
--secret-string '{"username":"admin","password":"secret"}'
|
|
431
|
+
|
|
432
|
+
# Reference in template
|
|
433
|
+
DB_SECRET: !Sub "{{resolve:secretsmanager:my-app/db-credentials}}"
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Local Development
|
|
437
|
+
|
|
438
|
+
### SAM Local
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
# Start local API
|
|
442
|
+
sam local start-api
|
|
443
|
+
|
|
444
|
+
# Invoke function locally
|
|
445
|
+
sam local invoke MyFunction -e events/event.json
|
|
446
|
+
|
|
447
|
+
# Generate sample event
|
|
448
|
+
sam local generate-event apigateway aws-proxy > event.json
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### Serverless Offline
|
|
452
|
+
|
|
453
|
+
```bash
|
|
454
|
+
# Install plugin
|
|
455
|
+
npm install --save-dev serverless-offline
|
|
456
|
+
|
|
457
|
+
# Add to serverless.yml
|
|
458
|
+
plugins:
|
|
459
|
+
- serverless-offline
|
|
460
|
+
|
|
461
|
+
# Run locally
|
|
462
|
+
serverless offline start
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## Testing
|
|
466
|
+
|
|
467
|
+
### Unit Tests
|
|
468
|
+
|
|
469
|
+
```python
|
|
470
|
+
# tests/test_app.py
|
|
471
|
+
import pytest
|
|
472
|
+
from src import app
|
|
473
|
+
|
|
474
|
+
def test_lambda_handler():
|
|
475
|
+
event = {
|
|
476
|
+
'httpMethod': 'GET',
|
|
477
|
+
'path': '/hello',
|
|
478
|
+
'body': None
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
response = app.lambda_handler(event, None)
|
|
482
|
+
|
|
483
|
+
assert response['statusCode'] == 200
|
|
484
|
+
assert 'message' in response['body']
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### Integration Tests
|
|
488
|
+
|
|
489
|
+
```bash
|
|
490
|
+
# Deploy to test environment
|
|
491
|
+
sam deploy --config-env test
|
|
492
|
+
|
|
493
|
+
# Run tests against deployed API
|
|
494
|
+
pytest tests/integration/
|
|
495
|
+
|
|
496
|
+
# Clean up
|
|
497
|
+
sam delete --stack-name my-app-test
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
## CI/CD Integration
|
|
501
|
+
|
|
502
|
+
### GitHub Actions
|
|
503
|
+
|
|
504
|
+
```yaml
|
|
505
|
+
# .github/workflows/deploy.yml
|
|
506
|
+
name: Deploy Lambda
|
|
507
|
+
|
|
508
|
+
on:
|
|
509
|
+
push:
|
|
510
|
+
branches: [main]
|
|
511
|
+
|
|
512
|
+
jobs:
|
|
513
|
+
deploy:
|
|
514
|
+
runs-on: ubuntu-latest
|
|
515
|
+
steps:
|
|
516
|
+
- uses: actions/checkout@v3
|
|
517
|
+
|
|
518
|
+
- uses: aws-actions/setup-sam@v2
|
|
519
|
+
|
|
520
|
+
- uses: aws-actions/configure-aws-credentials@v2
|
|
521
|
+
with:
|
|
522
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
523
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
524
|
+
aws-region: us-east-1
|
|
525
|
+
|
|
526
|
+
- name: Build and deploy
|
|
527
|
+
run: |
|
|
528
|
+
sam build
|
|
529
|
+
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
## Monitoring and Logging
|
|
533
|
+
|
|
534
|
+
### CloudWatch Logs
|
|
535
|
+
|
|
536
|
+
```bash
|
|
537
|
+
# View logs
|
|
538
|
+
sam logs -n MyFunction --tail
|
|
539
|
+
|
|
540
|
+
# Filter logs
|
|
541
|
+
aws logs filter-log-events \
|
|
542
|
+
--log-group-name /aws/lambda/MyFunction \
|
|
543
|
+
--filter-pattern "ERROR"
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
### X-Ray Tracing
|
|
547
|
+
|
|
548
|
+
```yaml
|
|
549
|
+
# template.yaml
|
|
550
|
+
Globals:
|
|
551
|
+
Function:
|
|
552
|
+
Tracing: Active
|
|
553
|
+
|
|
554
|
+
# In code (Python)
|
|
555
|
+
from aws_xray_sdk.core import xray_recorder
|
|
556
|
+
|
|
557
|
+
@xray_recorder.capture('process_request')
|
|
558
|
+
def process_request(data):
|
|
559
|
+
# Your code
|
|
560
|
+
pass
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
### CloudWatch Metrics
|
|
564
|
+
|
|
565
|
+
```python
|
|
566
|
+
import boto3
|
|
567
|
+
|
|
568
|
+
cloudwatch = boto3.client('cloudwatch')
|
|
569
|
+
|
|
570
|
+
cloudwatch.put_metric_data(
|
|
571
|
+
Namespace='MyApp',
|
|
572
|
+
MetricData=[
|
|
573
|
+
{
|
|
574
|
+
'MetricName': 'ProcessedItems',
|
|
575
|
+
'Value': 1,
|
|
576
|
+
'Unit': 'Count'
|
|
577
|
+
}
|
|
578
|
+
]
|
|
579
|
+
)
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
## Best Practices
|
|
583
|
+
|
|
584
|
+
1. **Keep Functions Small**: Single responsibility, < 50 MB package
|
|
585
|
+
2. **Use Layers**: Share dependencies across functions
|
|
586
|
+
3. **Optimize Cold Starts**: Minimize dependencies, use provisioned concurrency for critical paths
|
|
587
|
+
4. **Environment Variables**: Use for configuration, not secrets
|
|
588
|
+
5. **Secrets Management**: Always use Secrets Manager or Parameter Store
|
|
589
|
+
6. **Error Handling**: Implement proper error handling and retries
|
|
590
|
+
7. **Monitoring**: Enable X-Ray, CloudWatch Logs Insights
|
|
591
|
+
8. **IAM Least Privilege**: Grant minimum necessary permissions
|
|
592
|
+
9. **VPC Only When Needed**: VPC adds cold start latency
|
|
593
|
+
10. **Timeout Configuration**: Set appropriate timeout for workload
|
|
594
|
+
|
|
595
|
+
## Cost Optimization
|
|
596
|
+
|
|
597
|
+
```yaml
|
|
598
|
+
# Right-size memory (CPU scales with memory)
|
|
599
|
+
MemorySize: 512 # Test 128, 256, 512, 1024, etc.
|
|
600
|
+
|
|
601
|
+
# Set appropriate timeout
|
|
602
|
+
Timeout: 30 # Don't use max unless needed
|
|
603
|
+
|
|
604
|
+
# Use ARM architecture (Graviton2)
|
|
605
|
+
Architectures:
|
|
606
|
+
- arm64
|
|
607
|
+
|
|
608
|
+
# Reserved concurrency for cost control
|
|
609
|
+
ReservedConcurrentExecutions: 100
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
## Troubleshooting
|
|
613
|
+
|
|
614
|
+
### Common Issues
|
|
615
|
+
|
|
616
|
+
**Cold Start Latency**
|
|
617
|
+
```yaml
|
|
618
|
+
# Use provisioned concurrency
|
|
619
|
+
ProvisionedConcurrencyConfig:
|
|
620
|
+
ProvisionedConcurrentExecutions: 5
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
**Timeout Errors**
|
|
624
|
+
```yaml
|
|
625
|
+
# Increase timeout
|
|
626
|
+
Timeout: 60 # Up to 900 seconds (15 min)
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
**Memory Errors**
|
|
630
|
+
```yaml
|
|
631
|
+
# Increase memory
|
|
632
|
+
MemorySize: 1024 # Up to 10,240 MB
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
**Permission Errors**
|
|
636
|
+
```yaml
|
|
637
|
+
# Add IAM policies
|
|
638
|
+
Policies:
|
|
639
|
+
- DynamoDBCrudPolicy:
|
|
640
|
+
TableName: !Ref DataTable
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
## References
|
|
644
|
+
|
|
645
|
+
- [AWS SAM Documentation](https://docs.aws.amazon.com/serverless-application-model/)
|
|
646
|
+
- [AWS Lambda Documentation](https://docs.aws.amazon.com/lambda/)
|
|
647
|
+
- [Serverless Framework Docs](https://www.serverless.com/framework/docs)
|
|
648
|
+
- [Lambda Best Practices](https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html)
|
|
649
|
+
- [SAM CLI Reference](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-command-reference.html)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Azure Deployment Module
|
|
2
|
+
|
|
3
|
+
Deft guidance for deploying applications to Microsoft Azure.
|
|
4
|
+
|
|
5
|
+
## Status
|
|
6
|
+
|
|
7
|
+
- ! Optional module
|
|
8
|
+
- ~ Good for Deft usage
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
Azure provides enterprise-grade deployment options with strong Microsoft ecosystem integration.
|
|
13
|
+
|
|
14
|
+
## Deployment Methods
|
|
15
|
+
|
|
16
|
+
| File | Method | Best For |
|
|
17
|
+
|------|--------|----------|
|
|
18
|
+
| `via-app-service.md` | Azure App Service | Traditional web apps, APIs, multi-language PaaS (default for web apps) |
|
|
19
|
+
| `via-container-apps.md` | Azure Container Apps | Microservices, serverless containers, scale-to-zero (default for containers) |
|
|
20
|
+
| `via-functions.md` | Azure Functions | Serverless functions, event-driven workloads (default for serverless) |
|
|
21
|
+
| `via-aks.md` | Azure Kubernetes Service | Complex Kubernetes workloads, advanced orchestration |
|
|
22
|
+
|
|
23
|
+
## Quick Decision Guide
|
|
24
|
+
|
|
25
|
+
- **Default web apps**: `via-app-service.md` — `az webapp up` for Node.js, Python, .NET, Java, PHP, Ruby
|
|
26
|
+
- **Default containers**: `via-container-apps.md` — serverless containers with Dapr, KEDA, scale-to-zero
|
|
27
|
+
- **Default serverless**: `via-functions.md` — event-driven functions with consumption pricing
|
|
28
|
+
- **Complex orchestration**: `via-aks.md` — when you need full Kubernetes control
|
|
29
|
+
|
|
30
|
+
## References
|
|
31
|
+
|
|
32
|
+
- [Azure Compute Services](https://azure.microsoft.com/products/category/compute/)
|
|
33
|
+
- [Azure App Service Documentation](https://docs.microsoft.com/azure/app-service/)
|
|
34
|
+
- [Azure Container Apps Documentation](https://docs.microsoft.com/azure/container-apps/)
|
|
35
|
+
- [Azure Functions Documentation](https://docs.microsoft.com/azure/azure-functions/)
|
|
36
|
+
- [Azure Kubernetes Service Documentation](https://docs.microsoft.com/azure/aks/)
|
|
37
|
+
- [Azure Static Web Apps Documentation](https://docs.microsoft.com/azure/static-web-apps/)
|