stacktape 3.5.7 → 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 +206 -41
- package/package.json +1 -1
- package/plain.d.ts +309 -54
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: config-ref
|
|
3
|
+
title: Lambda Function
|
|
4
|
+
resourceType: function
|
|
5
|
+
tags:
|
|
6
|
+
- function
|
|
7
|
+
- lambda
|
|
8
|
+
- serverless
|
|
9
|
+
- faas
|
|
10
|
+
source: types/stacktape-config/functions.d.ts
|
|
11
|
+
priority: 1
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Lambda Function
|
|
15
|
+
|
|
16
|
+
A serverless compute resource that runs your code in response to events.
|
|
17
|
+
|
|
18
|
+
Lambda functions are short-lived, stateless, and scale automatically. You only pay for the compute time you consume.
|
|
19
|
+
|
|
20
|
+
Resource type: `function`
|
|
21
|
+
|
|
22
|
+
## TypeScript Definition
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
/**
|
|
26
|
+
* #### A serverless compute resource that runs your code in response to events.
|
|
27
|
+
*
|
|
28
|
+
* ---
|
|
29
|
+
*
|
|
30
|
+
* Lambda functions are short-lived, stateless, and scale automatically. You only pay for the compute time you consume.
|
|
31
|
+
*/
|
|
32
|
+
interface LambdaFunction {
|
|
33
|
+
type: 'function';
|
|
34
|
+
properties: LambdaFunctionProps;
|
|
35
|
+
overrides?: ResourceOverrides;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface LambdaFunctionProps extends ResourceAccessProps {
|
|
39
|
+
/**
|
|
40
|
+
* #### How your code is built and packaged for deployment.
|
|
41
|
+
*
|
|
42
|
+
* ---
|
|
43
|
+
*
|
|
44
|
+
* - **`stacktape-lambda-buildpack`** (recommended): Point to your source file and Stacktape builds,
|
|
45
|
+
* bundles, and uploads it automatically.
|
|
46
|
+
* - **`custom-artifact`**: Provide a pre-built zip file. Stacktape handles the upload.
|
|
47
|
+
*/
|
|
48
|
+
packaging: LambdaPackaging;
|
|
49
|
+
/**
|
|
50
|
+
* #### What triggers this function: HTTP requests, file uploads, queues, schedules, etc.
|
|
51
|
+
*
|
|
52
|
+
* ---
|
|
53
|
+
*
|
|
54
|
+
* Stacktape auto-configures permissions for each trigger.
|
|
55
|
+
* The event payload your function receives depends on the trigger type.
|
|
56
|
+
*/
|
|
57
|
+
events?: (
|
|
58
|
+
| HttpApiIntegration
|
|
59
|
+
| S3Integration
|
|
60
|
+
| ScheduleIntegration
|
|
61
|
+
| SnsIntegration
|
|
62
|
+
| SqsIntegration
|
|
63
|
+
| KinesisIntegration
|
|
64
|
+
| DynamoDbIntegration
|
|
65
|
+
| CloudwatchLogIntegration
|
|
66
|
+
| ApplicationLoadBalancerIntegration
|
|
67
|
+
| EventBusIntegration
|
|
68
|
+
| KafkaTopicIntegration
|
|
69
|
+
| AlarmIntegration
|
|
70
|
+
)[];
|
|
71
|
+
/**
|
|
72
|
+
* #### Environment variables available to the function at runtime.
|
|
73
|
+
*
|
|
74
|
+
* ---
|
|
75
|
+
*
|
|
76
|
+
* Variables from `connectTo` (e.g., `STP_MY_DATABASE_CONNECTION_STRING`) are added automatically.
|
|
77
|
+
*/
|
|
78
|
+
environment?: EnvironmentVar[];
|
|
79
|
+
/**
|
|
80
|
+
* #### The language runtime (e.g., `nodejs22.x`, `python3.13`).
|
|
81
|
+
*
|
|
82
|
+
* ---
|
|
83
|
+
*
|
|
84
|
+
* Auto-detected from your source file extension when using `stacktape-lambda-buildpack`.
|
|
85
|
+
* Override only if you need a specific version.
|
|
86
|
+
*/
|
|
87
|
+
runtime?: LambdaRuntime;
|
|
88
|
+
/**
|
|
89
|
+
* #### Processor architecture: `x86_64` (default) or `arm64` (Graviton, ~20% cheaper).
|
|
90
|
+
*
|
|
91
|
+
* ---
|
|
92
|
+
*
|
|
93
|
+
* `arm64` is cheaper per GB-second and often faster. Works with most code out of the box.
|
|
94
|
+
* If using `stacktape-lambda-buildpack`, Stacktape builds for the selected architecture automatically.
|
|
95
|
+
* With `custom-artifact`, you must pre-compile for the target architecture.
|
|
96
|
+
*
|
|
97
|
+
* @default "x86_64"
|
|
98
|
+
*/
|
|
99
|
+
architecture?: 'x86_64' | 'arm64';
|
|
100
|
+
/**
|
|
101
|
+
* #### Memory in MB (128 - 10,240). Also determines CPU power.
|
|
102
|
+
*
|
|
103
|
+
* ---
|
|
104
|
+
*
|
|
105
|
+
* Lambda scales CPU proportionally to memory: 1,769 MB = 1 vCPU, 3,538 MB = 2 vCPUs, etc.
|
|
106
|
+
* If your function is slow, increasing memory gives it more CPU, which often makes it faster
|
|
107
|
+
* and cheaper overall (less execution time).
|
|
108
|
+
*/
|
|
109
|
+
memory?: number;
|
|
110
|
+
/**
|
|
111
|
+
* #### Max execution time in seconds. Function is killed if it exceeds this.
|
|
112
|
+
*
|
|
113
|
+
* ---
|
|
114
|
+
*
|
|
115
|
+
* Maximum: 900 seconds (15 minutes). For longer tasks, use a `batch-job` or `worker-service`.
|
|
116
|
+
*
|
|
117
|
+
* @default 10
|
|
118
|
+
*/
|
|
119
|
+
timeout?: number;
|
|
120
|
+
/**
|
|
121
|
+
* #### Connects the function to your VPC so it can reach databases, Redis, and other VPC-only resources.
|
|
122
|
+
*
|
|
123
|
+
* ---
|
|
124
|
+
*
|
|
125
|
+
* **You usually don't need to set this manually.** Stacktape will tell you if a resource in your `connectTo`
|
|
126
|
+
* requires it (e.g., a database with `accessibilityMode: 'vpc'`, or any Redis cluster).
|
|
127
|
+
*
|
|
128
|
+
* **Tradeoff:** The function loses direct internet access. It can still reach S3 and DynamoDB
|
|
129
|
+
* (Stacktape auto-creates VPC endpoints), but calls to external APIs (Stripe, OpenAI, etc.) will fail.
|
|
130
|
+
* If you need both VPC access and internet, use a `web-service` or `worker-service` instead.
|
|
131
|
+
*
|
|
132
|
+
* Required when using `volumeMounts` (EFS).
|
|
133
|
+
*
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
joinDefaultVpc?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* #### Additional tags for this function (on top of stack-level tags). Max 50.
|
|
139
|
+
*/
|
|
140
|
+
tags?: CloudformationTag[];
|
|
141
|
+
/**
|
|
142
|
+
* #### Route async invocation results to another service (SQS, SNS, EventBus, or another function).
|
|
143
|
+
*
|
|
144
|
+
* ---
|
|
145
|
+
*
|
|
146
|
+
* Useful for building event-driven workflows: send successful results to one destination
|
|
147
|
+
* and failures to another for error handling.
|
|
148
|
+
*/
|
|
149
|
+
destinations?: LambdaFunctionDestinations;
|
|
150
|
+
/**
|
|
151
|
+
* #### Logging configuration (retention, forwarding).
|
|
152
|
+
*
|
|
153
|
+
* ---
|
|
154
|
+
*
|
|
155
|
+
* Logs (`stdout`/`stderr`) are auto-sent to CloudWatch. View with `stacktape logs` or in the Stacktape Console.
|
|
156
|
+
*/
|
|
157
|
+
logging?: LambdaFunctionLogging;
|
|
158
|
+
/**
|
|
159
|
+
* #### Eliminates cold starts by keeping function instances warm and ready.
|
|
160
|
+
*
|
|
161
|
+
* ---
|
|
162
|
+
*
|
|
163
|
+
* When a function hasn't been called recently, the first request can take 1-5+ seconds ("cold start").
|
|
164
|
+
* This setting pre-warms the specified number of instances so they respond instantly.
|
|
165
|
+
*
|
|
166
|
+
* **When to use:** User-facing APIs, web/mobile backends, or any function where response time matters.
|
|
167
|
+
* Skip this for background jobs, cron tasks, or data pipelines.
|
|
168
|
+
*
|
|
169
|
+
* **Cost:** You pay for each provisioned instance even when idle. Also increases deploy time by ~2-5 minutes.
|
|
170
|
+
*/
|
|
171
|
+
provisionedConcurrency?: number;
|
|
172
|
+
/**
|
|
173
|
+
* #### Cap the maximum number of concurrent instances for this function.
|
|
174
|
+
*
|
|
175
|
+
* ---
|
|
176
|
+
*
|
|
177
|
+
* Reserves this many execution slots exclusively for this function — other functions can't use them,
|
|
178
|
+
* and this function can't scale beyond it. **No additional cost.**
|
|
179
|
+
*
|
|
180
|
+
* Common uses:
|
|
181
|
+
* - Prevent overwhelming a database with too many connections
|
|
182
|
+
* - Guarantee capacity for critical functions
|
|
183
|
+
* - Throttle expensive downstream API calls
|
|
184
|
+
*/
|
|
185
|
+
reservedConcurrency?: number;
|
|
186
|
+
/**
|
|
187
|
+
* #### Lambda Layer ARNs to attach (shared libraries, custom runtimes, etc.).
|
|
188
|
+
*
|
|
189
|
+
* ---
|
|
190
|
+
*
|
|
191
|
+
* Layers are zip archives with additional code/data mounted into the function.
|
|
192
|
+
* Provide the layer ARN (e.g., from AWS console or another stack). Max 5 layers per function.
|
|
193
|
+
*/
|
|
194
|
+
layers?: string[];
|
|
195
|
+
/**
|
|
196
|
+
* #### Gradual traffic shifting for safe deployments.
|
|
197
|
+
*
|
|
198
|
+
* ---
|
|
199
|
+
*
|
|
200
|
+
* Instead of switching all traffic to the new version instantly, shift it gradually
|
|
201
|
+
* (canary or linear). If issues arise, traffic rolls back automatically.
|
|
202
|
+
*/
|
|
203
|
+
deployment?: LambdaDeploymentConfig;
|
|
204
|
+
/**
|
|
205
|
+
* #### Alarms for this function (merged with global alarms from the Stacktape Console).
|
|
206
|
+
*/
|
|
207
|
+
alarms?: LambdaAlarm[];
|
|
208
|
+
/**
|
|
209
|
+
* #### Global alarm names to exclude from this function.
|
|
210
|
+
*/
|
|
211
|
+
disabledGlobalAlarms?: string[];
|
|
212
|
+
/**
|
|
213
|
+
* #### Give this function its own HTTPS URL (no API Gateway needed).
|
|
214
|
+
*
|
|
215
|
+
* ---
|
|
216
|
+
*
|
|
217
|
+
* Simpler and cheaper than an API Gateway for single-function endpoints.
|
|
218
|
+
* URL format: `https://{id}.lambda-url.{region}.on.aws`
|
|
219
|
+
*/
|
|
220
|
+
url?: LambdaUrlConfig;
|
|
221
|
+
/**
|
|
222
|
+
* #### Put a CDN (CloudFront) in front of this function for caching and lower latency.
|
|
223
|
+
*
|
|
224
|
+
* ---
|
|
225
|
+
*
|
|
226
|
+
* Caches responses at edge locations worldwide. Reduces function invocations and bandwidth costs.
|
|
227
|
+
*/
|
|
228
|
+
cdn?: CdnConfiguration;
|
|
229
|
+
/**
|
|
230
|
+
* #### Size of the `/tmp` directory in MB (512 - 10,240). Ephemeral per invocation.
|
|
231
|
+
*
|
|
232
|
+
* ---
|
|
233
|
+
*
|
|
234
|
+
* Increase if your function downloads/processes large files temporarily.
|
|
235
|
+
*
|
|
236
|
+
* @default 512
|
|
237
|
+
*/
|
|
238
|
+
storage?: number;
|
|
239
|
+
/**
|
|
240
|
+
* #### Persistent EFS storage shared across invocations and functions.
|
|
241
|
+
*
|
|
242
|
+
* ---
|
|
243
|
+
*
|
|
244
|
+
* Unlike `/tmp`, EFS data persists indefinitely and can be shared across multiple functions.
|
|
245
|
+
* Requires `joinDefaultVpc: true` (Stacktape will remind you if you forget).
|
|
246
|
+
*/
|
|
247
|
+
volumeMounts?: LambdaEfsMount[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
interface LambdaUrlConfig {
|
|
251
|
+
/**
|
|
252
|
+
* #### Enable the function URL.
|
|
253
|
+
*/
|
|
254
|
+
enabled: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* #### CORS settings for the function URL. Overrides any CORS headers from the function itself.
|
|
257
|
+
*/
|
|
258
|
+
cors?: LambdaUrlCorsConfig;
|
|
259
|
+
/**
|
|
260
|
+
* #### Who can call this URL.
|
|
261
|
+
*
|
|
262
|
+
* ---
|
|
263
|
+
*
|
|
264
|
+
* - `NONE` — public, anyone can call it.
|
|
265
|
+
* - `AWS_IAM` — only authenticated AWS users/roles with invoke permission.
|
|
266
|
+
*
|
|
267
|
+
* @default NONE
|
|
268
|
+
*/
|
|
269
|
+
authMode?: 'AWS_IAM' | 'NONE';
|
|
270
|
+
/**
|
|
271
|
+
* #### Stream the response progressively instead of buffering the entire response.
|
|
272
|
+
*
|
|
273
|
+
* ---
|
|
274
|
+
*
|
|
275
|
+
* Improves Time to First Byte and increases max response size from 6 MB to 20 MB.
|
|
276
|
+
* Requires using the AWS streaming handler pattern in your code.
|
|
277
|
+
*/
|
|
278
|
+
responseStreamEnabled?: boolean;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
interface LambdaUrlCorsConfig {
|
|
282
|
+
/**
|
|
283
|
+
* #### Enable CORS. When `true` with no other settings, uses permissive defaults (`*` for origins and methods).
|
|
284
|
+
*/
|
|
285
|
+
enabled: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* #### Allowed origins (e.g., `https://example.com`). Use `*` for any origin.
|
|
288
|
+
*
|
|
289
|
+
* @default ["*"]
|
|
290
|
+
*/
|
|
291
|
+
allowedOrigins?: string[];
|
|
292
|
+
/**
|
|
293
|
+
* #### Allowed request headers (e.g., `Content-Type`, `Authorization`).
|
|
294
|
+
*/
|
|
295
|
+
allowedHeaders?: string[];
|
|
296
|
+
/**
|
|
297
|
+
* #### Allowed HTTP methods (e.g., `GET`, `POST`).
|
|
298
|
+
*/
|
|
299
|
+
allowedMethods?: HttpMethod[];
|
|
300
|
+
/**
|
|
301
|
+
* #### Allow cookies and credentials in cross-origin requests.
|
|
302
|
+
*/
|
|
303
|
+
allowCredentials?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* #### Response headers accessible to browser JavaScript.
|
|
306
|
+
*/
|
|
307
|
+
exposedResponseHeaders?: string[];
|
|
308
|
+
/**
|
|
309
|
+
* #### How long (seconds) browsers can cache preflight responses.
|
|
310
|
+
*/
|
|
311
|
+
maxAge?: number;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
interface LambdaDeploymentConfig {
|
|
315
|
+
/**
|
|
316
|
+
* #### How traffic shifts from the old version to the new one.
|
|
317
|
+
*
|
|
318
|
+
* ---
|
|
319
|
+
*
|
|
320
|
+
* - **Canary**: Send 10% of traffic first, then all traffic after a wait period.
|
|
321
|
+
* - **Linear**: Shift 10% of traffic at regular intervals.
|
|
322
|
+
* - **AllAtOnce**: Instant switch (no gradual rollout).
|
|
323
|
+
*/
|
|
324
|
+
strategy:
|
|
325
|
+
| 'Canary10Percent5Minutes'
|
|
326
|
+
| 'Canary10Percent10Minutes'
|
|
327
|
+
| 'Canary10Percent15Minutes'
|
|
328
|
+
| 'Canary10Percent30Minutes'
|
|
329
|
+
| 'Linear10PercentEvery1Minute'
|
|
330
|
+
| 'Linear10PercentEvery2Minutes'
|
|
331
|
+
| 'Linear10PercentEvery3Minutes'
|
|
332
|
+
| 'Linear10PercentEvery10Minutes'
|
|
333
|
+
| 'AllAtOnce';
|
|
334
|
+
/**
|
|
335
|
+
* #### Function to run before traffic shifting begins (e.g., smoke tests).
|
|
336
|
+
*
|
|
337
|
+
* ---
|
|
338
|
+
*
|
|
339
|
+
* Must signal success/failure to CodeDeploy. If it fails, the deployment rolls back.
|
|
340
|
+
*/
|
|
341
|
+
beforeAllowTrafficFunction?: string;
|
|
342
|
+
/**
|
|
343
|
+
* #### Function to run after all traffic has shifted (e.g., post-deploy validation).
|
|
344
|
+
*
|
|
345
|
+
* ---
|
|
346
|
+
*
|
|
347
|
+
* Must signal success/failure to CodeDeploy.
|
|
348
|
+
*/
|
|
349
|
+
afterTrafficShiftFunction?: string;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
interface LambdaFunctionDestinations {
|
|
353
|
+
/**
|
|
354
|
+
* #### ARN to receive the result when the function succeeds (SQS, SNS, EventBus, or Lambda ARN).
|
|
355
|
+
*/
|
|
356
|
+
onSuccess?: string;
|
|
357
|
+
/**
|
|
358
|
+
* #### ARN to receive error details when the function fails. Useful for dead-letter processing.
|
|
359
|
+
*/
|
|
360
|
+
onFailure?: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
interface LambdaFunctionLogging extends LogForwardingBase {
|
|
364
|
+
/**
|
|
365
|
+
* #### Disable CloudWatch logging entirely.
|
|
366
|
+
*
|
|
367
|
+
* @default false
|
|
368
|
+
*/
|
|
369
|
+
disabled?: boolean;
|
|
370
|
+
/**
|
|
371
|
+
* #### How many days to keep logs. Longer retention = higher storage cost.
|
|
372
|
+
*
|
|
373
|
+
* @default 180
|
|
374
|
+
*/
|
|
375
|
+
retentionDays?: 1 | 3 | 5 | 7 | 14 | 30 | 60 | 90 | 120 | 150 | 180 | 365 | 400 | 545 | 731 | 1827 | 3653;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
interface LambdaEfsMount {
|
|
379
|
+
/**
|
|
380
|
+
* #### The type of the volume mount.
|
|
381
|
+
*/
|
|
382
|
+
type: 'efs';
|
|
383
|
+
/**
|
|
384
|
+
* #### Properties for the EFS volume mount.
|
|
385
|
+
*/
|
|
386
|
+
properties: LambdaEfsMountProps;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
interface LambdaEfsMountProps {
|
|
390
|
+
/**
|
|
391
|
+
* #### Name of the `efs-filesystem` resource defined in your config.
|
|
392
|
+
*/
|
|
393
|
+
efsFilesystemName: string;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* #### Subdirectory within the EFS filesystem to mount. Omit for full access.
|
|
397
|
+
*
|
|
398
|
+
* @default "/"
|
|
399
|
+
*/
|
|
400
|
+
rootDirectory?: string;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* #### Path inside the function where the volume appears. Must start with `/mnt/` (e.g., `/mnt/data`).
|
|
404
|
+
*/
|
|
405
|
+
mountPath: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
type FunctionReferencableParam = 'arn' | 'logGroupArn';
|
|
409
|
+
```
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
docType: config-ref
|
|
3
|
+
title: Hosting Bucket
|
|
4
|
+
resourceType: hosting-bucket
|
|
5
|
+
tags:
|
|
6
|
+
- hosting-bucket
|
|
7
|
+
- static-site
|
|
8
|
+
- static-website
|
|
9
|
+
- spa
|
|
10
|
+
source: types/stacktape-config/hosting-buckets.d.ts
|
|
11
|
+
priority: 1
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Hosting Bucket
|
|
15
|
+
|
|
16
|
+
Host a static website (React, Vue, Astro, etc.) on S3 + CloudFront CDN.
|
|
17
|
+
|
|
18
|
+
Combines S3 storage with a global CDN for fast, cheap, and scalable static site hosting.
|
|
19
|
+
Includes build step, custom domains, caching presets, and environment injection.
|
|
20
|
+
|
|
21
|
+
Resource type: `hosting-bucket`
|
|
22
|
+
|
|
23
|
+
## TypeScript Definition
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
/**
|
|
27
|
+
* #### Host a static website (React, Vue, Astro, etc.) on S3 + CloudFront CDN.
|
|
28
|
+
*
|
|
29
|
+
* ---
|
|
30
|
+
*
|
|
31
|
+
* Combines S3 storage with a global CDN for fast, cheap, and scalable static site hosting.
|
|
32
|
+
* Includes build step, custom domains, caching presets, and environment injection.
|
|
33
|
+
*/
|
|
34
|
+
interface HostingBucket {
|
|
35
|
+
type: 'hosting-bucket';
|
|
36
|
+
properties: HostingBucketProps;
|
|
37
|
+
overrides?: ResourceOverrides;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface HostingBucketProps {
|
|
41
|
+
/**
|
|
42
|
+
* #### Path to the build output directory (e.g., `dist`, `build`, `out`).
|
|
43
|
+
*
|
|
44
|
+
* ---
|
|
45
|
+
*
|
|
46
|
+
* This folder's contents are uploaded to the bucket on every deploy.
|
|
47
|
+
*/
|
|
48
|
+
uploadDirectoryPath: string;
|
|
49
|
+
/**
|
|
50
|
+
* #### Build command that produces the files to upload (e.g., `npm run build`).
|
|
51
|
+
*
|
|
52
|
+
* ---
|
|
53
|
+
*
|
|
54
|
+
* Runs during the packaging phase, in parallel with other resources. Bundle size is shown in deploy logs.
|
|
55
|
+
*/
|
|
56
|
+
build?: HostingBucketBuild;
|
|
57
|
+
/**
|
|
58
|
+
* #### Dev server command for local development (e.g., `npm run dev`, `vite`).
|
|
59
|
+
*
|
|
60
|
+
* ---
|
|
61
|
+
*
|
|
62
|
+
* Used by `stacktape dev`.
|
|
63
|
+
*/
|
|
64
|
+
dev?: HostingBucketBuild;
|
|
65
|
+
/**
|
|
66
|
+
* #### Glob patterns for files to skip during upload (relative to `uploadDirectoryPath`).
|
|
67
|
+
*/
|
|
68
|
+
excludeFilesPatterns?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* #### Optimizes caching and routing for your type of frontend app.
|
|
71
|
+
*
|
|
72
|
+
* ---
|
|
73
|
+
*
|
|
74
|
+
* - **`single-page-app`**: For React, Vue, Angular, or any SPA built with Vite/Webpack.
|
|
75
|
+
* Enables client-side routing (e.g., `/about` serves `index.html`). HTML is never browser-cached;
|
|
76
|
+
* hashed assets (`.js`, `.css`) are cached forever.
|
|
77
|
+
*
|
|
78
|
+
* - **`static-website`** (default): For multi-page static sites. All files are CDN-cached
|
|
79
|
+
* but never browser-cached, so users always see the latest content after a deploy.
|
|
80
|
+
*
|
|
81
|
+
* - **`astro-static-website`** / **`sveltekit-static-website`** / **`nuxt-static-website`**:
|
|
82
|
+
* Framework-specific presets that cache hashed build assets (`_astro/`, `_app/`, `_nuxt/`)
|
|
83
|
+
* indefinitely while keeping HTML fresh.
|
|
84
|
+
*
|
|
85
|
+
* - **`gatsby-static-website`**: Gatsby-specific caching following their recommendations.
|
|
86
|
+
*
|
|
87
|
+
* You can override any preset's behavior using `fileOptions`.
|
|
88
|
+
*
|
|
89
|
+
* @default "static-website"
|
|
90
|
+
*/
|
|
91
|
+
hostingContentType?: SupportedHeaderPreset;
|
|
92
|
+
/**
|
|
93
|
+
* #### Custom domains (e.g., `www.example.com`). Stacktape auto-creates DNS records and TLS certificates.
|
|
94
|
+
*
|
|
95
|
+
* ---
|
|
96
|
+
*
|
|
97
|
+
* Your domain must be added as a Route53 hosted zone in your AWS account first.
|
|
98
|
+
*/
|
|
99
|
+
customDomains?: DomainConfiguration[];
|
|
100
|
+
/**
|
|
101
|
+
* #### Disable clean URL normalization (e.g., `/about` → `/about.html`).
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
disableUrlNormalization?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* #### Run edge functions on CDN requests/responses (URL rewrites, auth, A/B testing).
|
|
107
|
+
*
|
|
108
|
+
* ---
|
|
109
|
+
*
|
|
110
|
+
* - `onRequest`: Before cache lookup and before forwarding to the bucket.
|
|
111
|
+
* - `onResponse`: Before returning the response to the client.
|
|
112
|
+
*/
|
|
113
|
+
edgeFunctions?: EdgeFunctionsConfig;
|
|
114
|
+
/**
|
|
115
|
+
* #### Page to show for 404 errors (e.g., `/error.html`).
|
|
116
|
+
*/
|
|
117
|
+
errorDocument?: string;
|
|
118
|
+
/**
|
|
119
|
+
* #### Page served for requests to `/`.
|
|
120
|
+
* @default /index.html
|
|
121
|
+
*/
|
|
122
|
+
indexDocument?: string;
|
|
123
|
+
/**
|
|
124
|
+
* #### Inject deploy-time values into HTML files as `window.STP_INJECTED_ENV.VARIABLE_NAME`.
|
|
125
|
+
*
|
|
126
|
+
* ---
|
|
127
|
+
*
|
|
128
|
+
* Useful for making API URLs, User Pool IDs, and other dynamic values
|
|
129
|
+
* available to your frontend JavaScript without rebuilding.
|
|
130
|
+
*/
|
|
131
|
+
injectEnvironment?: EnvironmentVar[];
|
|
132
|
+
/**
|
|
133
|
+
* #### Write deploy-time values to a `.env` file in the specified directory.
|
|
134
|
+
*
|
|
135
|
+
* ---
|
|
136
|
+
*
|
|
137
|
+
* Merges with existing `.env` content if the file already exists.
|
|
138
|
+
*/
|
|
139
|
+
writeDotenvFilesTo?: string;
|
|
140
|
+
/**
|
|
141
|
+
* #### Name of a `web-app-firewall` resource to protect this site. Must have `scope: cdn`.
|
|
142
|
+
*/
|
|
143
|
+
useFirewall?: string;
|
|
144
|
+
/**
|
|
145
|
+
* #### Set HTTP headers (e.g., `Cache-Control`) for files matching specific patterns.
|
|
146
|
+
*/
|
|
147
|
+
fileOptions?: DirectoryUploadFilter[];
|
|
148
|
+
/**
|
|
149
|
+
* #### Route specific URL patterns to different origins (e.g., `/api/*` → a Lambda function).
|
|
150
|
+
*
|
|
151
|
+
* ---
|
|
152
|
+
*
|
|
153
|
+
* Evaluated in order; first match wins. Unmatched requests go to the bucket.
|
|
154
|
+
*/
|
|
155
|
+
routeRewrites?: CdnRouteRewrite[];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type WriteEnvFilesFormat = 'dotenv';
|
|
159
|
+
|
|
160
|
+
interface HostingBucketBuild {
|
|
161
|
+
/**
|
|
162
|
+
* #### Command to run (e.g., `npm run build`, `vite build`, `npm run dev`).
|
|
163
|
+
*/
|
|
164
|
+
command: string;
|
|
165
|
+
/**
|
|
166
|
+
* #### Working directory for the command (relative to project root).
|
|
167
|
+
* @default "."
|
|
168
|
+
*/
|
|
169
|
+
workingDirectory?: string;
|
|
170
|
+
}
|
|
171
|
+
```
|