sst 2.7.1 → 2.8.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/cli/ci-info.d.ts +4 -0
- package/cli/ci-info.js +8 -0
- package/cli/commands/bind.js +1 -0
- package/cli/commands/deploy.js +2 -1
- package/cli/commands/dev.js +9 -3
- package/cli/commands/diff.js +20 -5
- package/cli/commands/update.js +1 -0
- package/cli/telemetry/environment.js +4 -4
- package/cli/ui/functions.js +3 -3
- package/config.js +2 -1
- package/constructs/AppSyncApi.d.ts +1 -2
- package/constructs/AppSyncApi.js +5 -15
- package/constructs/AstroSite.js +4 -8
- package/constructs/EdgeFunction.js +6 -6
- package/constructs/Function.d.ts +1 -1
- package/constructs/Function.js +10 -2
- package/constructs/RemixSite.js +4 -8
- package/constructs/SolidStartSite.js +4 -9
- package/constructs/SsrFunction.d.ts +10 -2
- package/constructs/SsrFunction.js +99 -32
- package/constructs/SsrSite.d.ts +5 -3
- package/constructs/SsrSite.js +23 -11
- package/constructs/SvelteKitSite.d.ts +27 -0
- package/constructs/SvelteKitSite.js +101 -0
- package/constructs/SvelteKitSite.tsdoc.d.ts +2 -0
- package/constructs/SvelteKitSite.tsdoc.js +2 -0
- package/constructs/deprecated/NextjsSite.js +1 -1
- package/constructs/deprecated/cross-region-helper.js +3 -3
- package/constructs/index.d.ts +1 -0
- package/constructs/index.js +1 -0
- package/constructs/static-file-list.d.ts +1 -0
- package/constructs/static-file-list.js +51 -0
- package/constructs/util/appSyncApiDomain.d.ts +14 -2
- package/constructs/util/appSyncApiDomain.js +56 -11
- package/node/config/index.js +0 -9
- package/node/site/index.d.ts +6 -6
- package/node/site/index.js +5 -5
- package/node/util/index.js +11 -0
- package/package.json +2 -2
- package/runtime/handlers.js +7 -0
- package/runtime/workers.js +4 -0
- package/sst.mjs +70 -16
- package/support/base-site-archiver.mjs +18 -18
- package/support/bootstrap-metadata-function/index.mjs +1345 -1409
- package/support/bridge/bridge.mjs +46 -35
- package/support/custom-resources/index.mjs +6468 -6532
- package/support/job-invoker/index.mjs +90 -907
- package/support/rds-migrator/index.mjs +16 -16
- package/support/script-function/index.mjs +90 -907
- package/support/ssr-site-function-archiver.mjs +9 -9
- /package/support/{sls-nextjs-site-function-stub → ssr-site-function-stub}/index.js +0 -0
package/cli/ci-info.d.ts
ADDED
package/cli/ci-info.js
ADDED
package/cli/commands/bind.js
CHANGED
package/cli/commands/deploy.js
CHANGED
|
@@ -17,6 +17,7 @@ export const deploy = (program) => program.command("deploy [filter]", "Deploy yo
|
|
|
17
17
|
const { dim, blue, bold } = await import("colorette");
|
|
18
18
|
const { useProject } = await import("../../project.js");
|
|
19
19
|
const { loadAssembly, useAppMetadata, saveAppMetadata, Stacks } = await import("../../stacks/index.js");
|
|
20
|
+
const { getCiInfo } = await import("../ci-info.js");
|
|
20
21
|
const { render } = await import("ink");
|
|
21
22
|
const { DeploymentUI } = await import("../ui/deploy.js");
|
|
22
23
|
const { mapValues } = await import("remeda");
|
|
@@ -40,7 +41,7 @@ export const deploy = (program) => program.command("deploy [filter]", "Deploy yo
|
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
// Check app mode changed
|
|
43
|
-
if (appMetadata && appMetadata.mode !== "deploy") {
|
|
44
|
+
if (!getCiInfo().isCI && appMetadata && appMetadata.mode !== "deploy") {
|
|
44
45
|
if (!(await promptChangeMode())) {
|
|
45
46
|
process.exit(0);
|
|
46
47
|
}
|
package/cli/commands/dev.js
CHANGED
|
@@ -31,6 +31,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
31
31
|
const { useMetadata } = await import("../../stacks/metadata.js");
|
|
32
32
|
const { useIOT } = await import("../../iot.js");
|
|
33
33
|
const { clear } = await import("../terminal.js");
|
|
34
|
+
const { getCiInfo } = await import("../ci-info.js");
|
|
34
35
|
if (args._[0] === "start") {
|
|
35
36
|
console.log(yellow(`Warning: ${bold(`sst start`)} has been renamed to ${bold(`sst dev`)}`));
|
|
36
37
|
}
|
|
@@ -69,12 +70,16 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
69
70
|
});
|
|
70
71
|
bus.subscribe("function.build.success", async (evt) => {
|
|
71
72
|
const info = useFunctions().fromID(evt.properties.functionID);
|
|
73
|
+
if (!info)
|
|
74
|
+
return;
|
|
72
75
|
if (info.enableLiveDev === false)
|
|
73
76
|
return;
|
|
74
77
|
Colors.line(Colors.dim(Colors.prefix, "Built", info.handler));
|
|
75
78
|
});
|
|
76
79
|
bus.subscribe("function.build.failed", async (evt) => {
|
|
77
80
|
const info = useFunctions().fromID(evt.properties.functionID);
|
|
81
|
+
if (!info)
|
|
82
|
+
return;
|
|
78
83
|
if (info.enableLiveDev === false)
|
|
79
84
|
return;
|
|
80
85
|
Colors.gap();
|
|
@@ -109,7 +114,6 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
109
114
|
const useStackBuilder = Context.memo(async () => {
|
|
110
115
|
const watcher = useWatcher();
|
|
111
116
|
const project = useProject();
|
|
112
|
-
const bus = useBus();
|
|
113
117
|
let lastDeployed;
|
|
114
118
|
let isWorking = false;
|
|
115
119
|
let isDirty = false;
|
|
@@ -188,7 +192,9 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
188
192
|
? "Remix"
|
|
189
193
|
: type === "SolidStartSite"
|
|
190
194
|
? "SolidStart"
|
|
191
|
-
:
|
|
195
|
+
: type === "SvelteKitSite"
|
|
196
|
+
? "SvelteKit"
|
|
197
|
+
: undefined;
|
|
192
198
|
if (framework) {
|
|
193
199
|
const cdCmd = path.resolve(props.path) === process.cwd()
|
|
194
200
|
? ""
|
|
@@ -276,7 +282,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
276
282
|
});
|
|
277
283
|
}
|
|
278
284
|
// Check app mode changed
|
|
279
|
-
if (appMetadata && appMetadata.mode !== "dev") {
|
|
285
|
+
if (!getCiInfo().isCI && appMetadata && appMetadata.mode !== "dev") {
|
|
280
286
|
if (!(await promptChangeMode())) {
|
|
281
287
|
process.exit(0);
|
|
282
288
|
}
|
package/cli/commands/diff.js
CHANGED
|
@@ -8,7 +8,6 @@ export const diff = (program) => program.command("diff", "Compare your app with
|
|
|
8
8
|
const { useAWSClient } = await import("../../credentials.js");
|
|
9
9
|
const { CloudFormationClient, GetTemplateCommand } = await import("@aws-sdk/client-cloudformation");
|
|
10
10
|
const { createSpinner } = await import("../spinner.js");
|
|
11
|
-
const { green } = await import("colorette");
|
|
12
11
|
const { Colors } = await import("../colors.js");
|
|
13
12
|
// Build app
|
|
14
13
|
const project = useProject();
|
|
@@ -23,10 +22,13 @@ export const diff = (program) => program.command("diff", "Compare your app with
|
|
|
23
22
|
for (const stack of assembly.stacks) {
|
|
24
23
|
const spinner = createSpinner(`${stack.stackName}: Checking for changes...`);
|
|
25
24
|
// get old template
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const oldTemplate = await getTemplate(stack.stackName);
|
|
26
|
+
if (!oldTemplate) {
|
|
27
|
+
spinner.clear();
|
|
28
|
+
Colors.line(`➜ ${Colors.dim.bold(stackNameToId(stack.stackName) + ":")} New stack`);
|
|
29
|
+
Colors.gap();
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
30
32
|
// generate diff
|
|
31
33
|
const { count, diff } = await Stacks.diff(stack, oldTemplate);
|
|
32
34
|
spinner.clear();
|
|
@@ -58,4 +60,17 @@ export const diff = (program) => program.command("diff", "Compare your app with
|
|
|
58
60
|
Colors.line(Colors.success(`✔`), Colors.bold(" Diff:"), changesAcc === 1 ? "1 change found in" : `${changesAcc} changes in`, changedStacks === 1 ? "1 stack" : `${changedStacks} stacks`);
|
|
59
61
|
}
|
|
60
62
|
process.exit(0);
|
|
63
|
+
async function getTemplate(stackName) {
|
|
64
|
+
try {
|
|
65
|
+
const response = await cfn.send(new GetTemplateCommand({ StackName: stackName }));
|
|
66
|
+
return JSON.parse(response.TemplateBody);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (e.name === "ValidationError" &&
|
|
70
|
+
e.message.includes("does not exist")) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
throw e;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
61
76
|
});
|
package/cli/commands/update.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os from "os";
|
|
2
|
-
import
|
|
2
|
+
import { getCiInfo } from "../ci-info.js";
|
|
3
3
|
import { useProject } from "../../project.js";
|
|
4
4
|
let data;
|
|
5
5
|
export function getEnvironmentData() {
|
|
@@ -7,7 +7,7 @@ export function getEnvironmentData() {
|
|
|
7
7
|
return data;
|
|
8
8
|
}
|
|
9
9
|
const cpus = os.cpus() || [];
|
|
10
|
-
const
|
|
10
|
+
const ciInfo = getCiInfo();
|
|
11
11
|
data = {
|
|
12
12
|
// Software information
|
|
13
13
|
systemPlatform: os.platform(),
|
|
@@ -19,8 +19,8 @@ export function getEnvironmentData() {
|
|
|
19
19
|
cpuSpeed: cpus.length ? cpus[0].speed : null,
|
|
20
20
|
memoryInMb: Math.trunc(os.totalmem() / Math.pow(1024, 2)),
|
|
21
21
|
// Environment information
|
|
22
|
-
isCI: ciInfo.isCI
|
|
23
|
-
ciName:
|
|
22
|
+
isCI: ciInfo.isCI,
|
|
23
|
+
ciName: ciInfo.name,
|
|
24
24
|
sstVersion: useProject().version,
|
|
25
25
|
};
|
|
26
26
|
return data;
|
package/cli/ui/functions.js
CHANGED
|
@@ -48,7 +48,7 @@ export function Functions() {
|
|
|
48
48
|
const success = bus.subscribe("function.success", (evt) => {
|
|
49
49
|
function print(input, diff) {
|
|
50
50
|
setTimeout(() => {
|
|
51
|
-
console.log(Colors.primary(` ➜ `), useFunctions().fromID(input.functionID)
|
|
51
|
+
console.log(Colors.primary(` ➜ `), useFunctions().fromID(input.functionID)?.handler);
|
|
52
52
|
for (const log of input.logs) {
|
|
53
53
|
console.log(` ${dim(log)}`);
|
|
54
54
|
}
|
|
@@ -78,7 +78,7 @@ export function Functions() {
|
|
|
78
78
|
const error = bus.subscribe("function.error", (evt) => {
|
|
79
79
|
function print(input, diff) {
|
|
80
80
|
setTimeout(() => {
|
|
81
|
-
console.log(Colors.primary(` ➜ `), useFunctions().fromID(input.functionID)
|
|
81
|
+
console.log(Colors.primary(` ➜ `), useFunctions().fromID(input.functionID)?.handler);
|
|
82
82
|
for (const log of input.logs) {
|
|
83
83
|
console.log(` ${dim(log)}`);
|
|
84
84
|
}
|
|
@@ -122,7 +122,7 @@ export function Functions() {
|
|
|
122
122
|
" ",
|
|
123
123
|
React.createElement(Spinner, null),
|
|
124
124
|
" ",
|
|
125
|
-
useFunctions().fromID(evt.functionID)
|
|
125
|
+
useFunctions().fromID(evt.functionID)?.handler),
|
|
126
126
|
evt.logs.map((log, index) => (React.createElement(Text, { dimColor: true, key: index },
|
|
127
127
|
" ",
|
|
128
128
|
log))),
|
package/config.js
CHANGED
|
@@ -122,7 +122,8 @@ export var Config;
|
|
|
122
122
|
.filter((c) => c.type === "AstroSite" ||
|
|
123
123
|
c.type === "NextjsSite" ||
|
|
124
124
|
c.type === "RemixSite" ||
|
|
125
|
-
c.type === "SolidStartSite"
|
|
125
|
+
c.type === "SolidStartSite" ||
|
|
126
|
+
c.type === "SvelteKitSite")
|
|
126
127
|
.filter((c) => keys.some((key) => c.data.secrets.includes(key)));
|
|
127
128
|
const siteDataPlaceholder = siteData.filter((c) => c.data.mode === "placeholder");
|
|
128
129
|
const siteDataEdge = siteData
|
|
@@ -10,7 +10,7 @@ import { Permissions } from "./util/permission.js";
|
|
|
10
10
|
import { Table as CDKTable } from "aws-cdk-lib/aws-dynamodb";
|
|
11
11
|
import { IServerlessCluster } from "aws-cdk-lib/aws-rds";
|
|
12
12
|
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
|
13
|
-
import { AwsIamConfig, BaseDataSource,
|
|
13
|
+
import { AwsIamConfig, BaseDataSource, GraphqlApi, GraphqlApiProps, IGraphqlApi, Resolver, ResolverProps } from "aws-cdk-lib/aws-appsync";
|
|
14
14
|
import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
|
|
15
15
|
import { IDomain } from "aws-cdk-lib/aws-opensearchservice";
|
|
16
16
|
export interface AppSyncApiDomainProps extends appSyncApiDomain.CustomDomainProps {
|
|
@@ -403,7 +403,6 @@ export declare class AppSyncApi extends Construct implements SSTConstruct {
|
|
|
403
403
|
};
|
|
404
404
|
private readonly props;
|
|
405
405
|
private _customDomainUrl?;
|
|
406
|
-
_cfnDomainName?: CfnDomainName;
|
|
407
406
|
private readonly functionsByDsKey;
|
|
408
407
|
private readonly dataSourcesByDsKey;
|
|
409
408
|
private readonly dsKeysByResKey;
|
package/constructs/AppSyncApi.js
CHANGED
|
@@ -48,7 +48,6 @@ export class AppSyncApi extends Construct {
|
|
|
48
48
|
cdk;
|
|
49
49
|
props;
|
|
50
50
|
_customDomainUrl;
|
|
51
|
-
_cfnDomainName;
|
|
52
51
|
functionsByDsKey = {};
|
|
53
52
|
dataSourcesByDsKey = {};
|
|
54
53
|
dsKeysByResKey = {};
|
|
@@ -308,24 +307,15 @@ export class AppSyncApi extends Construct {
|
|
|
308
307
|
name: app.logicalPrefixedName(id),
|
|
309
308
|
xrayEnabled: true,
|
|
310
309
|
schema: mainSchema,
|
|
311
|
-
domainName: domainData
|
|
310
|
+
domainName: domainData && {
|
|
311
|
+
certificate: domainData.certificate,
|
|
312
|
+
domainName: domainData.domainName,
|
|
313
|
+
},
|
|
312
314
|
...graphqlApiProps,
|
|
313
315
|
});
|
|
314
316
|
this.cdk.certificate = domainData?.certificate;
|
|
315
|
-
// note: As of CDK 2.20.0, the "AWS::AppSync::DomainNameApiAssociation" resource
|
|
316
|
-
// is not dependent on the "AWS::AppSync::DomainName" resource. This leads
|
|
317
|
-
// CloudFormation deploy error if DomainNameApiAssociation is created before
|
|
318
|
-
// DomainName is created.
|
|
319
|
-
// https://github.com/aws/aws-cdk/issues/18395#issuecomment-1099455502
|
|
320
|
-
// To workaround this issue, we need to add a dependency manually.
|
|
321
317
|
if (domainData) {
|
|
322
|
-
this
|
|
323
|
-
"AWS::AppSync::DomainName");
|
|
324
|
-
const cfnDomainNameApiAssociation = this.cdk.graphqlApi.node.children.find((child) => child.cfnResourceType ===
|
|
325
|
-
"AWS::AppSync::DomainNameApiAssociation");
|
|
326
|
-
if (this._cfnDomainName && cfnDomainNameApiAssociation) {
|
|
327
|
-
cfnDomainNameApiAssociation.node.addDependency(this._cfnDomainName);
|
|
328
|
-
}
|
|
318
|
+
appSyncApiDomain.cleanup(this, domainData);
|
|
329
319
|
}
|
|
330
320
|
}
|
|
331
321
|
}
|
package/constructs/AstroSite.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { Architecture } from "aws-cdk-lib/aws-lambda";
|
|
4
3
|
import { SsrSite } from "./SsrSite.js";
|
|
5
|
-
import {
|
|
4
|
+
import { SsrFunction } from "./SsrFunction.js";
|
|
6
5
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
7
6
|
/**
|
|
8
7
|
* The `AstroSite` construct is a higher level CDK construct that makes it easy to create a Astro app.
|
|
@@ -34,10 +33,9 @@ export class AstroSite extends SsrSite {
|
|
|
34
33
|
}
|
|
35
34
|
createFunctionForRegional() {
|
|
36
35
|
const { runtime, timeout, memorySize, permissions, environment, nodejs, bind, cdk, } = this.props;
|
|
37
|
-
const
|
|
38
|
-
description: "Server handler",
|
|
36
|
+
const ssrFn = new SsrFunction(this, `ServerFunction`, {
|
|
37
|
+
description: "Server handler for Astro",
|
|
39
38
|
handler: path.join(this.props.path, "dist", "server", "entry.handler"),
|
|
40
|
-
logRetention: "three_days",
|
|
41
39
|
runtime,
|
|
42
40
|
memorySize,
|
|
43
41
|
timeout,
|
|
@@ -49,10 +47,8 @@ export class AstroSite extends SsrSite {
|
|
|
49
47
|
environment,
|
|
50
48
|
permissions,
|
|
51
49
|
...cdk?.server,
|
|
52
|
-
architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
|
|
53
50
|
});
|
|
54
|
-
|
|
55
|
-
return fn;
|
|
51
|
+
return ssrFn.function;
|
|
56
52
|
}
|
|
57
53
|
createFunctionForEdge() {
|
|
58
54
|
const { runtime, timeout, memorySize, bind, permissions, environment, nodejs, } = this.props;
|
|
@@ -75,7 +75,7 @@ export class EdgeFunction extends Construct {
|
|
|
75
75
|
const lambdaBucket = this.createSingletonBucketInUsEast1();
|
|
76
76
|
const { fn, fnArn } = this.createFunctionInUsEast1(assetBucket, assetKey, lambdaBucket);
|
|
77
77
|
const { versionId } = this.createVersionInUsEast1(fn, fnArn);
|
|
78
|
-
//
|
|
78
|
+
// Create function after the code is updated
|
|
79
79
|
fn.node.addDependency(assetReplacer);
|
|
80
80
|
this.function = fn;
|
|
81
81
|
this.functionArn = fnArn;
|
|
@@ -182,6 +182,10 @@ export class EdgeFunction extends Construct {
|
|
|
182
182
|
}
|
|
183
183
|
createCodeReplacer(assetBucket, assetKey, handlerFilename) {
|
|
184
184
|
const { environment } = this.props;
|
|
185
|
+
const stack = Stack.of(this);
|
|
186
|
+
// Note: Source code for the Lambda functions have "{{ ENV_KEY }}" in them.
|
|
187
|
+
// They need to be replaced with real values before the Lambda
|
|
188
|
+
// functions get deployed.
|
|
185
189
|
const replacements = [
|
|
186
190
|
{
|
|
187
191
|
files: handlerFilename,
|
|
@@ -192,15 +196,11 @@ export class EdgeFunction extends Construct {
|
|
|
192
196
|
}),
|
|
193
197
|
},
|
|
194
198
|
...Object.entries(environment).map(([key, value]) => ({
|
|
195
|
-
files: "
|
|
199
|
+
files: "**/*.@(*js|json|html)",
|
|
196
200
|
search: `{{ ${key} }}`,
|
|
197
201
|
replace: value,
|
|
198
202
|
})),
|
|
199
203
|
];
|
|
200
|
-
// Note: Source code for the Lambda functions have "{{ ENV_KEY }}" in them.
|
|
201
|
-
// They need to be replaced with real values before the Lambda
|
|
202
|
-
// functions get deployed.
|
|
203
|
-
const stack = Stack.of(this);
|
|
204
204
|
const policy = new Policy(this, "AssetReplacerPolicy", {
|
|
205
205
|
statements: [
|
|
206
206
|
new PolicyStatement({
|
package/constructs/Function.d.ts
CHANGED
|
@@ -590,7 +590,7 @@ export declare class Function extends CDKFunction implements SSTConstruct {
|
|
|
590
590
|
static mergeProps(baseProps?: FunctionProps, props?: FunctionProps): FunctionProps;
|
|
591
591
|
}
|
|
592
592
|
export declare const useFunctions: () => {
|
|
593
|
-
fromID(id: string): FunctionProps;
|
|
593
|
+
fromID(id: string): FunctionProps | undefined;
|
|
594
594
|
add(name: string, props: FunctionProps): void;
|
|
595
595
|
readonly all: Record<string, FunctionProps>;
|
|
596
596
|
};
|
package/constructs/Function.js
CHANGED
|
@@ -122,6 +122,7 @@ export class Function extends CDKFunction {
|
|
|
122
122
|
environment: props.environment,
|
|
123
123
|
layers: Function.buildLayers(scope, id, props),
|
|
124
124
|
logRetention,
|
|
125
|
+
logRetentionRetryOptions: logRetention && { maxRetries: 100 },
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
// Handle local development (ie. sst start)
|
|
@@ -156,6 +157,7 @@ export class Function extends CDKFunction {
|
|
|
156
157
|
environment: props.environment,
|
|
157
158
|
layers: [],
|
|
158
159
|
logRetention,
|
|
160
|
+
logRetentionRetryOptions: logRetention && { maxRetries: 100 },
|
|
159
161
|
retryAttempts: 0,
|
|
160
162
|
...(debugOverrideProps || {}),
|
|
161
163
|
});
|
|
@@ -171,7 +173,9 @@ export class Function extends CDKFunction {
|
|
|
171
173
|
new PolicyStatement({
|
|
172
174
|
actions: ["s3:*"],
|
|
173
175
|
effect: Effect.ALLOW,
|
|
174
|
-
resources: [
|
|
176
|
+
resources: [
|
|
177
|
+
`arn:${Stack.of(this).partition}:s3:::${bootstrap.bucket}`,
|
|
178
|
+
],
|
|
175
179
|
}),
|
|
176
180
|
]);
|
|
177
181
|
});
|
|
@@ -192,6 +196,7 @@ export class Function extends CDKFunction {
|
|
|
192
196
|
environment: props.environment,
|
|
193
197
|
layers: Function.buildLayers(scope, id, props),
|
|
194
198
|
logRetention,
|
|
199
|
+
logRetentionRetryOptions: logRetention && { maxRetries: 100 },
|
|
195
200
|
});
|
|
196
201
|
useDeferredTasks().add(async () => {
|
|
197
202
|
// Build function
|
|
@@ -499,7 +504,10 @@ export const useFunctions = createAppContext(() => {
|
|
|
499
504
|
const functions = {};
|
|
500
505
|
return {
|
|
501
506
|
fromID(id) {
|
|
502
|
-
|
|
507
|
+
const result = functions[id];
|
|
508
|
+
if (!result)
|
|
509
|
+
return;
|
|
510
|
+
return result;
|
|
503
511
|
},
|
|
504
512
|
add(name, props) {
|
|
505
513
|
functions[name] = props;
|
package/constructs/RemixSite.js
CHANGED
|
@@ -3,9 +3,8 @@ import url from "url";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { createRequire } from "module";
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
|
-
import { Architecture } from "aws-cdk-lib/aws-lambda";
|
|
7
6
|
import { SsrSite } from "./SsrSite.js";
|
|
8
|
-
import {
|
|
7
|
+
import { SsrFunction } from "./SsrFunction.js";
|
|
9
8
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
10
9
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
11
10
|
/**
|
|
@@ -92,10 +91,9 @@ export class RemixSite extends SsrSite {
|
|
|
92
91
|
createFunctionForRegional() {
|
|
93
92
|
const { runtime, timeout, memorySize, permissions, environment, bind, nodejs, cdk, } = this.props;
|
|
94
93
|
const { handler, esbuild } = this.createServerLambdaBundle("regional-server.js");
|
|
95
|
-
const
|
|
96
|
-
description: "Server handler",
|
|
94
|
+
const ssrFn = new SsrFunction(this, `ServerFunction`, {
|
|
95
|
+
description: "Server handler for Remix",
|
|
97
96
|
handler,
|
|
98
|
-
logRetention: "three_days",
|
|
99
97
|
runtime,
|
|
100
98
|
memorySize,
|
|
101
99
|
timeout,
|
|
@@ -112,10 +110,8 @@ export class RemixSite extends SsrSite {
|
|
|
112
110
|
environment,
|
|
113
111
|
permissions,
|
|
114
112
|
...cdk?.server,
|
|
115
|
-
architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
|
|
116
113
|
});
|
|
117
|
-
|
|
118
|
-
return fn;
|
|
114
|
+
return ssrFn.function;
|
|
119
115
|
}
|
|
120
116
|
createFunctionForEdge() {
|
|
121
117
|
const { runtime, timeout, memorySize, bind, permissions, environment, nodejs, } = this.props;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { Architecture } from "aws-cdk-lib/aws-lambda";
|
|
3
2
|
import { SsrSite } from "./SsrSite.js";
|
|
4
|
-
import {
|
|
3
|
+
import { SsrFunction } from "./SsrFunction.js";
|
|
5
4
|
import { EdgeFunction } from "./EdgeFunction.js";
|
|
6
5
|
/**
|
|
7
6
|
* The `SolidStartSite` construct is a higher level CDK construct that makes it easy to create a SolidStart app.
|
|
@@ -25,11 +24,9 @@ export class SolidStartSite extends SsrSite {
|
|
|
25
24
|
}
|
|
26
25
|
createFunctionForRegional() {
|
|
27
26
|
const { runtime, timeout, memorySize, bind, nodejs, permissions, environment, cdk, } = this.props;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
description: "Server handler",
|
|
27
|
+
const ssrFn = new SsrFunction(this, `ServerFunction`, {
|
|
28
|
+
description: "Server handler for Solid",
|
|
31
29
|
handler: path.join(this.props.path, "dist", "server", "index.handler"),
|
|
32
|
-
logRetention: "three_days",
|
|
33
30
|
runtime,
|
|
34
31
|
memorySize,
|
|
35
32
|
timeout,
|
|
@@ -41,10 +38,8 @@ export class SolidStartSite extends SsrSite {
|
|
|
41
38
|
environment,
|
|
42
39
|
permissions,
|
|
43
40
|
...cdk?.server,
|
|
44
|
-
architecture: cdk?.server?.architecture === Architecture.ARM_64 ? "arm_64" : "x86_64",
|
|
45
41
|
});
|
|
46
|
-
|
|
47
|
-
return fn;
|
|
42
|
+
return ssrFn.function;
|
|
48
43
|
}
|
|
49
44
|
createFunctionForEdge() {
|
|
50
45
|
const { runtime, timeout, memorySize, bind, permissions, environment, nodejs, } = this.props;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { FunctionOptions, Function as CdkFunction } from "aws-cdk-lib/aws-lambda";
|
|
3
|
+
import { NodeJSProps, FunctionCopyFilesProps } from "./Function.js";
|
|
3
4
|
import { SSTConstruct } from "./Construct.js";
|
|
4
5
|
import { Permissions } from "./util/permission.js";
|
|
5
6
|
import { Size } from "./util/size.js";
|
|
6
7
|
import { Duration } from "./util/duration.js";
|
|
7
8
|
export interface SsrFunctionProps extends Omit<FunctionOptions, "memorySize" | "timeout" | "runtime"> {
|
|
8
|
-
bundle
|
|
9
|
+
bundle?: string;
|
|
9
10
|
handler: string;
|
|
10
11
|
runtime?: "nodejs14.x" | "nodejs16.x" | "nodejs18.x";
|
|
11
12
|
timeout: number | Duration;
|
|
@@ -13,14 +14,21 @@ export interface SsrFunctionProps extends Omit<FunctionOptions, "memorySize" | "
|
|
|
13
14
|
permissions?: Permissions;
|
|
14
15
|
environment?: Record<string, string>;
|
|
15
16
|
bind?: SSTConstruct[];
|
|
17
|
+
nodejs?: NodeJSProps;
|
|
18
|
+
copyFiles?: FunctionCopyFilesProps[];
|
|
16
19
|
}
|
|
17
20
|
export declare class SsrFunction extends Construct {
|
|
18
21
|
function: CdkFunction;
|
|
22
|
+
private assetReplacer;
|
|
23
|
+
private assetReplacerPolicy;
|
|
19
24
|
private props;
|
|
20
25
|
constructor(scope: Construct, id: string, props: SsrFunctionProps);
|
|
21
26
|
attachPermissions(permissions: Permissions): void;
|
|
22
|
-
private createCodeAsset;
|
|
23
27
|
private createFunction;
|
|
24
28
|
private createCodeReplacer;
|
|
25
29
|
private bind;
|
|
30
|
+
private buildAssetFromHandler;
|
|
31
|
+
private buildAssetFromBundle;
|
|
32
|
+
private updateCodeReplacer;
|
|
33
|
+
private updateFunction;
|
|
26
34
|
}
|