sst 2.10.3 → 2.10.4
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/node/util/index.js +24 -5
- package/package.json +1 -1
package/node/util/index.js
CHANGED
|
@@ -23,10 +23,8 @@ export function createProxy(constructName) {
|
|
|
23
23
|
// run code analysis after build. The code analysis runs
|
|
24
24
|
// the top level code, and would fail b/c "SST_APP" and
|
|
25
25
|
// "SST_STAGE" are undefined at build time.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new Error(`Cannot find the ${builtInEnv} environment variable. This is usually the case when you are using an older version of SST. Please update SST to the latest version to use the SST Config feature.`);
|
|
29
|
-
}
|
|
26
|
+
if (!process.env.SST_APP) {
|
|
27
|
+
throw new Error(buildMissingBuiltInEnvError());
|
|
30
28
|
}
|
|
31
29
|
// normalize prop to convert kebab cases like `my-table` to `my_table`
|
|
32
30
|
const normProp = normalizeId(prop);
|
|
@@ -109,7 +107,7 @@ async function fetchValuesFromSSM(variablesFromSsm) {
|
|
|
109
107
|
.filter((variable) => variable.constructName === "Secret")
|
|
110
108
|
.map((variable) => variable.constructId);
|
|
111
109
|
if (missingSecrets.length > 0) {
|
|
112
|
-
throw new Error(`The following
|
|
110
|
+
throw new Error(`The following secret values are not set in the "${process.env.SST_STAGE} stage": ${missingSecrets.join(", ")}`);
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
async function loadSecrets(paths) {
|
|
@@ -175,3 +173,24 @@ function storeVariable(variable, value) {
|
|
|
175
173
|
allVariables[c][id] = allVariables[c][id] || {};
|
|
176
174
|
allVariables[c][id][prop] = value;
|
|
177
175
|
}
|
|
176
|
+
function buildMissingBuiltInEnvError() {
|
|
177
|
+
// Build environment => building SSR sites
|
|
178
|
+
if (process.env.SST) {
|
|
179
|
+
return [
|
|
180
|
+
"",
|
|
181
|
+
`Cannot access bound resources. This usually happens if the "sst/node" package is used at build time. For example:`,
|
|
182
|
+
"",
|
|
183
|
+
` - The "sst/node" package is used inside the "getStaticProps()" function of a Next.js app.`,
|
|
184
|
+
` - The "sst/node" package is used at the top level outside of the "load()" function of a SvelteKit app.`,
|
|
185
|
+
"",
|
|
186
|
+
`Please wrap your build script with "sst bind". For example, "sst bind next build".`,
|
|
187
|
+
"",
|
|
188
|
+
].join("\n");
|
|
189
|
+
}
|
|
190
|
+
// Lambda/CodeBuild environment => Function/Job or SSR function
|
|
191
|
+
if (process.env.AWS_LAMBDA_FUNCTION_NAME || process.env.CODEBUILD_BUILD_ARN) {
|
|
192
|
+
return `Cannot access bound resources. This usually happens if you are using an older version of SST. Please update SST to the latest version.`;
|
|
193
|
+
}
|
|
194
|
+
// Unknown environment => client-side code
|
|
195
|
+
return `Cannot access bound resources. This usually happens if the "sst/node" package is used on the client-side. Ensure that it's only called in your server functions.`;
|
|
196
|
+
}
|