sst 2.0.0-rc.8 → 2.0.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/bootstrap.d.ts +2 -4
- package/bootstrap.js +208 -61
- package/bus.d.ts +3 -3
- package/bus.js +1 -1
- package/cache.js +1 -1
- package/cdk/cloudformation-deployments-wrapper.d.ts +3 -0
- package/cdk/cloudformation-deployments-wrapper.js +117 -0
- package/cdk/cloudformation-deployments.d.ts +19 -4
- package/cdk/deploy-stack.d.ts +17 -2
- package/cdk/deploy-stack.js +6 -1
- package/cli/colors.d.ts +28 -0
- package/cli/colors.js +27 -0
- package/cli/commands/bind.d.ts +4 -0
- package/cli/commands/bind.js +10 -7
- package/cli/commands/bootstrap.d.ts +13 -0
- package/cli/commands/bootstrap.js +11 -0
- package/cli/commands/build.d.ts +6 -2
- package/cli/commands/build.js +13 -8
- package/cli/commands/console.d.ts +5 -1
- package/cli/commands/console.js +8 -6
- package/cli/commands/deploy.d.ts +4 -2
- package/cli/commands/deploy.js +71 -29
- package/cli/commands/dev.d.ts +5 -1
- package/cli/commands/dev.js +157 -79
- package/cli/commands/diff.d.ts +15 -0
- package/cli/commands/diff.js +61 -0
- package/cli/commands/env.d.ts +5 -1
- package/cli/commands/env.js +14 -15
- package/cli/commands/plugins/kysely.js +13 -5
- package/cli/commands/plugins/pothos.js +9 -4
- package/cli/commands/remove.d.ts +4 -0
- package/cli/commands/remove.js +26 -18
- package/cli/commands/secrets/get.d.ts +7 -3
- package/cli/commands/secrets/get.js +11 -24
- package/cli/commands/secrets/list.d.ts +6 -2
- package/cli/commands/secrets/list.js +15 -7
- package/cli/commands/secrets/remove.d.ts +8 -4
- package/cli/commands/secrets/remove.js +18 -16
- package/cli/commands/secrets/secrets.js +3 -3
- package/cli/commands/secrets/set.d.ts +8 -6
- package/cli/commands/secrets/set.js +16 -33
- package/cli/commands/telemetry.d.ts +15 -0
- package/cli/commands/telemetry.js +17 -0
- package/cli/commands/transform.d.ts +15 -0
- package/cli/commands/transform.js +55 -0
- package/cli/commands/update.d.ts +6 -2
- package/cli/commands/update.js +41 -33
- package/cli/commands/version.d.ts +13 -0
- package/cli/commands/version.js +7 -0
- package/cli/local/router.d.ts +6 -6
- package/cli/local/router.js +3 -3
- package/cli/local/server.d.ts +5 -3
- package/cli/local/server.js +21 -14
- package/cli/program.d.ts +5 -1
- package/cli/program.js +29 -5
- package/cli/spinner.js +2 -0
- package/cli/sst.js +35 -23
- package/cli/telemetry/environment.d.ts +1 -1
- package/cli/telemetry/environment.js +1 -1
- package/cli/terminal.d.ts +1 -0
- package/cli/terminal.js +8 -0
- package/cli/ui/deploy.d.ts +3 -2
- package/cli/ui/deploy.js +106 -106
- package/cli/ui/functions.d.ts +2 -0
- package/cli/ui/functions.js +132 -0
- package/cli/ui/header.d.ts +5 -0
- package/cli/ui/header.js +16 -0
- package/cli/ui/stack.d.ts +1 -0
- package/cli/ui/stack.js +6 -0
- package/config.d.ts +1 -1
- package/config.js +8 -8
- package/constructs/Api.d.ts +3 -71
- package/constructs/Api.js +3 -42
- package/constructs/ApiGatewayV1Api.d.ts +3 -3
- package/constructs/ApiGatewayV1Api.js +4 -3
- package/constructs/App.d.ts +2 -22
- package/constructs/App.js +12 -25
- package/constructs/AppSyncApi.d.ts +4 -5
- package/constructs/AppSyncApi.js +8 -5
- package/constructs/AstroSite.d.ts +2 -3
- package/constructs/AstroSite.js +43 -53
- package/constructs/Auth.js +27 -16
- package/constructs/BaseSite.d.ts +10 -10
- package/constructs/BaseSite.js +2 -2
- package/constructs/Cognito.js +28 -28
- package/constructs/EdgeFunction.d.ts +6 -4
- package/constructs/EdgeFunction.js +56 -59
- package/constructs/EventBus.js +1 -1
- package/constructs/Function.d.ts +4 -44
- package/constructs/Function.js +14 -50
- package/constructs/FunctionalStack.d.ts +2 -2
- package/constructs/Job.d.ts +23 -63
- package/constructs/Job.js +11 -32
- package/constructs/Metadata.d.ts +18 -20
- package/constructs/NextjsSite.d.ts +21 -5
- package/constructs/NextjsSite.js +67 -101
- package/constructs/Queue.js +10 -10
- package/constructs/RDS.d.ts +1 -1
- package/constructs/RDS.js +1 -1
- package/constructs/RemixSite.d.ts +0 -2
- package/constructs/RemixSite.js +20 -20
- package/constructs/Script.js +1 -1
- package/constructs/Secret.js +5 -3
- package/constructs/SolidStartSite.d.ts +2 -3
- package/constructs/SolidStartSite.js +42 -52
- package/constructs/SsrFunction.d.ts +22 -0
- package/constructs/SsrFunction.js +113 -0
- package/constructs/SsrSite.d.ts +104 -104
- package/constructs/SsrSite.js +196 -217
- package/constructs/Stack.d.ts +1 -20
- package/constructs/Stack.js +3 -65
- package/constructs/StaticSite.d.ts +33 -53
- package/constructs/StaticSite.js +92 -118
- package/constructs/Table.d.ts +1 -1
- package/constructs/Table.js +4 -4
- package/constructs/Topic.js +1 -1
- package/constructs/cdk/certificate-base.d.ts +18 -0
- package/constructs/cdk/certificate-base.js +26 -0
- package/constructs/cdk/dns-validated-certificate.d.ts +77 -0
- package/constructs/cdk/dns-validated-certificate.js +125 -0
- package/constructs/cdk/website-redirect.d.ts +53 -0
- package/constructs/cdk/website-redirect.js +77 -0
- package/constructs/deferred_task.d.ts +1 -1
- package/constructs/deprecated/NextjsSite.js +8 -6
- package/constructs/index.d.ts +0 -6
- package/constructs/index.js +0 -6
- package/constructs/util/apiGatewayV1AccessLog.d.ts +1 -1
- package/constructs/util/apiGatewayV2AccessLog.js +4 -4
- package/constructs/util/apiGatewayV2Domain.js +9 -2
- package/constructs/util/appSyncApiDomain.d.ts +1 -1
- package/constructs/util/appSyncApiDomain.js +9 -15
- package/constructs/util/duration.d.ts +1 -1
- package/constructs/util/functionBinding.js +1 -1
- package/constructs/util/permission.d.ts +3 -3
- package/constructs/util/permission.js +16 -18
- package/constructs/util/size.d.ts +1 -1
- package/constructs/util/warning.js +2 -2
- package/context/context.d.ts +2 -2
- package/context/context.js +4 -4
- package/context/handler.d.ts +1 -1
- package/credentials.d.ts +1 -1
- package/credentials.js +42 -6
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/iot.js +6 -2
- package/logger.js +3 -1
- package/node/api/index.d.ts +4 -3
- package/node/api/index.js +8 -2
- package/node/auth/adapter/adapter.d.ts +1 -1
- package/node/auth/adapter/facebook.js +1 -1
- package/node/auth/adapter/github.js +4 -4
- package/node/auth/adapter/google.d.ts +1 -1
- package/node/auth/adapter/google.js +2 -2
- package/node/auth/adapter/twitch.js +1 -1
- package/node/auth/session.d.ts +1 -1
- package/node/config/index.d.ts +2 -2
- package/node/config/index.js +3 -8
- package/node/job/index.d.ts +2 -2
- package/node/site/index.js +3 -5
- package/package.json +26 -21
- package/pothos.js +1 -0
- package/project.d.ts +47 -0
- package/{app.js → project.js} +60 -53
- package/runtime/handlers/dotnet.d.ts +1 -1
- package/runtime/handlers/dotnet.js +4 -4
- package/runtime/handlers/go.d.ts +1 -1
- package/runtime/handlers/go.js +3 -3
- package/runtime/handlers/java.d.ts +1 -1
- package/runtime/handlers/java.js +4 -4
- package/runtime/handlers/node.d.ts +1 -1
- package/runtime/handlers/node.js +60 -39
- package/runtime/handlers/python.d.ts +1 -1
- package/runtime/handlers/python.js +3 -3
- package/runtime/handlers.js +15 -12
- package/runtime/iot.js +3 -0
- package/runtime/runtime.d.ts +4 -0
- package/runtime/server.d.ts +3 -3
- package/runtime/server.js +11 -5
- package/runtime/workers.d.ts +4 -2
- package/runtime/workers.js +13 -3
- package/site-env.js +2 -1
- package/sst.mjs +6357 -20846
- package/stacks/app-metadata.d.ts +7 -0
- package/stacks/app-metadata.js +78 -0
- package/stacks/assembly.d.ts +1 -0
- package/stacks/assembly.js +4 -0
- package/stacks/build.d.ts +1 -1
- package/stacks/build.js +41 -48
- package/stacks/deploy.d.ts +1 -0
- package/stacks/deploy.js +128 -7
- package/stacks/diff.d.ts +8 -0
- package/stacks/diff.js +62 -0
- package/stacks/index.d.ts +3 -0
- package/stacks/index.js +3 -0
- package/stacks/metadata.d.ts +2 -0
- package/stacks/metadata.js +14 -12
- package/stacks/monitor.d.ts +8 -3
- package/stacks/monitor.js +38 -4
- package/stacks/remove.js +0 -4
- package/stacks/synth.d.ts +1 -0
- package/stacks/synth.js +27 -13
- package/support/base-site-archiver.mjs +1 -1
- package/support/bootstrap-metadata-function/index.mjs +68740 -0
- package/support/bridge/bridge.mjs +28 -28
- package/support/certificate-requestor/index.js +549 -0
- package/support/custom-resources/index.mjs +3824 -26567
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +1 -1
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +1 -1
- package/support/edge-function/edge-lambda.mjs +2 -2
- package/support/job-invoker/index.mjs +26 -0
- package/support/nodejs-runtime/index.mjs +75 -72
- package/support/rds-migrator/index.mjs +22 -23
- package/support/remix-site-function/edge-server.js +1 -1
- package/support/script-function/index.mjs +30485 -0
- package/support/{edge-function-code-replacer → sls-nextjs-site-function-code-replacer}/lambda-code-updater.py +0 -0
- package/support/ssr-site-function-archiver.mjs +96 -0
- package/util/process.d.ts +0 -1
- package/watcher.js +1 -1
- package/app.d.ts +0 -36
- package/constructs/DebugApp.d.ts +0 -49
- package/constructs/DebugApp.js +0 -63
- package/constructs/DebugStack.d.ts +0 -34
- package/constructs/DebugStack.js +0 -132
- package/constructs/GraphQLApi.d.ts +0 -98
- package/constructs/GraphQLApi.js +0 -80
- package/constructs/ReactStaticSite.d.ts +0 -20
- package/constructs/ReactStaticSite.js +0 -54
- 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/constructs/ViteStaticSite.d.ts +0 -32
- package/constructs/ViteStaticSite.js +0 -66
- package/support/astro-site-html-stub/index.html +0 -99
- package/support/base-site-archiver.cjs +0 -116
- package/support/nextjs-site-html-stub/index.html +0 -99
- package/support/remix-site-html-stub/index.html +0 -99
- package/support/solid-start-site-html-stub/index.html +0 -99
- package/support/static-site-stub/index.html +0 -90
package/util/process.d.ts
CHANGED
package/watcher.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Context } from "./context/context.js";
|
|
|
2
2
|
import chokidar from "chokidar";
|
|
3
3
|
import { useBus } from "./bus.js";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { useProject } from "./
|
|
5
|
+
import { useProject } from "./project.js";
|
|
6
6
|
export const useWatcher = Context.memo(() => {
|
|
7
7
|
const project = useProject();
|
|
8
8
|
const bus = useBus();
|
package/app.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export interface Project {
|
|
2
|
-
name: string;
|
|
3
|
-
region: string;
|
|
4
|
-
stage?: string;
|
|
5
|
-
profile?: string;
|
|
6
|
-
main?: string;
|
|
7
|
-
ssmPrefix?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const DEFAULTS: {
|
|
10
|
-
readonly main: "stacks/index.ts";
|
|
11
|
-
readonly stage: undefined;
|
|
12
|
-
readonly ssmPrefix: undefined;
|
|
13
|
-
};
|
|
14
|
-
declare type ProjectWithDefaults = Project & Required<{
|
|
15
|
-
[key in keyof typeof DEFAULTS]: Exclude<Project[key], undefined>;
|
|
16
|
-
}> & {
|
|
17
|
-
version: string;
|
|
18
|
-
paths: {
|
|
19
|
-
root: string;
|
|
20
|
-
out: string;
|
|
21
|
-
artifacts: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export declare const ProjectContext: {
|
|
25
|
-
use(): ProjectWithDefaults;
|
|
26
|
-
provide(value: ProjectWithDefaults): void;
|
|
27
|
-
};
|
|
28
|
-
export declare function useProject(): ProjectWithDefaults;
|
|
29
|
-
interface GlobalOptions {
|
|
30
|
-
profile?: string;
|
|
31
|
-
stage?: string;
|
|
32
|
-
root?: string;
|
|
33
|
-
region?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare function initProject(globals: GlobalOptions): Promise<void>;
|
|
36
|
-
export {};
|
package/constructs/DebugApp.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { App, StageSynthesisOptions } from "aws-cdk-lib";
|
|
2
|
-
import { CloudAssembly } from "aws-cdk-lib/cx-api";
|
|
3
|
-
/**
|
|
4
|
-
* Deploy props for apps.
|
|
5
|
-
*/
|
|
6
|
-
export interface DebugAppDeployProps {
|
|
7
|
-
/**
|
|
8
|
-
* The app name, used to prefix stacks.
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
/**
|
|
12
|
-
* The stage to deploy this app to.
|
|
13
|
-
*/
|
|
14
|
-
stage: string;
|
|
15
|
-
/**
|
|
16
|
-
* The region to deploy this app to.
|
|
17
|
-
*/
|
|
18
|
-
region: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The DebugApp construct is used internally by SST to create the resources needed to power Live Lambda Development.
|
|
22
|
-
*/
|
|
23
|
-
export declare class DebugApp extends App {
|
|
24
|
-
/**
|
|
25
|
-
* The name of the app. This comes from the `name` in your `sst.json`.
|
|
26
|
-
*/
|
|
27
|
-
readonly name: string;
|
|
28
|
-
/**
|
|
29
|
-
* The stage the app is being deployed to. If this is not specified as the [`--stage`](/packages/sst.md#--stage) option, it'll default to the stage configured during the initial run of the SST CLI.
|
|
30
|
-
*/
|
|
31
|
-
readonly stage: string;
|
|
32
|
-
/**
|
|
33
|
-
* The region the app is being deployed to. If this is not specified as the [`--region`](/packages/sst.md#--region) option in the SST CLI, it'll default to the `region` in your `sst.json`.
|
|
34
|
-
*/
|
|
35
|
-
readonly region: string;
|
|
36
|
-
/**
|
|
37
|
-
* The AWS account the app is being deployed to. This comes from the IAM credentials being used to run the SST CLI.
|
|
38
|
-
*/
|
|
39
|
-
readonly account: string;
|
|
40
|
-
/**
|
|
41
|
-
* @internal
|
|
42
|
-
*/
|
|
43
|
-
constructor(deployProps: DebugAppDeployProps);
|
|
44
|
-
synth(options?: StageSynthesisOptions): CloudAssembly;
|
|
45
|
-
/**
|
|
46
|
-
* Use this method to prefix resource names in your stacks to make sure they don't thrash when deployed to different stages in the same AWS account. This method will prefix a given resource name with the stage and app name. Using the format `${stage}-${name}-${logicalName}`.
|
|
47
|
-
*/
|
|
48
|
-
logicalPrefixedName(logicalName: string): string;
|
|
49
|
-
}
|
package/constructs/DebugApp.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { App } from "aws-cdk-lib";
|
|
2
|
-
import { isStackConstruct, isSSTDebugStack } from "./Construct.js";
|
|
3
|
-
/**
|
|
4
|
-
* The DebugApp construct is used internally by SST to create the resources needed to power Live Lambda Development.
|
|
5
|
-
*/
|
|
6
|
-
export class DebugApp extends App {
|
|
7
|
-
/**
|
|
8
|
-
* The name of the app. This comes from the `name` in your `sst.json`.
|
|
9
|
-
*/
|
|
10
|
-
name;
|
|
11
|
-
/**
|
|
12
|
-
* The stage the app is being deployed to. If this is not specified as the [`--stage`](/packages/sst.md#--stage) option, it'll default to the stage configured during the initial run of the SST CLI.
|
|
13
|
-
*/
|
|
14
|
-
stage;
|
|
15
|
-
/**
|
|
16
|
-
* The region the app is being deployed to. If this is not specified as the [`--region`](/packages/sst.md#--region) option in the SST CLI, it'll default to the `region` in your `sst.json`.
|
|
17
|
-
*/
|
|
18
|
-
region;
|
|
19
|
-
/**
|
|
20
|
-
* The AWS account the app is being deployed to. This comes from the IAM credentials being used to run the SST CLI.
|
|
21
|
-
*/
|
|
22
|
-
account;
|
|
23
|
-
/**
|
|
24
|
-
* @internal
|
|
25
|
-
*/
|
|
26
|
-
constructor(deployProps) {
|
|
27
|
-
super();
|
|
28
|
-
this.name = deployProps.name;
|
|
29
|
-
this.stage = deployProps.stage;
|
|
30
|
-
this.region = deployProps.region;
|
|
31
|
-
this.account = process.env.CDK_DEFAULT_ACCOUNT || "my-account";
|
|
32
|
-
}
|
|
33
|
-
synth(options = {}) {
|
|
34
|
-
// Check app has stack
|
|
35
|
-
const stacks = this.node.children.filter((child) => isSSTDebugStack(child));
|
|
36
|
-
if (stacks.length > 1) {
|
|
37
|
-
console.error(`Error: You can only create 1 DebugStack inside the "debugApp()" callback.\n`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
if (stacks.length === 0) {
|
|
41
|
-
console.error(`Error: The "debugApp()" callback is not creating a DebugStack.\n`);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
for (const child of this.node.children) {
|
|
45
|
-
if (isStackConstruct(child)) {
|
|
46
|
-
// Stack names need to be parameterized with the stage name
|
|
47
|
-
if (!child.stackName.startsWith(`${this.stage}-`) &&
|
|
48
|
-
!child.stackName.endsWith(`-${this.stage}`) &&
|
|
49
|
-
child.stackName.indexOf(`-${this.stage}-`) === -1) {
|
|
50
|
-
console.error(`Error: Stack "${child.stackName}" is not parameterized with the stage name. The stack name needs to either start with "$stage-", end in "-$stage", or contain the stage name "-$stage-".\n`);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return super.synth(options);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Use this method to prefix resource names in your stacks to make sure they don't thrash when deployed to different stages in the same AWS account. This method will prefix a given resource name with the stage and app name. Using the format `${stage}-${name}-${logicalName}`.
|
|
59
|
-
*/
|
|
60
|
-
logicalPrefixedName(logicalName) {
|
|
61
|
-
return `${this.stage}-${this.name}-${logicalName}`;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import * as cdk from "aws-cdk-lib";
|
|
3
|
-
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
4
|
-
/**
|
|
5
|
-
* Stack properties for the DebugStack.
|
|
6
|
-
*/
|
|
7
|
-
export interface DebugStackProps extends cdk.StackProps {
|
|
8
|
-
/**
|
|
9
|
-
* S3 bucket to store large websocket payloads.
|
|
10
|
-
*/
|
|
11
|
-
payloadBucketArn?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Lambda function props for WebSocket request handlers.
|
|
14
|
-
*/
|
|
15
|
-
websocketHandlerRoleArn?: string;
|
|
16
|
-
cdk?: {
|
|
17
|
-
/**
|
|
18
|
-
* Override the settings of the internally created DynamoDB table
|
|
19
|
-
*/
|
|
20
|
-
table?: Omit<dynamodb.TableProps, "partitionKey" | "sortKey">;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* The `DebugStack` construct is used internally to create the resources needed to power Live Lambda Development. Note that, the `DebugStack` construct should only be created inside the [`DebugApp`](DebugApp).
|
|
25
|
-
*/
|
|
26
|
-
export declare class DebugStack extends cdk.Stack {
|
|
27
|
-
readonly stage: string;
|
|
28
|
-
private readonly api;
|
|
29
|
-
private readonly table;
|
|
30
|
-
private readonly bucket;
|
|
31
|
-
constructor(scope: Construct, id: string, props?: DebugStackProps);
|
|
32
|
-
private addApiRoute;
|
|
33
|
-
private static checkForEnvInProps;
|
|
34
|
-
}
|
package/constructs/DebugStack.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import url from "url";
|
|
3
|
-
import * as cdk from "aws-cdk-lib";
|
|
4
|
-
import * as s3 from "aws-cdk-lib/aws-s3";
|
|
5
|
-
import * as iam from "aws-cdk-lib/aws-iam";
|
|
6
|
-
import * as logs from "aws-cdk-lib/aws-logs";
|
|
7
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
8
|
-
import * as apig from "aws-cdk-lib/aws-apigatewayv2";
|
|
9
|
-
import * as dynamodb from "aws-cdk-lib/aws-dynamodb";
|
|
10
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
11
|
-
/**
|
|
12
|
-
* The `DebugStack` construct is used internally to create the resources needed to power Live Lambda Development. Note that, the `DebugStack` construct should only be created inside the [`DebugApp`](DebugApp).
|
|
13
|
-
*/
|
|
14
|
-
export class DebugStack extends cdk.Stack {
|
|
15
|
-
stage;
|
|
16
|
-
api;
|
|
17
|
-
table;
|
|
18
|
-
bucket;
|
|
19
|
-
constructor(scope, id, props) {
|
|
20
|
-
const app = scope.node.root;
|
|
21
|
-
const stackId = app.logicalPrefixedName(id);
|
|
22
|
-
DebugStack.checkForEnvInProps(id, props);
|
|
23
|
-
super(scope, stackId, {
|
|
24
|
-
...props,
|
|
25
|
-
env: {
|
|
26
|
-
account: app.account,
|
|
27
|
-
region: app.region,
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
this.stage = app.stage;
|
|
31
|
-
// Create connection table
|
|
32
|
-
this.table = new dynamodb.Table(this, "Table", {
|
|
33
|
-
partitionKey: { name: "pk", type: dynamodb.AttributeType.STRING },
|
|
34
|
-
billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
|
|
35
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
36
|
-
...props?.cdk?.table,
|
|
37
|
-
});
|
|
38
|
-
// Create S3 bucket for storing large payloads
|
|
39
|
-
this.bucket = props?.payloadBucketArn
|
|
40
|
-
? s3.Bucket.fromBucketArn(this, "Bucket", props.payloadBucketArn)
|
|
41
|
-
: new s3.Bucket(this, "Bucket", {
|
|
42
|
-
lifecycleRules: [
|
|
43
|
-
{
|
|
44
|
-
expiration: cdk.Duration.days(1),
|
|
45
|
-
prefix: "payloads/",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
encryption: s3.BucketEncryption.S3_MANAGED,
|
|
49
|
-
removalPolicy: cdk.RemovalPolicy.DESTROY,
|
|
50
|
-
autoDeleteObjects: true,
|
|
51
|
-
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL,
|
|
52
|
-
});
|
|
53
|
-
// Create API
|
|
54
|
-
this.api = new apig.CfnApi(this, "Api", {
|
|
55
|
-
name: `${this.stackName}-api`,
|
|
56
|
-
protocolType: "WEBSOCKET",
|
|
57
|
-
routeSelectionExpression: "$request.body.action",
|
|
58
|
-
});
|
|
59
|
-
new apig.CfnStage(this, "ApiStage", {
|
|
60
|
-
apiId: this.api.ref,
|
|
61
|
-
autoDeploy: true,
|
|
62
|
-
stageName: this.stage,
|
|
63
|
-
});
|
|
64
|
-
// Create API routes
|
|
65
|
-
const role = props?.websocketHandlerRoleArn
|
|
66
|
-
? iam.Role.fromRoleArn(this, "HandlerRole", props.websocketHandlerRoleArn)
|
|
67
|
-
: undefined;
|
|
68
|
-
this.addApiRoute("Connect", "$connect", "wsConnect.main", role);
|
|
69
|
-
this.addApiRoute("Disconnect", "$disconnect", "wsDisconnect.main", role);
|
|
70
|
-
this.addApiRoute("Default", "$default", "wsDefault.main", role);
|
|
71
|
-
// Stack Output
|
|
72
|
-
new cdk.CfnOutput(this, "Endpoint", {
|
|
73
|
-
value: `${this.api.attrApiEndpoint}/${this.stage}`,
|
|
74
|
-
});
|
|
75
|
-
new cdk.CfnOutput(this, "BucketArn", {
|
|
76
|
-
value: this.bucket.bucketArn,
|
|
77
|
-
});
|
|
78
|
-
new cdk.CfnOutput(this, "BucketName", {
|
|
79
|
-
value: this.bucket.bucketName,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
addApiRoute(id, routeKey, handler, role) {
|
|
83
|
-
// Create execution policy
|
|
84
|
-
const policyStatement = new iam.PolicyStatement();
|
|
85
|
-
policyStatement.addAllResources();
|
|
86
|
-
policyStatement.addActions("apigateway:*", "dynamodb:*", "execute-api:ManageConnections");
|
|
87
|
-
// Create Lambda
|
|
88
|
-
const lambdaFunc = new lambda.Function(this, id, {
|
|
89
|
-
code: lambda.Code.fromAsset(path.join(__dirname, "../assets/DebugStack")),
|
|
90
|
-
handler,
|
|
91
|
-
runtime: lambda.Runtime.NODEJS_16_X,
|
|
92
|
-
timeout: cdk.Duration.seconds(10),
|
|
93
|
-
memorySize: 256,
|
|
94
|
-
logRetention: logs.RetentionDays.ONE_WEEK,
|
|
95
|
-
logRetentionRole: role,
|
|
96
|
-
environment: {
|
|
97
|
-
TABLE_NAME: this.table.tableName,
|
|
98
|
-
},
|
|
99
|
-
role,
|
|
100
|
-
initialPolicy: [policyStatement],
|
|
101
|
-
});
|
|
102
|
-
lambdaFunc.addPermission(`${id}Permission`, {
|
|
103
|
-
principal: new iam.ServicePrincipal("apigateway.amazonaws.com"),
|
|
104
|
-
});
|
|
105
|
-
// Create API integrations
|
|
106
|
-
const integration = new apig.CfnIntegration(this, `${id}Integration`, {
|
|
107
|
-
apiId: this.api.ref,
|
|
108
|
-
integrationType: "AWS_PROXY",
|
|
109
|
-
integrationUri: `arn:${this.partition}:apigateway:${this.region}:lambda:path/2015-03-31/functions/${lambdaFunc.functionArn}/invocations`,
|
|
110
|
-
});
|
|
111
|
-
// Create API routes
|
|
112
|
-
new apig.CfnRoute(this, `${id}Route`, {
|
|
113
|
-
apiId: this.api.ref,
|
|
114
|
-
routeKey,
|
|
115
|
-
authorizationType: "NONE",
|
|
116
|
-
target: `integrations/${integration.ref}`,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
static checkForEnvInProps(id, props) {
|
|
121
|
-
if (props && props.env) {
|
|
122
|
-
let envS = "";
|
|
123
|
-
try {
|
|
124
|
-
envS = " (" + JSON.stringify(props.env) + ")";
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
// Ignore
|
|
128
|
-
}
|
|
129
|
-
throw new Error(`Do not set the "env" prop while initializing "${id}" stack${envS}. Use the "AWS_PROFILE" environment variable and "--region" CLI option instead.`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { HttpRouteIntegration } from "@aws-cdk/aws-apigatewayv2-alpha";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
import { Api, ApiFunctionRouteProps, ApiProps } from "./Api.js";
|
|
4
|
-
import { Function as Fn, FunctionDefinition } from "./Function.js";
|
|
5
|
-
export interface GraphQLApiProps extends Omit<ApiProps, "routes"> {
|
|
6
|
-
/**
|
|
7
|
-
* Path to graphql-codegen configuration file
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```js
|
|
11
|
-
* new GraphQLApi(stack, "api", {
|
|
12
|
-
* codegen: "./graphql/codegen.yml"
|
|
13
|
-
* })
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
codegen?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Path to function that will be invoked to resolve GraphQL queries.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* new GraphQLApi(stack, "api", {
|
|
23
|
-
* codegen: "./graphql/codegen.yml"
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
server: FunctionDefinition;
|
|
28
|
-
rootPath?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* The `GraphQLApi` construct is a higher level CDK construct that makes it easy to create GraphQL servers with AWS Lambda.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
*
|
|
35
|
-
* ```js
|
|
36
|
-
* import { GraphQLApi } from "@serverless-stack/resources";
|
|
37
|
-
*
|
|
38
|
-
* new GraphQLApi(stack, "Api", {
|
|
39
|
-
* server: "src/graphql.handler",
|
|
40
|
-
* });
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare class GraphQLApi extends Api {
|
|
44
|
-
private readonly codegen?;
|
|
45
|
-
private lambdaIntegration?;
|
|
46
|
-
private rootPath?;
|
|
47
|
-
constructor(scope: Construct, id: string, props: GraphQLApiProps);
|
|
48
|
-
get serverFunction(): Fn;
|
|
49
|
-
protected createFunctionIntegration(scope: Construct, routeKey: string, routeProps: ApiFunctionRouteProps<string>, postfixName: string): HttpRouteIntegration;
|
|
50
|
-
getConstructMetadata(): {
|
|
51
|
-
data: {
|
|
52
|
-
graphql: true;
|
|
53
|
-
codegen: string | undefined;
|
|
54
|
-
url: string | undefined;
|
|
55
|
-
httpApiId: string;
|
|
56
|
-
customDomainUrl: string | undefined;
|
|
57
|
-
routes: ({
|
|
58
|
-
type: "function";
|
|
59
|
-
route: string;
|
|
60
|
-
fn: {
|
|
61
|
-
node: string;
|
|
62
|
-
stack: string;
|
|
63
|
-
} | undefined;
|
|
64
|
-
schema?: undefined;
|
|
65
|
-
output?: undefined;
|
|
66
|
-
commands?: undefined;
|
|
67
|
-
} | {
|
|
68
|
-
type: "pothos";
|
|
69
|
-
route: string;
|
|
70
|
-
fn: {
|
|
71
|
-
node: string;
|
|
72
|
-
stack: string;
|
|
73
|
-
} | undefined;
|
|
74
|
-
schema: string | undefined;
|
|
75
|
-
output: string | undefined;
|
|
76
|
-
commands: string[] | undefined;
|
|
77
|
-
} | {
|
|
78
|
-
type: "graphql";
|
|
79
|
-
route: string;
|
|
80
|
-
fn: {
|
|
81
|
-
node: string;
|
|
82
|
-
stack: string;
|
|
83
|
-
} | undefined;
|
|
84
|
-
schema: string | undefined;
|
|
85
|
-
output: string | undefined;
|
|
86
|
-
commands: string[] | undefined;
|
|
87
|
-
} | {
|
|
88
|
-
type: "lambda_function" | "url" | "alb";
|
|
89
|
-
route: string;
|
|
90
|
-
fn?: undefined;
|
|
91
|
-
schema?: undefined;
|
|
92
|
-
output?: undefined;
|
|
93
|
-
commands?: undefined;
|
|
94
|
-
})[];
|
|
95
|
-
};
|
|
96
|
-
type: "Api";
|
|
97
|
-
};
|
|
98
|
-
}
|
package/constructs/GraphQLApi.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { App } from "./App.js";
|
|
2
|
-
import spawn from "cross-spawn";
|
|
3
|
-
import { Api } from "./Api.js";
|
|
4
|
-
/**
|
|
5
|
-
* The `GraphQLApi` construct is a higher level CDK construct that makes it easy to create GraphQL servers with AWS Lambda.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```js
|
|
10
|
-
* import { GraphQLApi } from "@serverless-stack/resources";
|
|
11
|
-
*
|
|
12
|
-
* new GraphQLApi(stack, "Api", {
|
|
13
|
-
* server: "src/graphql.handler",
|
|
14
|
-
* });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class GraphQLApi extends Api {
|
|
18
|
-
codegen;
|
|
19
|
-
lambdaIntegration;
|
|
20
|
-
rootPath;
|
|
21
|
-
constructor(scope, id, props) {
|
|
22
|
-
if ("routes" in props || !props.server) {
|
|
23
|
-
throw new Error(`Please use the "server" option instead of the "routes" to configure the handler for the "${id}" GraphQLApi`);
|
|
24
|
-
}
|
|
25
|
-
if (props.codegen) {
|
|
26
|
-
const app = App.of(scope);
|
|
27
|
-
if (!app.local) {
|
|
28
|
-
const result = spawn.sync("npx", ["graphql-codegen", "-c", props.codegen], {
|
|
29
|
-
stdio: "inherit",
|
|
30
|
-
});
|
|
31
|
-
if (result.status !== 0) {
|
|
32
|
-
throw new Error(`Failed to generate the schema for the "${id}" GraphQLApi`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const rootPath = props.rootPath || "/";
|
|
37
|
-
super(scope, id, {
|
|
38
|
-
...props,
|
|
39
|
-
routes: {
|
|
40
|
-
[`GET ${rootPath}`]: { function: props.server },
|
|
41
|
-
[`POST ${rootPath}`]: { function: props.server },
|
|
42
|
-
},
|
|
43
|
-
});
|
|
44
|
-
this.rootPath = rootPath;
|
|
45
|
-
this.codegen = props.codegen;
|
|
46
|
-
}
|
|
47
|
-
get serverFunction() {
|
|
48
|
-
const serverFn = this.getFunction(`GET ${this.rootPath}`);
|
|
49
|
-
// This should never happen
|
|
50
|
-
if (!serverFn) {
|
|
51
|
-
throw new Error(`Failed to get "serverFunction" in the "${this.node.id}" GraphQLApi`);
|
|
52
|
-
}
|
|
53
|
-
return serverFn;
|
|
54
|
-
}
|
|
55
|
-
// Note: We want to create 1 Lambda handling both the GET and POST request.
|
|
56
|
-
// This design is based on this discussion on GitHub
|
|
57
|
-
// https://github.com/serverless-stack/sst/issues/601
|
|
58
|
-
// Also Note: We cannot use the "ANY /" route because if authorization
|
|
59
|
-
// were provided, the OPTIONS route will be protected. This
|
|
60
|
-
// causes CORS to fail.
|
|
61
|
-
// Solution: We will override the createFunctionIntegration() function, and
|
|
62
|
-
// it will re-use the same Route Integration for all routes.
|
|
63
|
-
createFunctionIntegration(scope, routeKey, routeProps, postfixName) {
|
|
64
|
-
if (!this.lambdaIntegration) {
|
|
65
|
-
this.lambdaIntegration = super.createFunctionIntegration(scope, routeKey, routeProps, postfixName);
|
|
66
|
-
}
|
|
67
|
-
return this.lambdaIntegration;
|
|
68
|
-
}
|
|
69
|
-
getConstructMetadata() {
|
|
70
|
-
const parent = super.getConstructMetadata();
|
|
71
|
-
return {
|
|
72
|
-
...parent,
|
|
73
|
-
data: {
|
|
74
|
-
...parent.data,
|
|
75
|
-
graphql: true,
|
|
76
|
-
codegen: this.codegen,
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { StaticSite, StaticSiteProps } from "./StaticSite.js";
|
|
3
|
-
import { SSTConstruct } from "./Construct.js";
|
|
4
|
-
export declare type ReactStaticSiteProps = StaticSiteProps;
|
|
5
|
-
/**
|
|
6
|
-
* The `ReactStaticSite` construct is a higher level CDK construct that makes it easy to create a React single page app.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* Deploys a Create React App in the `path/to/src` directory.
|
|
11
|
-
*
|
|
12
|
-
* ```js
|
|
13
|
-
* new ReactStaticSite(stack, "ReactSite", {
|
|
14
|
-
* path: "path/to/src",
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export declare class ReactStaticSite extends StaticSite implements SSTConstruct {
|
|
19
|
-
constructor(scope: Construct, id: string, props: ReactStaticSiteProps);
|
|
20
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { StaticSite } from "./StaticSite.js";
|
|
4
|
-
/////////////////////
|
|
5
|
-
// Construct
|
|
6
|
-
/////////////////////
|
|
7
|
-
/**
|
|
8
|
-
* The `ReactStaticSite` construct is a higher level CDK construct that makes it easy to create a React single page app.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* Deploys a Create React App in the `path/to/src` directory.
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* new ReactStaticSite(stack, "ReactSite", {
|
|
16
|
-
* path: "path/to/src",
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class ReactStaticSite extends StaticSite {
|
|
21
|
-
constructor(scope, id, props) {
|
|
22
|
-
const { path: sitePath, environment } = props || {};
|
|
23
|
-
// Validate environment
|
|
24
|
-
Object.keys(environment || {}).forEach((key) => {
|
|
25
|
-
if (!key.startsWith("REACT_APP_")) {
|
|
26
|
-
throw new Error(`Environment variables in the "${id}" ReactStaticSite must start with "REACT_APP_".`);
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
// generate buildCommand
|
|
30
|
-
let defaultBuildCommand = "npm run build";
|
|
31
|
-
if (fs.existsSync(path.join(sitePath, "yarn.lock"))) {
|
|
32
|
-
defaultBuildCommand = "yarn build";
|
|
33
|
-
}
|
|
34
|
-
super(scope, id, {
|
|
35
|
-
indexPage: "index.html",
|
|
36
|
-
errorPage: "redirect_to_index_page",
|
|
37
|
-
buildCommand: defaultBuildCommand,
|
|
38
|
-
buildOutput: "build",
|
|
39
|
-
fileOptions: [
|
|
40
|
-
{
|
|
41
|
-
exclude: "*",
|
|
42
|
-
include: "*.html",
|
|
43
|
-
cacheControl: "max-age=0,no-cache,no-store,must-revalidate",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
exclude: "*",
|
|
47
|
-
include: ["*.js", "*.css"],
|
|
48
|
-
cacheControl: "max-age=31536000,public,immutable",
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
...props,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export declare const CREATE_FAILED_PHYSICAL_ID_MARKER = "AWSCDK::CustomResourceProviderFramework::CREATE_FAILED";
|
|
2
|
-
export declare const MISSING_PHYSICAL_ID_MARKER = "AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID";
|
|
3
|
-
export interface CloudFormationResponseOptions {
|
|
4
|
-
readonly reason?: string;
|
|
5
|
-
readonly noEcho?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface CloudFormationEventContext {
|
|
8
|
-
StackId: string;
|
|
9
|
-
RequestId: string;
|
|
10
|
-
PhysicalResourceId?: string;
|
|
11
|
-
LogicalResourceId: string;
|
|
12
|
-
ResponseURL: string;
|
|
13
|
-
Data?: any;
|
|
14
|
-
}
|
|
15
|
-
export declare function submitResponse(status: "SUCCESS" | "FAILED", event: CloudFormationEventContext, options?: CloudFormationResponseOptions): Promise<void>;
|
|
16
|
-
export declare const includeStackTraces = true;
|
|
17
|
-
export declare function safeHandler(block: (event: any) => Promise<void>): (event: any) => Promise<void>;
|
|
18
|
-
export declare class Retry extends Error {
|
|
19
|
-
}
|