sst 2.32.2 → 2.33.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/constructs/AstroSite.js +43 -26
- package/constructs/Auth.js +1 -0
- package/constructs/Function.d.ts +22 -0
- package/constructs/Script.d.ts +5 -7
- package/constructs/StaticSite.d.ts +1 -1
- package/constructs/future/Auth.js +1 -0
- package/package.json +3 -3
- package/runtime/handlers/python.js +14 -12
- package/runtime/handlers/pythonBundling.js +0 -4
- package/support/bridge/bridge.mjs +15 -15
package/constructs/AstroSite.js
CHANGED
|
@@ -67,6 +67,7 @@ export class AstroSite extends SsrSite {
|
|
|
67
67
|
plan() {
|
|
68
68
|
const { path: sitePath, edge, regional } = this.props;
|
|
69
69
|
const buildMeta = AstroSite.getBuildMeta(join(sitePath, "dist", BUILD_META_FILE_NAME));
|
|
70
|
+
const isStatic = buildMeta.outputMode === "static";
|
|
70
71
|
const serverConfig = {
|
|
71
72
|
description: "Server handler for Astro",
|
|
72
73
|
handler: join(sitePath, "dist", "server", "entry.handler"),
|
|
@@ -133,32 +134,41 @@ export class AstroSite extends SsrSite {
|
|
|
133
134
|
})));
|
|
134
135
|
}
|
|
135
136
|
else {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
137
|
+
if (isStatic) {
|
|
138
|
+
plan.behaviors.push({
|
|
139
|
+
cacheType: "static",
|
|
140
|
+
cfFunction: "serverCfFunction",
|
|
141
|
+
origin: "staticsServer",
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
plan.origins.regionalServer = {
|
|
146
|
+
type: "function",
|
|
147
|
+
constructId: "ServerFunction",
|
|
148
|
+
function: serverConfig,
|
|
149
|
+
streaming: buildMeta.responseMode === "stream",
|
|
150
|
+
};
|
|
151
|
+
plan.origins.fallthroughServer = {
|
|
152
|
+
type: "group",
|
|
153
|
+
primaryOriginName: "staticsServer",
|
|
154
|
+
fallbackOriginName: "regionalServer",
|
|
155
|
+
fallbackStatusCodes: [403, 404],
|
|
156
|
+
};
|
|
157
|
+
plan.behaviors.push({
|
|
158
|
+
cacheType: "server",
|
|
159
|
+
cfFunction: "serverCfFunction",
|
|
160
|
+
origin: "fallthroughServer",
|
|
161
|
+
allowedMethods: AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
|
|
162
|
+
}, {
|
|
163
|
+
cacheType: "static",
|
|
164
|
+
pattern: `${buildMeta.clientBuildVersionedSubDir}/*`,
|
|
165
|
+
origin: "staticsServer",
|
|
166
|
+
}, ...(buildMeta.serverRoutes ?? regional?.serverRoutes ?? []).map((route) => ({
|
|
167
|
+
cacheType: "server",
|
|
168
|
+
pattern: route,
|
|
169
|
+
origin: "regionalServer",
|
|
170
|
+
})));
|
|
171
|
+
}
|
|
162
172
|
buildMeta.routes
|
|
163
173
|
.filter(({ type, route }) => type === "page" && /^\/\d{3}\/?$/.test(route))
|
|
164
174
|
.forEach(({ route, prerender }) => {
|
|
@@ -170,6 +180,13 @@ export class AstroSite extends SsrSite {
|
|
|
170
180
|
responsePagePath: prerender ? "/404.html" : "/404",
|
|
171
181
|
responseHttpStatus: 404,
|
|
172
182
|
});
|
|
183
|
+
if (isStatic) {
|
|
184
|
+
plan.errorResponses?.push({
|
|
185
|
+
httpStatus: 403,
|
|
186
|
+
responsePagePath: "/404.html",
|
|
187
|
+
responseHttpStatus: 404,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
173
190
|
break;
|
|
174
191
|
case "/500":
|
|
175
192
|
case "/500/":
|
package/constructs/Auth.js
CHANGED
package/constructs/Function.d.ts
CHANGED
|
@@ -472,6 +472,28 @@ export interface PythonProps {
|
|
|
472
472
|
* ```
|
|
473
473
|
*/
|
|
474
474
|
installCommands?: string[];
|
|
475
|
+
/**
|
|
476
|
+
* This options skips the Python bundle step. If you set this flag to `true`, you must ensure
|
|
477
|
+
* that either:
|
|
478
|
+
*
|
|
479
|
+
* 1. Your Python build does not require dependencies.
|
|
480
|
+
* 2. Or, you've already installed production dependencies before running `sst deploy`.
|
|
481
|
+
*
|
|
482
|
+
* One solution to accomplish this is to pre-compile your production dependencies to some
|
|
483
|
+
* temporary directory, using pip's `--platform` argument to ensure Python pre-built wheels are
|
|
484
|
+
* used and that your builds match your target Lambda runtime, and use SST's `copyFiles`
|
|
485
|
+
* option to make sure these dependencies make it into your final deployment build.
|
|
486
|
+
*
|
|
487
|
+
* This can also help speed up Python Lambdas which do not have external dependencies. By
|
|
488
|
+
* default, SST will still run a docker file that is essentially a no-op if you have no
|
|
489
|
+
* dependencies. This option will bypass that step, even if you have a `Pipfile`, a `poetry.toml`,
|
|
490
|
+
* a `pyproject.toml`, or a `requirements.txt` (which would normally trigger an all-dependencies
|
|
491
|
+
* Docker build).
|
|
492
|
+
*
|
|
493
|
+
* Enabling this option implies that you have accounted for all of the above and are handling
|
|
494
|
+
* your own build processes, and you are doing this for the sake of build optimization.
|
|
495
|
+
*/
|
|
496
|
+
noDocker?: boolean;
|
|
475
497
|
}
|
|
476
498
|
/**
|
|
477
499
|
* Used to configure Go bundling options
|
package/constructs/Script.d.ts
CHANGED
|
@@ -20,14 +20,14 @@ export interface ScriptProps {
|
|
|
20
20
|
*/
|
|
21
21
|
params?: Record<string, any>;
|
|
22
22
|
/**
|
|
23
|
-
* By default, the
|
|
23
|
+
* By default, the `onUpdate` function runs during each deployment. If a version is provided, it will only run when the version changes.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
26
|
* ```js
|
|
27
27
|
* import { Script } from "sst/constructs";
|
|
28
28
|
*
|
|
29
29
|
* new Script(stack, "Script", {
|
|
30
|
-
*
|
|
30
|
+
* onUpdate: "src/function.handler",
|
|
31
31
|
* version: "v17",
|
|
32
32
|
* });
|
|
33
33
|
* ```
|
|
@@ -51,7 +51,7 @@ export interface ScriptProps {
|
|
|
51
51
|
function?: FunctionProps;
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
|
-
* Specifies the function to be run once when the Script construct is
|
|
54
|
+
* Specifies the function to be run once when the Script construct is added to the stack or when the entire stack is deployed for the first time.
|
|
55
55
|
* @example
|
|
56
56
|
* ```js
|
|
57
57
|
* new Script(stack, "Api", {
|
|
@@ -61,8 +61,7 @@ export interface ScriptProps {
|
|
|
61
61
|
*/
|
|
62
62
|
onCreate?: FunctionDefinition;
|
|
63
63
|
/**
|
|
64
|
-
* Specifies the function to be run each time the Script construct is redeployed. If a version is provided,
|
|
65
|
-
* the function is only executed when the version changes.
|
|
64
|
+
* Specifies the function to be run each time the Script construct is redeployed. If a version is provided, the function is only executed when the version changes.
|
|
66
65
|
*
|
|
67
66
|
* Note that the `onUpdate` function is not run during the initial creation of the Script construct.
|
|
68
67
|
* For initial creation, use `onCreate`.
|
|
@@ -75,8 +74,7 @@ export interface ScriptProps {
|
|
|
75
74
|
*/
|
|
76
75
|
onUpdate?: FunctionDefinition;
|
|
77
76
|
/**
|
|
78
|
-
* Specifies the function to be run once when the Script construct is deleted from the stack or
|
|
79
|
-
* when the entire stack is removed from the app.
|
|
77
|
+
* Specifies the function to be run once when the Script construct is deleted from the stack or when the entire stack is removed from the app.
|
|
80
78
|
* @example
|
|
81
79
|
* ```js
|
|
82
80
|
* new Script(stack, "Api", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sideEffects": false,
|
|
3
3
|
"name": "sst",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.33.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sst": "cli/sst.js"
|
|
7
7
|
},
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@trpc/server": "9.16.0",
|
|
57
57
|
"adm-zip": "^0.5.10",
|
|
58
58
|
"aws-cdk-lib": "2.101.1",
|
|
59
|
-
"aws-iot-device-sdk": "^2.2.
|
|
59
|
+
"aws-iot-device-sdk": "^2.2.13",
|
|
60
60
|
"aws-sdk": "^2.1326.0",
|
|
61
61
|
"builtin-modules": "3.2.0",
|
|
62
62
|
"cdk-assets": "2.101.1",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@types/ws": "^8.5.3",
|
|
121
121
|
"@types/yargs": "^17.0.13",
|
|
122
122
|
"archiver": "^5.3.1",
|
|
123
|
-
"astro-sst": "2.
|
|
123
|
+
"astro-sst": "2.33.0",
|
|
124
124
|
"async": "^3.2.4",
|
|
125
125
|
"tsx": "^3.12.1",
|
|
126
126
|
"typescript": "^5.2.2",
|
|
@@ -7,6 +7,7 @@ import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
|
7
7
|
import { bundle } from "./pythonBundling.js";
|
|
8
8
|
import os from "os";
|
|
9
9
|
import url from "url";
|
|
10
|
+
import fs from "fs/promises";
|
|
10
11
|
const RUNTIME_MAP = {
|
|
11
12
|
"python2.7": Runtime.PYTHON_2_7,
|
|
12
13
|
"python3.6": Runtime.PYTHON_3_6,
|
|
@@ -88,20 +89,21 @@ export const usePythonHandler = () => {
|
|
|
88
89
|
type: "error",
|
|
89
90
|
errors: [`Could not find src for ${input.props.handler}`],
|
|
90
91
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
92
|
+
if (input.props.python?.noDocker !== true) {
|
|
93
|
+
bundle({
|
|
94
|
+
installCommands: input.props.python?.installCommands,
|
|
95
|
+
entry: src,
|
|
96
|
+
runtime: RUNTIME_MAP[input.props.runtime],
|
|
97
|
+
architecture: input.props.architecture,
|
|
98
|
+
outputPathSuffix: ".",
|
|
99
|
+
out: input.out,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
100
102
|
await fs.cp(src, input.out, {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
recursive: true,
|
|
104
|
+
filter: (src) => !src.includes(".sst"),
|
|
103
105
|
});
|
|
104
|
-
|
|
106
|
+
/*
|
|
105
107
|
if (await existsAsync(path.join(src, "Pipfile"))) {
|
|
106
108
|
await execAsync("pipenv requirements > requirements.txt", {
|
|
107
109
|
cwd: input.out,
|
|
@@ -46,10 +46,6 @@ export function bundle(options) {
|
|
|
46
46
|
if (hasDeps || hasInstallCommands) {
|
|
47
47
|
image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
|
|
48
48
|
}
|
|
49
|
-
// Copy source code to the bundle.
|
|
50
|
-
fs.cpSync(entry, outputPath, {
|
|
51
|
-
recursive: true,
|
|
52
|
-
});
|
|
53
49
|
}
|
|
54
50
|
/**
|
|
55
51
|
* Checks to see if the `entry` directory contains a type of dependency that
|