stacktape 3.5.8 → 3.6.0-beta.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/.tsconfig.bun-build.json +1 -0
- package/ai-docs/cli-ref/aws-profile-create.md +22 -0
- package/ai-docs/cli-ref/aws-profile-delete.md +22 -0
- package/ai-docs/cli-ref/aws-profile-list.md +20 -0
- package/ai-docs/cli-ref/aws-profile-update.md +22 -0
- package/ai-docs/cli-ref/bastion-session.md +29 -0
- package/ai-docs/cli-ref/bastion-tunnel.md +30 -0
- package/ai-docs/cli-ref/bucket-sync.md +30 -0
- package/ai-docs/cli-ref/cf-module-update.md +26 -0
- package/ai-docs/cli-ref/cf-rollback.md +28 -0
- package/ai-docs/cli-ref/codebuild-deploy.md +34 -0
- package/ai-docs/cli-ref/compile-template.md +25 -0
- package/ai-docs/cli-ref/container-session.md +30 -0
- package/ai-docs/cli-ref/debug-alarms.md +28 -0
- package/ai-docs/cli-ref/debug-aws-sdk.md +33 -0
- package/ai-docs/cli-ref/debug-container-exec.md +36 -0
- package/ai-docs/cli-ref/debug-dynamodb.md +35 -0
- package/ai-docs/cli-ref/debug-logs.md +34 -0
- package/ai-docs/cli-ref/debug-metrics.md +33 -0
- package/ai-docs/cli-ref/debug-opensearch.md +35 -0
- package/ai-docs/cli-ref/debug-redis.md +36 -0
- package/ai-docs/cli-ref/debug-sql.md +35 -0
- package/ai-docs/cli-ref/defaults-configure.md +29 -0
- package/ai-docs/cli-ref/defaults-list.md +20 -0
- package/ai-docs/cli-ref/delete.md +24 -0
- package/ai-docs/cli-ref/deploy.md +25 -0
- package/ai-docs/cli-ref/deployment-script-run.md +28 -0
- package/ai-docs/cli-ref/dev-stop.md +26 -0
- package/ai-docs/cli-ref/dev.md +45 -0
- package/ai-docs/cli-ref/domain-add.md +26 -0
- package/ai-docs/cli-ref/help.md +18 -0
- package/ai-docs/cli-ref/info-operations.md +22 -0
- package/ai-docs/cli-ref/info-stack.md +30 -0
- package/ai-docs/cli-ref/info-stacks.md +26 -0
- package/ai-docs/cli-ref/info-whoami.md +22 -0
- package/ai-docs/cli-ref/init.md +30 -0
- package/ai-docs/cli-ref/login.md +20 -0
- package/ai-docs/cli-ref/logout.md +18 -0
- package/ai-docs/cli-ref/mcp-add.md +22 -0
- package/ai-docs/cli-ref/mcp.md +20 -0
- package/ai-docs/cli-ref/org-create.md +24 -0
- package/ai-docs/cli-ref/org-delete.md +24 -0
- package/ai-docs/cli-ref/org-list.md +22 -0
- package/ai-docs/cli-ref/package-workloads.md +25 -0
- package/ai-docs/cli-ref/param-get.md +26 -0
- package/ai-docs/cli-ref/preview-changes.md +23 -0
- package/ai-docs/cli-ref/project-create.md +22 -0
- package/ai-docs/cli-ref/projects-list.md +22 -0
- package/ai-docs/cli-ref/rollback.md +28 -0
- package/ai-docs/cli-ref/script-run.md +29 -0
- package/ai-docs/cli-ref/secret-create.md +28 -0
- package/ai-docs/cli-ref/secret-delete.md +26 -0
- package/ai-docs/cli-ref/secret-get.md +26 -0
- package/ai-docs/cli-ref/upgrade.md +20 -0
- package/ai-docs/cli-ref/version.md +18 -0
- package/ai-docs/concept/connecting-resources.md +369 -0
- package/ai-docs/concept/directives.md +371 -0
- package/ai-docs/concept/extending-cloudformation.md +315 -0
- package/ai-docs/concept/overrides-and-transforms.md +352 -0
- package/ai-docs/concept/stages-and-environments.md +347 -0
- package/ai-docs/concept/typescript-config.md +447 -0
- package/ai-docs/concept/yaml-config.md +338 -0
- package/ai-docs/config-ref/_root.md +142 -0
- package/ai-docs/config-ref/application-load-balancer.md +1109 -0
- package/ai-docs/config-ref/astro-web.md +115 -0
- package/ai-docs/config-ref/aws-cdk-construct.md +68 -0
- package/ai-docs/config-ref/bastion.md +93 -0
- package/ai-docs/config-ref/batch-job.md +179 -0
- package/ai-docs/config-ref/bucket.md +348 -0
- package/ai-docs/config-ref/cdn.md +496 -0
- package/ai-docs/config-ref/custom-resource.md +80 -0
- package/ai-docs/config-ref/deployment-script.md +79 -0
- package/ai-docs/config-ref/dynamo-db-table.md +202 -0
- package/ai-docs/config-ref/edge-lambda-function.md +87 -0
- package/ai-docs/config-ref/efs-filesystem.md +72 -0
- package/ai-docs/config-ref/event-bus.md +63 -0
- package/ai-docs/config-ref/function.md +409 -0
- package/ai-docs/config-ref/hosting-bucket.md +171 -0
- package/ai-docs/config-ref/http-api-gateway.md +149 -0
- package/ai-docs/config-ref/http-endpoint.md +92 -0
- package/ai-docs/config-ref/kinesis-stream.md +97 -0
- package/ai-docs/config-ref/mongo-db-atlas-cluster.md +254 -0
- package/ai-docs/config-ref/multi-container-workload.md +399 -0
- package/ai-docs/config-ref/network-load-balancer.md +118 -0
- package/ai-docs/config-ref/nextjs-web.md +147 -0
- package/ai-docs/config-ref/nuxt-web.md +81 -0
- package/ai-docs/config-ref/open-search.md +206 -0
- package/ai-docs/config-ref/private-service.md +75 -0
- package/ai-docs/config-ref/redis-cluster.md +223 -0
- package/ai-docs/config-ref/relational-database.md +525 -0
- package/ai-docs/config-ref/remix-web.md +74 -0
- package/ai-docs/config-ref/sns-topic.md +69 -0
- package/ai-docs/config-ref/solidstart-web.md +75 -0
- package/ai-docs/config-ref/sqs-queue-not-empty.md +405 -0
- package/ai-docs/config-ref/sqs-queue.md +232 -0
- package/ai-docs/config-ref/state-machine.md +235 -0
- package/ai-docs/config-ref/sveltekit-web.md +81 -0
- package/ai-docs/config-ref/tanstack-web.md +75 -0
- package/ai-docs/config-ref/upstash-redis.md +59 -0
- package/ai-docs/config-ref/user-auth-pool.md +876 -0
- package/ai-docs/config-ref/web-app-firewall.md +212 -0
- package/ai-docs/config-ref/web-service.md +178 -0
- package/ai-docs/config-ref/worker-service.md +41 -0
- package/ai-docs/getting-started/console.md +232 -0
- package/ai-docs/getting-started/deployment.md +434 -0
- package/ai-docs/getting-started/dev-mode.md +118 -0
- package/ai-docs/getting-started/how-it-works.md +119 -0
- package/ai-docs/getting-started/intro.md +157 -0
- package/ai-docs/getting-started/using-with-ai.md +228 -0
- package/ai-docs/getting-started/workflow.md +197 -0
- package/ai-docs/index.json +1514 -0
- package/ai-docs/recipe/background-jobs.md +183 -0
- package/ai-docs/recipe/database-migrations.md +240 -0
- package/ai-docs/recipe/graphql-api.md +211 -0
- package/ai-docs/recipe/monorepo-setup.md +183 -0
- package/ai-docs/recipe/nextjs-full-stack.md +188 -0
- package/ai-docs/recipe/rest-api-with-database.md +156 -0
- package/ai-docs/recipe/scheduled-tasks.md +186 -0
- package/ai-docs/recipe/static-website.md +241 -0
- package/ai-docs/troubleshooting/cloudformation-stack-states.md +189 -0
- package/bin/stacktape.js +0 -12
- package/package.json +1 -1
- package/plain.d.ts +309 -54
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: getting-started
|
|
3
|
+
title: Deployment
|
|
4
|
+
tags:
|
|
5
|
+
- deployment
|
|
6
|
+
- getting-started
|
|
7
|
+
source: docs/_curated-docs/getting-started/deployment.mdx
|
|
8
|
+
priority: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Deployment
|
|
12
|
+
|
|
13
|
+
This guide covers everything you need to know about deploying your Stacktape infrastructure to AWS.
|
|
14
|
+
|
|
15
|
+
## Basic Deployment
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
stacktape deploy --stage dev --region us-east-1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Option | Required | Description |
|
|
22
|
+
| ----------------- | -------- | ------------------------------------------------------------------------- |
|
|
23
|
+
| `--stage` (`-s`) | Yes | Environment name: `dev`, `staging`, `production`, etc. Max 12 characters. |
|
|
24
|
+
| `--region` (`-r`) | Yes | AWS region: `us-east-1`, `eu-west-1`, `ap-southeast-1`, etc. |
|
|
25
|
+
| `--configPath` | No | Path to config file. Default: `stacktape.ts` or `stacktape.yml` |
|
|
26
|
+
| `--awsProfile` | No | AWS profile to use. Default: `default` |
|
|
27
|
+
|
|
28
|
+
## What Happens During Deployment
|
|
29
|
+
|
|
30
|
+
### Example Output
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
Stacktape: Deploy
|
|
34
|
+
|
|
35
|
+
Stage: dev
|
|
36
|
+
Region: us-east-1
|
|
37
|
+
Stack: my-api-dev
|
|
38
|
+
|
|
39
|
+
✓ Validating configuration...
|
|
40
|
+
✓ Packaging handler (1.2 MB)...
|
|
41
|
+
✓ Packaging worker (890 KB)...
|
|
42
|
+
✓ Uploading artifacts to S3...
|
|
43
|
+
✓ Deploying CloudFormation stack...
|
|
44
|
+
|
|
45
|
+
Creating: MyApiDevHandlerLambda
|
|
46
|
+
Creating: MyApiDevDatabase
|
|
47
|
+
Creating: MyApiDevApiGateway
|
|
48
|
+
✓ Created: MyApiDevHandlerLambda
|
|
49
|
+
✓ Created: MyApiDevDatabase
|
|
50
|
+
✓ Created: MyApiDevApiGateway
|
|
51
|
+
|
|
52
|
+
✓ Stack deployed successfully in 47s
|
|
53
|
+
|
|
54
|
+
Stack Outputs:
|
|
55
|
+
api.url: https://abc123.execute-api.us-east-1.amazonaws.com
|
|
56
|
+
database.host: my-api-dev-db.xxx.us-east-1.rds.amazonaws.com
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Deployment Strategies
|
|
60
|
+
|
|
61
|
+
### Hot-Swap (Development)
|
|
62
|
+
|
|
63
|
+
Update Lambda code in ~5 seconds without full CloudFormation deployment:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
stacktape deploy --stage dev --region us-east-1 --hotSwap
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Hot-swap directly updates Lambda function code, bypassing CloudFormation. Use only for development - it can cause state drift.
|
|
70
|
+
|
|
71
|
+
**What hot-swap updates:**
|
|
72
|
+
|
|
73
|
+
- Lambda function code
|
|
74
|
+
- Lambda environment variables
|
|
75
|
+
- Container image references
|
|
76
|
+
|
|
77
|
+
**What hot-swap doesn't update:**
|
|
78
|
+
|
|
79
|
+
- New resources (databases, queues, etc.)
|
|
80
|
+
- IAM permissions
|
|
81
|
+
- API Gateway routes
|
|
82
|
+
- Resource configuration (memory, timeout, etc.)
|
|
83
|
+
|
|
84
|
+
### Full Deployment (Production)
|
|
85
|
+
|
|
86
|
+
Always use full deployment for production:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
stacktape deploy --stage production --region us-east-1
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Full deployment:
|
|
93
|
+
|
|
94
|
+
- Updates all resources through CloudFormation
|
|
95
|
+
- Maintains infrastructure state consistency
|
|
96
|
+
- Enables automatic rollback on failure
|
|
97
|
+
- Required for any configuration changes
|
|
98
|
+
|
|
99
|
+
### CodeBuild Deployment
|
|
100
|
+
|
|
101
|
+
For resource-intensive builds (large Docker images, monorepos), offload to AWS CodeBuild:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
stacktape codebuild:deploy --stage production --region us-east-1
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
This:
|
|
108
|
+
|
|
109
|
+
1. Zips your project and uploads to S3
|
|
110
|
+
2. Spins up a CodeBuild environment in your AWS account
|
|
111
|
+
3. Runs the deployment there (more CPU/memory available)
|
|
112
|
+
4. Streams logs to your terminal
|
|
113
|
+
|
|
114
|
+
Useful when your local machine is slow or has limited resources.
|
|
115
|
+
|
|
116
|
+
## Deployment Options
|
|
117
|
+
|
|
118
|
+
### Skip Confirmation Prompts
|
|
119
|
+
|
|
120
|
+
For CI/CD pipelines:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
stacktape deploy --stage production --region us-east-1 --autoConfirmOperation
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Disable Auto-Rollback
|
|
127
|
+
|
|
128
|
+
By default, failed deployments automatically rollback to the previous state. Disable this to debug failures:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
stacktape deploy --stage dev --region us-east-1 --disableAutoRollback
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Then inspect the failed resources in AWS Console, fix the issue, and either:
|
|
135
|
+
|
|
136
|
+
- Deploy again (will continue from failed state)
|
|
137
|
+
- Manually rollback: `stacktape rollback --stage dev --region us-east-1`
|
|
138
|
+
|
|
139
|
+
### Preserve Temp Files
|
|
140
|
+
|
|
141
|
+
Keep generated CloudFormation templates for debugging:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
stacktape deploy --stage dev --region us-east-1 --preserveTempFiles
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Files are saved to `.stacktape/<invocation-id>/`.
|
|
148
|
+
|
|
149
|
+
### Debug Logging
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
stacktape deploy --stage dev --region us-east-1 --logLevel debug
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### No Build Cache
|
|
156
|
+
|
|
157
|
+
Force fresh builds (useful if cache is corrupted):
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
stacktape deploy --stage dev --region us-east-1 --noCache
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## CI/CD Integration
|
|
164
|
+
|
|
165
|
+
### GitHub Actions
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
# .github/workflows/deploy.yml
|
|
169
|
+
name: Deploy
|
|
170
|
+
|
|
171
|
+
on:
|
|
172
|
+
push:
|
|
173
|
+
branches: [main]
|
|
174
|
+
|
|
175
|
+
jobs:
|
|
176
|
+
deploy:
|
|
177
|
+
runs-on: ubuntu-latest
|
|
178
|
+
steps:
|
|
179
|
+
- uses: actions/checkout@v4
|
|
180
|
+
|
|
181
|
+
- uses: actions/setup-node@v4
|
|
182
|
+
with:
|
|
183
|
+
node-version: '20'
|
|
184
|
+
|
|
185
|
+
- name: Install dependencies
|
|
186
|
+
run: npm ci
|
|
187
|
+
|
|
188
|
+
- name: Deploy to production
|
|
189
|
+
env:
|
|
190
|
+
STACKTAPE_API_KEY: ${{ secrets.STACKTAPE_API_KEY }}
|
|
191
|
+
run: |
|
|
192
|
+
npm install -g stacktape
|
|
193
|
+
stacktape deploy --stage production --region us-east-1 --autoConfirmOperation
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### GitLab CI
|
|
197
|
+
|
|
198
|
+
```yaml
|
|
199
|
+
# .gitlab-ci.yml
|
|
200
|
+
deploy:
|
|
201
|
+
image: node:20
|
|
202
|
+
stage: deploy
|
|
203
|
+
only:
|
|
204
|
+
- main
|
|
205
|
+
script:
|
|
206
|
+
- npm ci
|
|
207
|
+
- npm install -g stacktape
|
|
208
|
+
- stacktape deploy --stage production --region us-east-1 --autoConfirmOperation
|
|
209
|
+
variables:
|
|
210
|
+
STACKTAPE_API_KEY: $STACKTAPE_API_KEY
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Environment Variables for CI/CD
|
|
214
|
+
|
|
215
|
+
| Variable | Description |
|
|
216
|
+
| ----------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
217
|
+
| `STACKTAPE_API_KEY` | Your Stacktape API key (get from [console.stacktape.com/api-keys](https://console.stacktape.com/api-keys)) |
|
|
218
|
+
| `AWS_ACCESS_KEY_ID` | AWS credentials (alternative to connected account) |
|
|
219
|
+
| `AWS_SECRET_ACCESS_KEY` | AWS credentials (alternative to connected account) |
|
|
220
|
+
|
|
221
|
+
## GitOps (Console-based)
|
|
222
|
+
|
|
223
|
+
Connect your repository to the Stacktape Console for automated deployments:
|
|
224
|
+
|
|
225
|
+
1. Go to [console.stacktape.com](https://console.stacktape.com)
|
|
226
|
+
2. Create a new project
|
|
227
|
+
3. Connect your GitHub/GitLab/Bitbucket repository
|
|
228
|
+
4. Configure branch-to-stage mapping:
|
|
229
|
+
- `main` → `production`
|
|
230
|
+
- `develop` → `staging`
|
|
231
|
+
- Pull requests → `preview-{pr-number}`
|
|
232
|
+
|
|
233
|
+
**Features:**
|
|
234
|
+
|
|
235
|
+
- Automatic deployment on push
|
|
236
|
+
- Preview environments for pull requests
|
|
237
|
+
- Deployment history and logs
|
|
238
|
+
- One-click rollback
|
|
239
|
+
- Slack/Discord notifications
|
|
240
|
+
|
|
241
|
+
## Managing Deployments
|
|
242
|
+
|
|
243
|
+
### View Stack Information
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
stacktape stack:info --stage dev --region us-east-1
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Output:
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
Stack: my-api-dev
|
|
253
|
+
Status: DEPLOYED
|
|
254
|
+
Region: us-east-1
|
|
255
|
+
|
|
256
|
+
Resources:
|
|
257
|
+
handler (function)
|
|
258
|
+
URL: https://abc123.execute-api.us-east-1.amazonaws.com
|
|
259
|
+
ARN: arn:aws:lambda:us-east-1:123456789:function:my-api-dev-handler
|
|
260
|
+
|
|
261
|
+
database (relational-database)
|
|
262
|
+
Host: my-api-dev-db.xxx.us-east-1.rds.amazonaws.com
|
|
263
|
+
Port: 5432
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### List All Stacks
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
stacktape stack:list --region us-east-1
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Preview Changes
|
|
273
|
+
|
|
274
|
+
See what will change before deploying:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
stacktape preview-changes --stage dev --region us-east-1
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Output:
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
Changes to be applied:
|
|
284
|
+
|
|
285
|
+
+ CREATE: newFunction (Lambda Function)
|
|
286
|
+
~ UPDATE: handler (Lambda Function)
|
|
287
|
+
- memory: 256 → 512
|
|
288
|
+
- timeout: 10 → 30
|
|
289
|
+
- DELETE: oldFunction (Lambda Function)
|
|
290
|
+
|
|
291
|
+
Resources unchanged: 3
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Delete Stack
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
stacktape delete --stage dev --region us-east-1
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Rollback
|
|
301
|
+
|
|
302
|
+
If a deployment fails with auto-rollback disabled:
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
stacktape rollback --stage dev --region us-east-1
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
If a specific resource is blocking rollback:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
stacktape rollback --stage dev --region us-east-1 --resourcesToSkip BrokenResource
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
## Setting Defaults
|
|
315
|
+
|
|
316
|
+
Configure defaults to avoid typing stage/region every time:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
stacktape defaults:configure
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Prompts:
|
|
323
|
+
|
|
324
|
+
```
|
|
325
|
+
? Default stage: dev
|
|
326
|
+
? Default region: us-east-1
|
|
327
|
+
? Default AWS profile: default
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Now you can just run:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
stacktape deploy
|
|
334
|
+
stacktape dev
|
|
335
|
+
stacktape logs --resourceName handler
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
View current defaults:
|
|
339
|
+
|
|
340
|
+
```bash
|
|
341
|
+
stacktape defaults:list
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Deployment Best Practices
|
|
345
|
+
|
|
346
|
+
### 1. Use Stages for Environments
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
# Development - fast iteration, hot-swap OK
|
|
350
|
+
stacktape deploy --stage dev --region us-east-1 --hotSwap
|
|
351
|
+
|
|
352
|
+
# Staging - test production config
|
|
353
|
+
stacktape deploy --stage staging --region us-east-1
|
|
354
|
+
|
|
355
|
+
# Production - full deployment, no shortcuts
|
|
356
|
+
stacktape deploy --stage production --region us-east-1
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### 2. Protect Production
|
|
360
|
+
|
|
361
|
+
Add confirmation for production deployments in CI:
|
|
362
|
+
|
|
363
|
+
```yaml
|
|
364
|
+
- name: Deploy to production
|
|
365
|
+
if: github.ref == 'refs/heads/main'
|
|
366
|
+
run: |
|
|
367
|
+
echo "Deploying to PRODUCTION"
|
|
368
|
+
stacktape deploy --stage production --region us-east-1 --autoConfirmOperation
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### 3. Run Migrations in Hooks
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
export default defineConfig(() => ({
|
|
375
|
+
hooks: {
|
|
376
|
+
afterDeploy: [{ scriptName: 'migrate' }]
|
|
377
|
+
},
|
|
378
|
+
scripts: {
|
|
379
|
+
migrate: {
|
|
380
|
+
executeCommand: 'npx prisma migrate deploy',
|
|
381
|
+
environment: {
|
|
382
|
+
DATABASE_URL: $ResourceParam('database', 'connectionString')
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
},
|
|
386
|
+
resources: {
|
|
387
|
+
/* ... */
|
|
388
|
+
}
|
|
389
|
+
}));
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### 4. Use Preview Environments
|
|
393
|
+
|
|
394
|
+
For pull request previews, use dynamic stage names:
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
# In CI, use PR number as stage
|
|
398
|
+
stacktape deploy --stage "preview-${PR_NUMBER}" --region us-east-1
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
Clean up when PR is closed:
|
|
402
|
+
|
|
403
|
+
```bash
|
|
404
|
+
stacktape delete --stage "preview-${PR_NUMBER}" --region us-east-1
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Troubleshooting
|
|
408
|
+
|
|
409
|
+
### "Stack is in ROLLBACK_COMPLETE state"
|
|
410
|
+
|
|
411
|
+
The stack failed to create and rolled back. Delete it and try again:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
stacktape delete --stage dev --region us-east-1
|
|
415
|
+
stacktape deploy --stage dev --region us-east-1
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### "Resource limit exceeded"
|
|
419
|
+
|
|
420
|
+
You've hit AWS service limits. Request a limit increase in AWS Console under Service Quotas.
|
|
421
|
+
|
|
422
|
+
### "Deployment is taking too long"
|
|
423
|
+
|
|
424
|
+
- Check if you're deploying a large Docker image (use `--logLevel debug`)
|
|
425
|
+
- Consider using `codebuild:deploy` for better build performance
|
|
426
|
+
- Ensure your config doesn't create unnecessary resources
|
|
427
|
+
|
|
428
|
+
### "No changes to deploy"
|
|
429
|
+
|
|
430
|
+
Your configuration matches what's already deployed. If you expected changes, check:
|
|
431
|
+
|
|
432
|
+
- You're deploying the correct stage
|
|
433
|
+
- Your config file was saved
|
|
434
|
+
- The changes are in a Stacktape-managed resource (not `cloudformationResources`)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: getting-started
|
|
3
|
+
title: Dev Mode
|
|
4
|
+
tags:
|
|
5
|
+
- dev
|
|
6
|
+
- mode
|
|
7
|
+
- getting-started
|
|
8
|
+
source: docs/_curated-docs/getting-started/dev-mode.mdx
|
|
9
|
+
priority: 2
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Dev Mode
|
|
13
|
+
|
|
14
|
+
Dev mode runs your workloads locally while connecting to (or emulating) cloud resources. Change code, see results immediately - no redeploy needed.
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
stacktape dev --stage dev --region us-east-1
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## How it works
|
|
21
|
+
|
|
22
|
+
Dev mode creates a minimal "dev stack" in AWS (IAM roles, secrets, API gateways) and runs everything else locally:
|
|
23
|
+
|
|
24
|
+
- **Lambda functions** - Deployed to AWS, but with logs streamed to your terminal
|
|
25
|
+
- **Containers** (web-service, worker-service) - Run as Docker containers on your machine
|
|
26
|
+
- **Databases** - Emulated locally with Docker (PostgreSQL, MySQL, Redis, DynamoDB, OpenSearch)
|
|
27
|
+
- **Static sites** (hosting-bucket, Next.js) - Served from a local dev server
|
|
28
|
+
|
|
29
|
+
Your Lambda functions can still reach your locally-emulated databases through automatic tunneling.
|
|
30
|
+
|
|
31
|
+
## Starting dev mode
|
|
32
|
+
|
|
33
|
+
**Run all workloads:**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
stacktape dev --stage dev --region us-east-1 --resources all
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Run specific workloads:**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
stacktape dev --stage dev --region us-east-1 --resources myApi,myWorker
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Watch for changes and auto-rebuild:**
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
stacktape dev --stage dev --region us-east-1 --resources all --watch
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Local database emulation
|
|
52
|
+
|
|
53
|
+
Dev mode automatically spins up Docker containers for your databases:
|
|
54
|
+
|
|
55
|
+
| Resource Type | Local Emulator |
|
|
56
|
+
| ---------------------------- | --------------------------------- |
|
|
57
|
+
| PostgreSQL/Aurora PostgreSQL | `postgres:latest` |
|
|
58
|
+
| MySQL/Aurora MySQL | `mysql:latest` / `mariadb:latest` |
|
|
59
|
+
| Redis | `redis:latest` |
|
|
60
|
+
| DynamoDB | `amazon/dynamodb-local` |
|
|
61
|
+
| OpenSearch | `opensearchproject/opensearch` |
|
|
62
|
+
|
|
63
|
+
Database data persists between runs in `.stacktape/dev-data/{stage}/`.
|
|
64
|
+
|
|
65
|
+
**Start fresh:**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
stacktape dev --stage dev --region us-east-1 --freshDb
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Use deployed (remote) database instead:**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
stacktape dev --stage dev --region us-east-1 --remoteResources myDatabase
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Environment variables
|
|
78
|
+
|
|
79
|
+
Local workloads receive the same `STP_*` environment variables as deployed resources, pointing to local endpoints:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
STP_MY_DB_CONNECTION_STRING=postgres://postgres:postgres@localhost:5432/postgres
|
|
83
|
+
STP_MY_DB_HOST=localhost
|
|
84
|
+
STP_MY_DB_PORT=5432
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Manual rebuilds
|
|
88
|
+
|
|
89
|
+
When running without `--watch`, trigger rebuilds manually:
|
|
90
|
+
|
|
91
|
+
- Type `rs` + Enter in the terminal to rebuild
|
|
92
|
+
- Or call the HTTP API (see [Using with AI](/getting-started/using-with-ai))
|
|
93
|
+
|
|
94
|
+
## Command options
|
|
95
|
+
|
|
96
|
+
| Flag | Description |
|
|
97
|
+
| ------------------- | ------------------------------------------------------ |
|
|
98
|
+
| `--resources` | Resources to run (`all` or comma-separated names) |
|
|
99
|
+
| `--skipResources` | Resources to exclude |
|
|
100
|
+
| `--watch` | Auto-rebuild on file changes |
|
|
101
|
+
| `--remoteResources` | Resources to connect to AWS instead of local emulation |
|
|
102
|
+
| `--freshDb` | Delete existing local database data |
|
|
103
|
+
| `--noTunnel` | Disable Lambda-to-local tunneling |
|
|
104
|
+
|
|
105
|
+
## Legacy mode
|
|
106
|
+
|
|
107
|
+
If you need to connect to an already-deployed stack (no local emulation):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
stacktape dev --stage dev --region us-east-1 --devMode legacy
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Legacy mode requires an existing deployment and connects directly to deployed AWS resources.
|
|
114
|
+
|
|
115
|
+
## Next steps
|
|
116
|
+
|
|
117
|
+
- [Using with AI](/getting-started/using-with-ai) - Programmatic control via HTTP API
|
|
118
|
+
- [Console](/getting-started/console) - Web-based deployment and monitoring
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: getting-started
|
|
3
|
+
title: How It Works
|
|
4
|
+
tags:
|
|
5
|
+
- how
|
|
6
|
+
- works
|
|
7
|
+
- getting-started
|
|
8
|
+
source: docs/_curated-docs/getting-started/how-it-works.mdx
|
|
9
|
+
priority: 2
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# How It Works
|
|
13
|
+
|
|
14
|
+
Stacktape transforms your configuration into production-grade AWS infrastructure via CloudFormation.
|
|
15
|
+
|
|
16
|
+
## The Deployment Flow
|
|
17
|
+
|
|
18
|
+
## Stacks and Stages
|
|
19
|
+
|
|
20
|
+
**Stack** = A complete deployment unit containing all your resources.
|
|
21
|
+
|
|
22
|
+
**Stage** = An environment identifier (`dev`, `staging`, `production`).
|
|
23
|
+
|
|
24
|
+
Each stage creates a completely separate stack:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
stacktape deploy --stage dev --region us-east-1 # Creates: my-app-dev
|
|
28
|
+
stacktape deploy --stage prod --region us-east-1 # Creates: my-app-prod
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Both stacks are fully isolated—separate databases, functions, everything.
|
|
32
|
+
|
|
33
|
+
## The `connectTo` System
|
|
34
|
+
|
|
35
|
+
When you connect resources:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
resources:
|
|
39
|
+
database:
|
|
40
|
+
type: relational-database
|
|
41
|
+
|
|
42
|
+
api:
|
|
43
|
+
type: function
|
|
44
|
+
properties:
|
|
45
|
+
connectTo:
|
|
46
|
+
- database
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Stacktape automatically:
|
|
50
|
+
|
|
51
|
+
1. **Creates IAM permissions** - Function can access database
|
|
52
|
+
2. **Injects environment variables** - `STP_DATABASE_CONNECTION_STRING`, `STP_DATABASE_HOST`, etc.
|
|
53
|
+
3. **Configures networking** - Security group rules, VPC placement
|
|
54
|
+
|
|
55
|
+
This replaces dozens of lines of manual IAM policies and networking config.
|
|
56
|
+
|
|
57
|
+
## Generated Environment Variables
|
|
58
|
+
|
|
59
|
+
| Resource Type | Variables Injected |
|
|
60
|
+
| --------------------- | ---------------------------------------------------- |
|
|
61
|
+
| `relational-database` | `STP_{NAME}_CONNECTION_STRING`, `HOST`, `PORT`, etc. |
|
|
62
|
+
| `dynamo-db-table` | `STP_{NAME}_TABLE_NAME`, `TABLE_ARN` |
|
|
63
|
+
| `bucket` | `STP_{NAME}_BUCKET_NAME`, `BUCKET_ARN` |
|
|
64
|
+
| `redis-cluster` | `STP_{NAME}_HOST`, `PORT` |
|
|
65
|
+
| `sqs-queue` | `STP_{NAME}_QUEUE_URL`, `QUEUE_ARN` |
|
|
66
|
+
|
|
67
|
+
## What Gets Created in AWS
|
|
68
|
+
|
|
69
|
+
Every stack includes baseline resources:
|
|
70
|
+
|
|
71
|
+
| Resource | Purpose |
|
|
72
|
+
| --------------------- | ----------------------------------------- |
|
|
73
|
+
| CloudFormation Stack | Manages all resources as a unit |
|
|
74
|
+
| S3 Bucket | Stores deployment artifacts |
|
|
75
|
+
| IAM Roles | Permissions for each resource |
|
|
76
|
+
| CloudWatch Log Groups | Centralized logging |
|
|
77
|
+
| VPC (if needed) | Private networking for databases/services |
|
|
78
|
+
|
|
79
|
+
Plus your defined resources (functions, databases, etc.).
|
|
80
|
+
|
|
81
|
+
## Extend and Override
|
|
82
|
+
|
|
83
|
+
Need more control? Override any CloudFormation property:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
const myFunction = new LambdaFunction({
|
|
87
|
+
// ... config
|
|
88
|
+
overrides: {
|
|
89
|
+
lambda: { Description: 'Custom description' }
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Or add raw CloudFormation:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
export default defineConfig(() => ({
|
|
98
|
+
resources: {
|
|
99
|
+
/* ... */
|
|
100
|
+
},
|
|
101
|
+
cloudformationResources: {
|
|
102
|
+
myResource: {
|
|
103
|
+
Type: 'AWS::SNS::Topic',
|
|
104
|
+
Properties: { TopicName: 'my-topic' }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Comparison
|
|
111
|
+
|
|
112
|
+
| Feature | Stacktape | CloudFormation | Terraform |
|
|
113
|
+
| ------------------ | --------- | -------------- | --------- |
|
|
114
|
+
| Lines of config | ~30 | ~1,200 | ~500 |
|
|
115
|
+
| Learning curve | Low | High | Medium |
|
|
116
|
+
| Type safety | Yes (TS) | No | Limited |
|
|
117
|
+
| Development mode | Yes | No | No |
|
|
118
|
+
| Built-in packaging | Yes | No | No |
|
|
119
|
+
| AWS-native | Yes | Yes | No |
|