sst 2.0.0-rc.2 → 2.0.0-rc.21
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/bootstrap.js +3 -3
- package/bus.d.ts +3 -3
- package/cache.js +1 -1
- package/cdk/deploy-stack.d.ts +2 -2
- package/cdk/deploy-stack.js +24 -16
- package/cli/commands/bind.js +2 -2
- package/cli/commands/build.js +4 -4
- package/cli/commands/deploy.js +11 -6
- package/cli/commands/dev.js +14 -16
- package/cli/commands/env.js +4 -3
- package/cli/commands/plugins/kysely.js +2 -2
- package/cli/commands/remove.js +4 -5
- package/cli/commands/update.js +12 -6
- package/cli/local/router.d.ts +6 -6
- package/cli/local/router.js +3 -3
- package/cli/local/server.d.ts +1 -1
- package/cli/local/server.js +7 -12
- package/cli/program.d.ts +1 -1
- package/cli/program.js +1 -1
- package/cli/telemetry/environment.d.ts +1 -1
- package/cli/telemetry/environment.js +1 -1
- package/cli/ui/deploy.js +2 -2
- package/config.js +5 -5
- package/constructs/Api.d.ts +3 -3
- package/constructs/ApiGatewayV1Api.d.ts +2 -2
- package/constructs/App.d.ts +2 -2
- package/constructs/App.js +1 -1
- package/constructs/AppSyncApi.d.ts +1 -1
- package/constructs/AppSyncApi.js +1 -1
- package/constructs/Function.d.ts +4 -5
- package/constructs/Function.js +6 -14
- package/constructs/FunctionalStack.d.ts +2 -2
- package/constructs/Job.d.ts +1 -1
- package/constructs/Job.js +2 -2
- package/constructs/Metadata.d.ts +19 -19
- package/constructs/NextjsSite.d.ts +1 -1
- package/constructs/NextjsSite.js +21 -4
- package/constructs/RDS.d.ts +1 -1
- package/constructs/RDS.js +1 -1
- package/constructs/ReactStaticSite.d.ts +2 -2
- package/constructs/ReactStaticSite.js +2 -1
- package/constructs/Script.js +1 -1
- package/constructs/SsrSite.d.ts +11 -6
- package/constructs/SsrSite.js +56 -43
- package/constructs/Stack.d.ts +1 -1
- package/constructs/Stack.js +1 -1
- package/constructs/StaticSite.d.ts +3 -3
- package/constructs/StaticSite.js +9 -9
- package/constructs/Table.d.ts +1 -1
- package/constructs/ViteStaticSite.d.ts +1 -1
- package/constructs/ViteStaticSite.js +2 -1
- package/constructs/deferred_task.d.ts +1 -1
- package/constructs/deprecated/NextjsSite.js +1 -1
- package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
- package/constructs/util/duration.d.ts +1 -1
- package/constructs/util/permission.d.ts +3 -3
- package/constructs/util/size.d.ts +1 -1
- package/context/handler.d.ts +1 -1
- package/credentials.d.ts +1 -1
- package/credentials.js +8 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/iot.js +2 -2
- package/logger.js +1 -1
- package/node/api/index.d.ts +2 -0
- package/node/api/index.js +8 -0
- package/node/auth/adapter/adapter.d.ts +1 -1
- package/node/auth/adapter/github.js +4 -4
- package/node/auth/adapter/google.d.ts +1 -1
- package/node/auth/session.d.ts +1 -1
- package/node/config/index.d.ts +2 -2
- package/node/job/index.d.ts +2 -2
- package/package.json +8 -13
- package/project.d.ts +44 -0
- package/{app.js → project.js} +56 -51
- package/runtime/handlers/dotnet.js +1 -1
- package/runtime/handlers/java.js +1 -1
- package/runtime/handlers/node.js +6 -5
- package/runtime/handlers.js +14 -11
- package/runtime/runtime.d.ts +4 -0
- package/runtime/workers.js +4 -0
- package/site-env.js +1 -1
- package/sst.mjs +807 -16608
- package/stacks/build.d.ts +1 -1
- package/stacks/build.js +13 -21
- package/stacks/metadata.js +5 -5
- package/stacks/monitor.d.ts +1 -1
- package/stacks/synth.js +4 -4
- package/support/base-site-archiver.mjs +79 -0
- package/support/bridge/bridge.mjs +83 -22
- package/support/custom-resources/index.mjs +22 -1
- package/support/edge-function/edge-lambda.mjs +2 -2
- package/support/nodejs-runtime/index.mjs +79 -72
- package/support/rds-migrator/index.mjs +27 -23
- package/support/script-function/index.mjs +30485 -0
- package/support/ssr-site-function-archiver.mjs +96 -0
- package/watcher.js +1 -1
- package/app.d.ts +0 -36
- package/constructs/Script/cfn-response.d.ts +0 -19
- package/constructs/Script/cfn-response.js +0 -77
- package/constructs/Script/index.d.ts +0 -1
- package/constructs/Script/index.js +0 -78
- package/constructs/Script/outbound.d.ts +0 -10
- package/constructs/Script/outbound.js +0 -42
- package/constructs/Script/util.d.ts +0 -2
- package/constructs/Script/util.js +0 -11
- package/support/base-site-archiver.cjs +0 -116
package/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DeleteParameterCommand, GetParameterCommand, GetParametersByPathCommand, PutParameterCommand, SSMClient, } from "@aws-sdk/client-ssm";
|
|
2
2
|
import { GetFunctionConfigurationCommand, LambdaClient, UpdateFunctionConfigurationCommand, } from "@aws-sdk/client-lambda";
|
|
3
3
|
import { pipe, map } from "remeda";
|
|
4
|
-
import { useProject } from "./
|
|
4
|
+
import { useProject } from "./project.js";
|
|
5
5
|
import { useAWSClient } from "./credentials.js";
|
|
6
6
|
import { Stacks } from "./stacks/index.js";
|
|
7
7
|
export var Config;
|
|
@@ -62,8 +62,8 @@ export var Config;
|
|
|
62
62
|
const project = useProject();
|
|
63
63
|
const parameters = await Config.parameters();
|
|
64
64
|
const env = {
|
|
65
|
-
SST_APP: project.name,
|
|
66
|
-
SST_STAGE: project.stage,
|
|
65
|
+
SST_APP: project.config.name,
|
|
66
|
+
SST_STAGE: project.config.stage,
|
|
67
67
|
...pipe(parameters, map((p) => [`SST_${p.type}_${p.prop}_${p.id}`, p.value]), Object.fromEntries),
|
|
68
68
|
};
|
|
69
69
|
return env;
|
|
@@ -156,11 +156,11 @@ const SECRET_UPDATED_AT_ENV = "SST_ADMIN_SECRET_UPDATED_AT";
|
|
|
156
156
|
const PREFIX = {
|
|
157
157
|
get STAGE() {
|
|
158
158
|
const project = useProject();
|
|
159
|
-
return `/sst/${project.name}/${project.stage}/`;
|
|
159
|
+
return `/sst/${project.config.name}/${project.config.stage}/`;
|
|
160
160
|
},
|
|
161
161
|
get FALLBACK() {
|
|
162
162
|
const project = useProject();
|
|
163
|
-
return `/sst/${project.name}/${FALLBACK_STAGE}/`;
|
|
163
|
+
return `/sst/${project.config.name}/${FALLBACK_STAGE}/`;
|
|
164
164
|
},
|
|
165
165
|
};
|
|
166
166
|
function parse(ssmName) {
|
package/constructs/Api.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ import * as apigV2Cors from "./util/apiGatewayV2Cors.js";
|
|
|
14
14
|
import * as apigV2Domain from "./util/apiGatewayV2Domain.js";
|
|
15
15
|
import * as apigV2AccessLog from "./util/apiGatewayV2AccessLog.js";
|
|
16
16
|
declare const PayloadFormatVersions: readonly ["1.0", "2.0"];
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export type ApiPayloadFormatVersion = typeof PayloadFormatVersions[number];
|
|
18
|
+
export type ApiAuthorizer = ApiUserPoolAuthorizer | ApiJwtAuthorizer | ApiLambdaAuthorizer;
|
|
19
19
|
interface ApiBaseAuthorizer {
|
|
20
20
|
/**
|
|
21
21
|
* The name of the authorizer.
|
|
@@ -393,7 +393,7 @@ export interface ApiProps<Authorizers extends Record<string, ApiAuthorizer> = Re
|
|
|
393
393
|
httpStages?: Omit<apig.HttpStageProps, "httpApi">[];
|
|
394
394
|
};
|
|
395
395
|
}
|
|
396
|
-
export
|
|
396
|
+
export type ApiRouteProps<AuthorizerKeys> = FunctionInlineDefinition | ApiFunctionRouteProps<AuthorizerKeys> | ApiHttpRouteProps<AuthorizerKeys> | ApiAlbRouteProps<AuthorizerKeys> | ApiGraphQLRouteProps<AuthorizerKeys> | ApiPothosRouteProps<AuthorizerKeys>;
|
|
397
397
|
interface ApiBaseRouteProps<AuthorizerKeys = string> {
|
|
398
398
|
authorizer?: "none" | "iam" | (string extends AuthorizerKeys ? Omit<AuthorizerKeys, "none" | "iam"> : AuthorizerKeys);
|
|
399
399
|
authorizationScopes?: string[];
|
|
@@ -203,7 +203,7 @@ export interface ApiGatewayV1ApiProps<Authorizers extends Record<string, ApiGate
|
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
export
|
|
206
|
+
export type ApiGatewayV1ApiRouteProps<AuthorizerKeys> = FunctionInlineDefinition | ApiGatewayV1ApiFunctionRouteProps<AuthorizerKeys>;
|
|
207
207
|
/**
|
|
208
208
|
* Specify a function route handler and configure additional options
|
|
209
209
|
*
|
|
@@ -230,7 +230,7 @@ export interface ApiGatewayV1ApiFunctionRouteProps<AuthorizerKeys = never> {
|
|
|
230
230
|
function?: lambda.IFunction;
|
|
231
231
|
};
|
|
232
232
|
}
|
|
233
|
-
export
|
|
233
|
+
export type ApiGatewayV1ApiAuthorizer = ApiGatewayV1ApiUserPoolsAuthorizer | ApiGatewayV1ApiLambdaTokenAuthorizer | ApiGatewayV1ApiLambdaRequestAuthorizer;
|
|
234
234
|
interface ApiGatewayV1ApiBaseAuthorizer {
|
|
235
235
|
/**
|
|
236
236
|
* The name of the authorizer.
|
package/constructs/App.d.ts
CHANGED
|
@@ -42,8 +42,8 @@ export interface AppDeployProps {
|
|
|
42
42
|
readonly mode: "deploy" | "dev" | "remove";
|
|
43
43
|
readonly bootstrap: Awaited<ReturnType<typeof useBootstrap>>;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
export
|
|
45
|
+
type AppRemovalPolicy = Lowercase<keyof typeof cdk.RemovalPolicy>;
|
|
46
|
+
export type AppProps = cdk.AppProps;
|
|
47
47
|
/**
|
|
48
48
|
* The App construct extends cdk.App and is used internally by SST.
|
|
49
49
|
*/
|
package/constructs/App.js
CHANGED
|
@@ -14,7 +14,7 @@ import { createRequire } from "module";
|
|
|
14
14
|
import { Auth } from "./Auth.js";
|
|
15
15
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
16
16
|
import { AppContext } from "./context.js";
|
|
17
|
-
import { useProject } from "../
|
|
17
|
+
import { useProject } from "../project.js";
|
|
18
18
|
import { Logger } from "../logger.js";
|
|
19
19
|
import { SiteEnv } from "../site-env.js";
|
|
20
20
|
const require = createRequire(import.meta.url);
|
|
@@ -178,7 +178,7 @@ export interface MappingTemplateInline {
|
|
|
178
178
|
*/
|
|
179
179
|
inline: string;
|
|
180
180
|
}
|
|
181
|
-
export
|
|
181
|
+
export type MappingTemplate = MappingTemplateFile | MappingTemplateInline;
|
|
182
182
|
/**
|
|
183
183
|
* Used to define full resolver config
|
|
184
184
|
*/
|
package/constructs/AppSyncApi.js
CHANGED
|
@@ -15,7 +15,7 @@ import * as appsync from "@aws-cdk/aws-appsync-alpha";
|
|
|
15
15
|
import * as appSyncApiDomain from "./util/appSyncApiDomain.js";
|
|
16
16
|
import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
17
17
|
import { Function as Fn, } from "./Function.js";
|
|
18
|
-
import { useProject } from "../
|
|
18
|
+
import { useProject } from "../project.js";
|
|
19
19
|
/////////////////////
|
|
20
20
|
// Construct
|
|
21
21
|
/////////////////////
|
package/constructs/Function.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ declare const supportedRuntimes: {
|
|
|
34
34
|
java11: cdk.aws_lambda.Runtime;
|
|
35
35
|
"go1.x": cdk.aws_lambda.Runtime;
|
|
36
36
|
};
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
37
|
+
export type Runtime = keyof typeof supportedRuntimes;
|
|
38
|
+
export type FunctionInlineDefinition = string | Function;
|
|
39
|
+
export type FunctionDefinition = string | Function | FunctionProps;
|
|
40
40
|
export interface FunctionUrlCorsProps extends functionUrlCors.CorsProps {
|
|
41
41
|
}
|
|
42
42
|
export interface FunctionHooks {
|
|
@@ -505,7 +505,7 @@ export interface JavaProps {
|
|
|
505
505
|
*/
|
|
506
506
|
experimentalUseProvidedRuntime?: "provided" | "provided.al2";
|
|
507
507
|
}
|
|
508
|
-
export
|
|
508
|
+
export type FunctionBundleProp = FunctionBundlePythonProps | boolean;
|
|
509
509
|
interface FunctionBundleBase {
|
|
510
510
|
}
|
|
511
511
|
/**
|
|
@@ -642,7 +642,6 @@ export declare class Function extends lambda.Function implements SSTConstruct {
|
|
|
642
642
|
static normalizeMemorySize(memorySize?: number | Size): number;
|
|
643
643
|
static normalizeDiskSize(diskSize?: number | Size): cdk.Size;
|
|
644
644
|
static normalizeTimeout(timeout?: number | Duration): cdk.Duration;
|
|
645
|
-
static normalizeRuntime(runtime?: Runtime): Runtime;
|
|
646
645
|
static normalizeSrcPath(srcPath: string): string;
|
|
647
646
|
static handleImportedLayer(scope: Construct, layer: lambda.ILayerVersion): lambda.ILayerVersion;
|
|
648
647
|
static isInlineDefinition(definition: any): definition is FunctionInlineDefinition;
|
package/constructs/Function.js
CHANGED
|
@@ -18,7 +18,7 @@ import * as functionUrlCors from "./util/functionUrlCors.js";
|
|
|
18
18
|
import url from "url";
|
|
19
19
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
20
20
|
import { useWarning } from "./util/warning.js";
|
|
21
|
-
import { useProject } from "../
|
|
21
|
+
import { useProject } from "../project.js";
|
|
22
22
|
import { useRuntimeHandlers } from "../runtime/handlers.js";
|
|
23
23
|
import { createAppContext } from "./context.js";
|
|
24
24
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
@@ -77,6 +77,7 @@ export class Function extends lambda.Function {
|
|
|
77
77
|
.forEach((per) => {
|
|
78
78
|
props = Function.mergeProps(per, props);
|
|
79
79
|
});
|
|
80
|
+
props.runtime = props.runtime || "nodejs16.x";
|
|
80
81
|
// Set defaults
|
|
81
82
|
const functionName = props.functionName &&
|
|
82
83
|
(typeof props.functionName === "string"
|
|
@@ -84,7 +85,6 @@ export class Function extends lambda.Function {
|
|
|
84
85
|
: props.functionName({ stack, functionProps: props }));
|
|
85
86
|
const handler = props.handler;
|
|
86
87
|
const timeout = Function.normalizeTimeout(props.timeout);
|
|
87
|
-
const runtime = Function.normalizeRuntime(props.runtime);
|
|
88
88
|
const architecture = (() => {
|
|
89
89
|
if (props.architecture === "arm_64")
|
|
90
90
|
return lambda.Architecture.ARM_64;
|
|
@@ -103,9 +103,7 @@ export class Function extends lambda.Function {
|
|
|
103
103
|
throw new Error(`No handler defined for the "${id}" Lambda function`);
|
|
104
104
|
}
|
|
105
105
|
// Validate input
|
|
106
|
-
const isNodeRuntime = runtime.startsWith("nodejs");
|
|
107
|
-
const isPythonRuntime = runtime.startsWith("python");
|
|
108
|
-
const isJavaRuntime = runtime.startsWith("java");
|
|
106
|
+
const isNodeRuntime = props.runtime.startsWith("nodejs");
|
|
109
107
|
// Handle local development (ie. sst start)
|
|
110
108
|
// - set runtime to nodejs12.x for non-Node runtimes (b/c the stub is in Node)
|
|
111
109
|
// - set retry to 0. When the debugger is disconnected, the Cron construct
|
|
@@ -196,7 +194,8 @@ export class Function extends lambda.Function {
|
|
|
196
194
|
// Update function's code
|
|
197
195
|
const codeConfig = code.bind(this);
|
|
198
196
|
const cfnFunction = this.node.defaultChild;
|
|
199
|
-
cfnFunction.runtime =
|
|
197
|
+
cfnFunction.runtime =
|
|
198
|
+
supportedRuntimes[props.runtime].toString();
|
|
200
199
|
/*
|
|
201
200
|
if (isJavaRuntime) {
|
|
202
201
|
const providedRuntime = (bundle as FunctionBundleJavaProps)
|
|
@@ -229,7 +228,7 @@ export class Function extends lambda.Function {
|
|
|
229
228
|
// Add config
|
|
230
229
|
this.addEnvironment("SST_APP", app.name, { removeInEdge: true });
|
|
231
230
|
this.addEnvironment("SST_STAGE", app.stage, { removeInEdge: true });
|
|
232
|
-
this.addEnvironment("SST_SSM_PREFIX", useProject().ssmPrefix, {
|
|
231
|
+
this.addEnvironment("SST_SSM_PREFIX", useProject().config.ssmPrefix, {
|
|
233
232
|
removeInEdge: true,
|
|
234
233
|
});
|
|
235
234
|
this.addConfig(props.config || []);
|
|
@@ -391,13 +390,6 @@ export class Function extends lambda.Function {
|
|
|
391
390
|
}
|
|
392
391
|
return cdk.Duration.seconds(timeout || 10);
|
|
393
392
|
}
|
|
394
|
-
static normalizeRuntime(runtime) {
|
|
395
|
-
runtime = runtime || "nodejs18.x";
|
|
396
|
-
if (!supportedRuntimes[runtime]) {
|
|
397
|
-
throw new Error(`The specified runtime is not supported for sst.Function. Only NodeJS, Python, Go, and .NET runtimes are currently supported.`);
|
|
398
|
-
}
|
|
399
|
-
return runtime;
|
|
400
|
-
}
|
|
401
393
|
static normalizeSrcPath(srcPath) {
|
|
402
394
|
return srcPath.replace(/\/+$/, "");
|
|
403
395
|
}
|
|
@@ -6,8 +6,8 @@ export declare function stack(app: App, fn: FunctionalStack<any>, props?: StackP
|
|
|
6
6
|
export declare function use<T>(stack: FunctionalStack<T>): T;
|
|
7
7
|
export declare function dependsOn(stack: FunctionalStack<any>): void;
|
|
8
8
|
export declare function getStack(stack: FunctionalStack<any>): Stack;
|
|
9
|
-
export
|
|
9
|
+
export type StackContext = {
|
|
10
10
|
app: App;
|
|
11
11
|
stack: Stack;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type FunctionalStack<T> = (this: Stack, ctx: StackContext) => T | Promise<T>;
|
package/constructs/Job.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Function } from "./Function.js";
|
|
|
5
5
|
import { Duration } from "./util/duration.js";
|
|
6
6
|
import { Permissions } from "./util/permission.js";
|
|
7
7
|
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
|
8
|
-
export
|
|
8
|
+
export type JobMemorySize = "3 GB" | "7 GB" | "15 GB" | "145 GB";
|
|
9
9
|
export interface JobProps {
|
|
10
10
|
/**
|
|
11
11
|
* Path to the entry point and handler function. Of the format:
|
package/constructs/Job.js
CHANGED
|
@@ -12,7 +12,7 @@ import { attachPermissionsToRole } from "./util/permission.js";
|
|
|
12
12
|
import { bindEnvironment, bindPermissions } from "./util/functionBinding.js";
|
|
13
13
|
import { useDeferredTasks } from "./deferred_task.js";
|
|
14
14
|
import { useWarning } from "./util/warning.js";
|
|
15
|
-
import { useProject } from "../
|
|
15
|
+
import { useProject } from "../project.js";
|
|
16
16
|
import { useRuntimeHandlers } from "../runtime/handlers.js";
|
|
17
17
|
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
18
18
|
/////////////////////
|
|
@@ -165,7 +165,7 @@ export class Job extends Construct {
|
|
|
165
165
|
environmentVariables: {
|
|
166
166
|
SST_APP: { value: app.name },
|
|
167
167
|
SST_STAGE: { value: app.stage },
|
|
168
|
-
SST_SSM_PREFIX: { value: useProject().ssmPrefix },
|
|
168
|
+
SST_SSM_PREFIX: { value: useProject().config.ssmPrefix },
|
|
169
169
|
},
|
|
170
170
|
timeout: this.normalizeTimeout(this.props.timeout || "8 hours"),
|
|
171
171
|
buildSpec: codebuild.BuildSpec.fromObject({
|
package/constructs/Metadata.d.ts
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
import { SSTConstruct } from "./Construct.js";
|
|
2
|
-
|
|
2
|
+
type ExtractMetadata<T extends SSTConstruct> = ReturnType<T["getConstructMetadata"]> & {
|
|
3
3
|
id: string;
|
|
4
4
|
addr: string;
|
|
5
5
|
stack: string;
|
|
6
6
|
};
|
|
7
7
|
import type { Api } from "./Api.js";
|
|
8
|
-
export
|
|
8
|
+
export type ApiMetadata = ExtractMetadata<Api<any>>;
|
|
9
9
|
import { GraphQLApi } from "./GraphQLApi.js";
|
|
10
|
-
export
|
|
10
|
+
export type GraphQLApiMetadata = ExtractMetadata<GraphQLApi>;
|
|
11
11
|
import type { ApiGatewayV1Api } from "./ApiGatewayV1Api.js";
|
|
12
|
-
export
|
|
12
|
+
export type ApiGatewayV1ApiMetadata = ExtractMetadata<ApiGatewayV1Api<any>>;
|
|
13
13
|
import type { Cognito } from "./Cognito.js";
|
|
14
|
-
export
|
|
14
|
+
export type AuthMetadata = ExtractMetadata<Cognito>;
|
|
15
15
|
import type { AppSyncApi } from "./AppSyncApi.js";
|
|
16
|
-
export
|
|
16
|
+
export type AppSyncApiMetadata = ExtractMetadata<AppSyncApi>;
|
|
17
17
|
import type { Bucket } from "./Bucket.js";
|
|
18
|
-
export
|
|
18
|
+
export type BucketMetadata = ExtractMetadata<Bucket>;
|
|
19
19
|
import type { Cron } from "./Cron.js";
|
|
20
|
-
export
|
|
20
|
+
export type CronMetadata = ExtractMetadata<Cron>;
|
|
21
21
|
import type { EventBus } from "./EventBus.js";
|
|
22
|
-
export
|
|
22
|
+
export type EventBusMetadata = ExtractMetadata<EventBus>;
|
|
23
23
|
import type { Function as Fn } from "./Function.js";
|
|
24
|
-
export
|
|
24
|
+
export type FunctionMetadata = ExtractMetadata<Fn>;
|
|
25
25
|
import type { KinesisStream } from "./KinesisStream.js";
|
|
26
|
-
export
|
|
26
|
+
export type KinesisStreamMetadata = ExtractMetadata<KinesisStream>;
|
|
27
27
|
import type { NextjsSite } from "./NextjsSite.js";
|
|
28
|
-
export
|
|
28
|
+
export type NextjsMetadata = ExtractMetadata<NextjsSite>;
|
|
29
29
|
import type { Queue } from "./Queue.js";
|
|
30
|
-
export
|
|
30
|
+
export type QueueMetadata = ExtractMetadata<Queue>;
|
|
31
31
|
import type { StaticSite } from "./StaticSite.js";
|
|
32
|
-
export
|
|
32
|
+
export type StaticSiteMetadata = ExtractMetadata<StaticSite>;
|
|
33
33
|
import type { Table } from "./Table.js";
|
|
34
|
-
export
|
|
34
|
+
export type TableMetadata = ExtractMetadata<Table>;
|
|
35
35
|
import type { Topic } from "./Topic.js";
|
|
36
|
-
export
|
|
36
|
+
export type TopicMetadata = ExtractMetadata<Topic>;
|
|
37
37
|
import type { WebSocketApi } from "./WebSocketApi.js";
|
|
38
|
-
export
|
|
38
|
+
export type WebSocketApiMetadata = ExtractMetadata<WebSocketApi>;
|
|
39
39
|
import type { RDS } from "./RDS.js";
|
|
40
|
-
export
|
|
41
|
-
export
|
|
40
|
+
export type RDSMetadata = ExtractMetadata<RDS>;
|
|
41
|
+
export type Metadata = ApiMetadata | ApiGatewayV1ApiMetadata | AuthMetadata | AppSyncApiMetadata | BucketMetadata | CronMetadata | EventBusMetadata | FunctionMetadata | KinesisStreamMetadata | NextjsMetadata | QueueMetadata | StaticSiteMetadata | TableMetadata | TopicMetadata | WebSocketApiMetadata | GraphQLApiMetadata | RDSMetadata;
|
|
42
42
|
export {};
|
|
@@ -16,7 +16,7 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "edge"> {
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare class NextjsSite extends SsrSite {
|
|
19
|
-
constructor(scope: Construct, id: string, props
|
|
19
|
+
constructor(scope: Construct, id: string, props?: NextjsSiteProps);
|
|
20
20
|
protected initBuildConfig(): {
|
|
21
21
|
serverBuildOutputFile: string;
|
|
22
22
|
clientBuildOutputDir: string;
|
package/constructs/NextjsSite.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import url from "url";
|
|
3
3
|
import path from "path";
|
|
4
|
+
import spawn from "cross-spawn";
|
|
4
5
|
import { buildErrorResponsesForRedirectToIndex } from "./BaseSite.js";
|
|
5
6
|
import { Fn, Duration, RemovalPolicy, } from "aws-cdk-lib";
|
|
6
7
|
import * as logs from "aws-cdk-lib/aws-logs";
|
|
@@ -44,7 +45,24 @@ export class NextjsSite extends SsrSite {
|
|
|
44
45
|
handler = "server.handler";
|
|
45
46
|
}
|
|
46
47
|
else {
|
|
47
|
-
bundlePath
|
|
48
|
+
// Note: cannot point the bundlePath to the `.open-next/server-function`
|
|
49
|
+
// b/c the folder contains node_modules. And pnpm node_modules
|
|
50
|
+
// contains symlinks. CDK cannot zip symlinks correctly.
|
|
51
|
+
// https://github.com/aws/aws-cdk/issues/9251
|
|
52
|
+
// We will zip the folder ourselves.
|
|
53
|
+
const zipOutDir = path.resolve(path.join(this.sstBuildDir, `Site-${this.node.id}-${this.node.addr}`));
|
|
54
|
+
const script = path.resolve(__dirname, "../support/ssr-site-function-archiver.mjs");
|
|
55
|
+
const result = spawn.sync("node", [
|
|
56
|
+
script,
|
|
57
|
+
path.join(this.props.path, ".open-next", "server-function"),
|
|
58
|
+
path.join(zipOutDir, "server-function.zip"),
|
|
59
|
+
], {
|
|
60
|
+
stdio: "inherit",
|
|
61
|
+
});
|
|
62
|
+
if (result.status !== 0) {
|
|
63
|
+
throw new Error(`There was a problem generating the assets package.`);
|
|
64
|
+
}
|
|
65
|
+
bundlePath = path.join(zipOutDir, "server-function.zip");
|
|
48
66
|
handler = "index.handler";
|
|
49
67
|
}
|
|
50
68
|
return new lambda.Function(this, `ServerFunction`, {
|
|
@@ -109,9 +127,8 @@ export class NextjsSite extends SsrSite {
|
|
|
109
127
|
};
|
|
110
128
|
// Create default behavior
|
|
111
129
|
// default handler for requests that don't match any other path:
|
|
112
|
-
// - try
|
|
113
|
-
// - if
|
|
114
|
-
// - if 404, fall back to lambda handler
|
|
130
|
+
// - try lambda handler first first
|
|
131
|
+
// - if failed, fall back to S3
|
|
115
132
|
const fallbackOriginGroup = new origins.OriginGroup({
|
|
116
133
|
primaryOrigin: serverBehavior.origin,
|
|
117
134
|
fallbackOrigin: s3Origin,
|
package/constructs/RDS.d.ts
CHANGED
|
@@ -134,7 +134,7 @@ export interface RDSProps {
|
|
|
134
134
|
secret?: secretsManager.ISecret;
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
-
export
|
|
137
|
+
export type RDSEngineType = RDSProps["engine"];
|
|
138
138
|
export interface RDSCdkServerlessClusterProps extends Omit<rds.ServerlessClusterProps, "vpc" | "engine" | "defaultDatabaseName" | "scaling"> {
|
|
139
139
|
vpc?: ec2.IVpc;
|
|
140
140
|
}
|
package/constructs/RDS.js
CHANGED
|
@@ -294,7 +294,7 @@ export class RDS extends Construct {
|
|
|
294
294
|
const app = this.node.root;
|
|
295
295
|
// Create custom resource handler
|
|
296
296
|
const handler = new lambda.Function(this, "MigrationHandler", {
|
|
297
|
-
code: lambda.Code.fromAsset(path.join(__dirname, "
|
|
297
|
+
code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
|
|
298
298
|
runtime: lambda.Runtime.NODEJS_16_X,
|
|
299
299
|
handler: "index.handler",
|
|
300
300
|
timeout: cdk.Duration.minutes(15),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Construct } from "constructs";
|
|
2
2
|
import { StaticSite, StaticSiteProps } from "./StaticSite.js";
|
|
3
3
|
import { SSTConstruct } from "./Construct.js";
|
|
4
|
-
export
|
|
4
|
+
export type ReactStaticSiteProps = StaticSiteProps;
|
|
5
5
|
/**
|
|
6
6
|
* The `ReactStaticSite` construct is a higher level CDK construct that makes it easy to create a React single page app.
|
|
7
7
|
*
|
|
@@ -16,5 +16,5 @@ export declare type ReactStaticSiteProps = StaticSiteProps;
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare class ReactStaticSite extends StaticSite implements SSTConstruct {
|
|
19
|
-
constructor(scope: Construct, id: string, props
|
|
19
|
+
constructor(scope: Construct, id: string, props?: ReactStaticSiteProps);
|
|
20
20
|
}
|
|
@@ -19,7 +19,8 @@ import { StaticSite } from "./StaticSite.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export class ReactStaticSite extends StaticSite {
|
|
21
21
|
constructor(scope, id, props) {
|
|
22
|
-
const { path:
|
|
22
|
+
const { path: pathRaw, environment } = props || {};
|
|
23
|
+
const sitePath = pathRaw || ".";
|
|
23
24
|
// Validate environment
|
|
24
25
|
Object.keys(environment || {}).forEach((key) => {
|
|
25
26
|
if (!key.startsWith("REACT_APP_")) {
|
package/constructs/Script.js
CHANGED
|
@@ -113,7 +113,7 @@ export class Script extends Construct {
|
|
|
113
113
|
}
|
|
114
114
|
createCustomResourceFunction() {
|
|
115
115
|
const handler = new lambda.Function(this, "ScriptHandler", {
|
|
116
|
-
code: lambda.Code.fromAsset(path.join(__dirname, "
|
|
116
|
+
code: lambda.Code.fromAsset(path.join(__dirname, "../support/script-function")),
|
|
117
117
|
runtime: lambda.Runtime.NODEJS_16_X,
|
|
118
118
|
handler: "index.handler",
|
|
119
119
|
timeout: cdk.Duration.minutes(15),
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { EdgeFunction } from "./EdgeFunction.js";
|
|
|
10
10
|
import { BaseSiteDomainProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
|
|
11
11
|
import { Permissions } from "./util/permission.js";
|
|
12
12
|
import { FunctionBindingProps } from "./util/functionBinding.js";
|
|
13
|
-
export
|
|
13
|
+
export type SsrBuildConfig = {
|
|
14
14
|
serverBuildOutputFile: string;
|
|
15
15
|
clientBuildOutputDir: string;
|
|
16
16
|
clientBuildVersionedSubDir: string;
|
|
@@ -28,8 +28,9 @@ export interface SsrSiteProps {
|
|
|
28
28
|
edge?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Path to the directory where the app is located.
|
|
31
|
+
* @default "."
|
|
31
32
|
*/
|
|
32
|
-
path
|
|
33
|
+
path?: string;
|
|
33
34
|
/**
|
|
34
35
|
* The command for building the website
|
|
35
36
|
* @default `npm run build`
|
|
@@ -161,7 +162,9 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
161
162
|
*/
|
|
162
163
|
certificate?: acm.ICertificate;
|
|
163
164
|
};
|
|
164
|
-
protected props: SsrSiteProps
|
|
165
|
+
protected props: Omit<SsrSiteProps, "path"> & {
|
|
166
|
+
path: string;
|
|
167
|
+
};
|
|
165
168
|
/**
|
|
166
169
|
* Determines if a placeholder site should be deployed instead. We will set
|
|
167
170
|
* this to `true` by default when performing local development, although the
|
|
@@ -176,7 +179,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
176
179
|
private serverLambdaForEdge?;
|
|
177
180
|
protected serverLambdaForRegional?: lambda.Function;
|
|
178
181
|
private awsCliLayer;
|
|
179
|
-
constructor(scope: Construct, id: string, props
|
|
182
|
+
constructor(scope: Construct, id: string, props?: SsrSiteProps);
|
|
180
183
|
/**
|
|
181
184
|
* The CloudFront URL of the website.
|
|
182
185
|
*/
|
|
@@ -226,8 +229,10 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
226
229
|
private buildApp;
|
|
227
230
|
protected validateBuildOutput(): void;
|
|
228
231
|
private runBuild;
|
|
229
|
-
private
|
|
230
|
-
private
|
|
232
|
+
private createS3Assets;
|
|
233
|
+
private createS3AssetFileOptions;
|
|
234
|
+
private createS3AssetsForStub;
|
|
235
|
+
private createS3AssetFileOptionsForStub;
|
|
231
236
|
private createS3Bucket;
|
|
232
237
|
private createS3Deployment;
|
|
233
238
|
protected createFunctionForRegional(): lambda.Function;
|