sst 1.16.0 → 2.0.0-rc.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/LICENSE +21 -0
- package/{dist/app.d.ts → app.d.ts} +8 -1
- package/app.js +122 -0
- package/{dist/bootstrap.d.ts → bootstrap.d.ts} +1 -0
- package/bootstrap.js +79 -0
- package/{dist/bus.d.ts → bus.d.ts} +0 -0
- package/{dist/bus.js → bus.js} +0 -0
- package/{dist/cache.d.ts → cache.d.ts} +0 -0
- package/{dist/cache.js → cache.js} +0 -0
- package/{dist/cdk → cdk}/cloudformation-deployments.d.ts +1 -1
- package/{dist/cdk → cdk}/cloudformation-deployments.js +1 -0
- package/{dist/cdk → cdk}/deploy-stack.d.ts +0 -0
- package/{dist/cdk → cdk}/deploy-stack.js +13 -6
- package/{dist/cli → cli}/commands/bind.d.ts +3 -1
- package/{dist/cli → cli}/commands/bind.js +8 -4
- package/{dist/cli → cli}/commands/build.d.ts +2 -0
- package/cli/commands/build.js +12 -0
- package/cli/commands/console.d.ts +9 -0
- package/cli/commands/console.js +15 -0
- package/{dist/cli → cli}/commands/deploy.d.ts +7 -1
- package/cli/commands/deploy.js +48 -0
- package/cli/commands/dev.d.ts +11 -0
- package/cli/commands/dev.js +188 -0
- package/cli/commands/env.d.ts +11 -0
- package/cli/commands/env.js +39 -0
- package/cli/commands/plugins/kysely.d.ts +1 -0
- package/cli/commands/plugins/kysely.js +91 -0
- package/cli/commands/plugins/pothos.d.ts +1 -0
- package/cli/commands/plugins/pothos.js +52 -0
- package/cli/commands/plugins/warmer.d.ts +1 -0
- package/cli/commands/plugins/warmer.js +33 -0
- package/cli/commands/remove.d.ts +13 -0
- package/cli/commands/remove.js +39 -0
- package/{dist/cli → cli}/commands/secrets/get.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/get.js +0 -0
- package/{dist/cli → cli}/commands/secrets/list.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/list.js +5 -5
- package/{dist/cli → cli}/commands/secrets/remove.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/remove.js +0 -0
- package/{dist/cli → cli}/commands/secrets/secrets.d.ts +0 -0
- package/{dist/cli → cli}/commands/secrets/secrets.js +0 -0
- package/{dist/cli → cli}/commands/secrets/set.d.ts +2 -0
- package/{dist/cli → cli}/commands/secrets/set.js +13 -11
- package/{dist/cli → cli}/commands/update.d.ts +2 -0
- package/{dist/cli → cli}/commands/update.js +17 -21
- package/cli/local/router.d.ts +42 -0
- package/cli/local/router.js +43 -0
- package/cli/local/server.d.ts +20 -0
- package/cli/local/server.js +212 -0
- package/cli/program.d.ts +9 -0
- package/{dist/cli → cli}/program.js +6 -1
- package/{dist/cli → cli}/spinner.d.ts +0 -0
- package/{dist/cli → cli}/spinner.js +0 -0
- package/cli/sst.d.ts +2 -0
- package/{dist/cli → cli}/sst.js +27 -16
- package/cli/telemetry/environment.d.ts +15 -0
- package/cli/telemetry/environment.js +27 -0
- package/cli/telemetry/post-payload.d.ts +1 -0
- package/cli/telemetry/post-payload.js +18 -0
- package/cli/telemetry/project-id.d.ts +2 -0
- package/cli/telemetry/project-id.js +47 -0
- package/cli/telemetry/telemetry.d.ts +4 -0
- package/cli/telemetry/telemetry.js +90 -0
- package/cli/ui/deploy.d.ts +8 -0
- package/{dist/cli → cli}/ui/deploy.js +39 -1
- package/{dist/config.d.ts → config.d.ts} +0 -0
- package/{dist/config.js → config.js} +16 -4
- package/{dist/constructs → constructs}/Api.d.ts +98 -12
- package/{dist/constructs → constructs}/Api.js +93 -7
- package/{dist/constructs → constructs}/ApiGatewayV1Api.d.ts +0 -0
- package/{dist/constructs → constructs}/ApiGatewayV1Api.js +10 -5
- package/{dist/constructs → constructs}/App.d.ts +4 -26
- package/{dist/constructs → constructs}/App.js +119 -99
- package/{dist/constructs → constructs}/AppSyncApi.d.ts +3 -3
- package/{dist/constructs → constructs}/AppSyncApi.js +27 -20
- package/constructs/AstroSite.d.ts +25 -0
- package/constructs/AstroSite.js +111 -0
- package/constructs/AstroSite.tsdoc.d.ts +2 -0
- package/constructs/AstroSite.tsdoc.js +2 -0
- package/{dist/constructs → constructs}/Auth.d.ts +1 -1
- package/{dist/constructs → constructs}/Auth.js +6 -4
- package/{dist/constructs → constructs}/BaseSite.d.ts +0 -0
- package/{dist/constructs → constructs}/BaseSite.js +0 -0
- package/{dist/constructs → constructs}/Bucket.d.ts +0 -0
- package/{dist/constructs → constructs}/Bucket.js +6 -3
- package/{dist/constructs → constructs}/Cognito.d.ts +0 -0
- package/{dist/constructs → constructs}/Cognito.js +4 -1
- package/{dist/constructs → constructs}/Config.d.ts +0 -0
- package/{dist/constructs → constructs}/Config.js +0 -0
- package/{dist/constructs → constructs}/Construct.d.ts +0 -0
- package/{dist/constructs → constructs}/Construct.js +0 -0
- package/{dist/constructs → constructs}/Cron.d.ts +0 -0
- package/{dist/constructs → constructs}/Cron.js +7 -0
- package/{dist/constructs → constructs}/DebugApp.d.ts +2 -2
- package/{dist/constructs → constructs}/DebugApp.js +16 -0
- package/{dist/constructs → constructs}/DebugStack.d.ts +0 -0
- package/{dist/constructs → constructs}/DebugStack.js +4 -0
- package/{dist/constructs → constructs}/EdgeFunction.d.ts +1 -0
- package/{dist/constructs → constructs}/EdgeFunction.js +27 -22
- package/{dist/constructs → constructs}/EventBus.d.ts +0 -0
- package/{dist/constructs → constructs}/EventBus.js +7 -4
- package/{dist/constructs → constructs}/Function.d.ts +73 -174
- package/{dist/constructs → constructs}/Function.js +43 -83
- package/{dist/constructs → constructs}/FunctionalStack.d.ts +0 -0
- package/{dist/constructs → constructs}/FunctionalStack.js +5 -5
- package/{dist/constructs → constructs}/GraphQLApi.d.ts +11 -1
- package/{dist/constructs → constructs}/GraphQLApi.js +3 -0
- package/{dist/constructs → constructs}/Job.d.ts +0 -14
- package/{dist/constructs → constructs}/Job.js +50 -46
- package/{dist/constructs → constructs}/KinesisStream.d.ts +0 -0
- package/{dist/constructs → constructs}/KinesisStream.js +6 -3
- package/{dist/constructs → constructs}/Metadata.d.ts +1 -1
- package/{dist/constructs → constructs}/Metadata.js +0 -0
- package/constructs/NextjsSite.d.ts +33 -0
- package/constructs/NextjsSite.js +285 -0
- package/{dist/constructs → constructs}/Parameter.d.ts +0 -0
- package/{dist/constructs → constructs}/Parameter.js +3 -0
- package/{dist/constructs → constructs}/Queue.d.ts +0 -0
- package/{dist/constructs → constructs}/Queue.js +19 -12
- package/{dist/constructs → constructs}/RDS.d.ts +0 -0
- package/{dist/constructs → constructs}/RDS.js +26 -19
- package/{dist/constructs → constructs}/ReactStaticSite.d.ts +0 -0
- package/{dist/constructs → constructs}/ReactStaticSite.js +1 -1
- package/constructs/RemixSite.d.ts +28 -0
- package/constructs/RemixSite.js +150 -0
- package/constructs/RemixSite.tsdoc.d.ts +2 -0
- package/constructs/RemixSite.tsdoc.js +2 -0
- package/{dist/constructs → constructs}/Script/cfn-response.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/cfn-response.js +0 -0
- package/{dist/constructs → constructs}/Script/index.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/index.js +0 -0
- package/{dist/constructs → constructs}/Script/outbound.d.ts +1 -1
- package/{dist/constructs → constructs}/Script/outbound.js +0 -0
- package/{dist/constructs → constructs}/Script/util.d.ts +0 -0
- package/{dist/constructs → constructs}/Script/util.js +0 -0
- package/{dist/constructs → constructs}/Script.d.ts +0 -0
- package/{dist/constructs → constructs}/Script.js +13 -0
- package/{dist/constructs → constructs}/Secret.d.ts +0 -0
- package/{dist/constructs → constructs}/Secret.js +2 -0
- package/constructs/SolidStartSite.d.ts +24 -0
- package/constructs/SolidStartSite.js +103 -0
- package/constructs/SolidStartSite.tsdoc.d.ts +2 -0
- package/constructs/SolidStartSite.tsdoc.js +2 -0
- package/{dist/constructs/RemixSite.d.ts → constructs/SsrSite.d.ts} +69 -107
- package/{dist/constructs/RemixSite.js → constructs/SsrSite.js} +243 -446
- package/{dist/constructs → constructs}/Stack.d.ts +1 -1
- package/{dist/constructs → constructs}/Stack.js +19 -4
- package/{dist/constructs → constructs}/StaticSite.d.ts +44 -17
- package/{dist/constructs → constructs}/StaticSite.js +121 -72
- package/{dist/constructs → constructs}/Table.d.ts +0 -0
- package/{dist/constructs → constructs}/Table.js +9 -3
- package/{dist/constructs → constructs}/Topic.d.ts +0 -0
- package/{dist/constructs → constructs}/Topic.js +6 -3
- package/{dist/constructs → constructs}/ViteStaticSite.d.ts +0 -0
- package/{dist/constructs → constructs}/ViteStaticSite.js +2 -2
- package/{dist/constructs → constructs}/WebSocketApi.d.ts +0 -0
- package/{dist/constructs → constructs}/WebSocketApi.js +9 -4
- package/{dist/constructs → constructs}/context.d.ts +1 -1
- package/{dist/constructs → constructs}/context.js +0 -0
- package/{dist/constructs → constructs}/deferred_task.d.ts +0 -0
- package/{dist/constructs → constructs}/deferred_task.js +4 -2
- package/{dist/constructs → constructs/deprecated}/NextjsSite.d.ts +12 -8
- package/{dist/constructs → constructs/deprecated}/NextjsSite.js +112 -89
- package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.d.ts +0 -0
- package/{dist/constructs/nextjs-site → constructs/deprecated}/cross-region-helper.js +3 -3
- package/constructs/deprecated/index.d.ts +1 -0
- package/constructs/deprecated/index.js +1 -0
- package/{dist/constructs → constructs}/index.d.ts +3 -2
- package/{dist/constructs → constructs}/index.js +2 -0
- package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV1AccessLog.js +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2AccessLog.js +4 -4
- package/{dist/constructs → constructs}/util/apiGatewayV2Cors.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Cors.js +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Domain.d.ts +0 -0
- package/{dist/constructs → constructs}/util/apiGatewayV2Domain.js +0 -0
- package/{dist/constructs → constructs}/util/appSyncApiDomain.d.ts +1 -1
- package/{dist/constructs → constructs}/util/appSyncApiDomain.js +15 -9
- package/{dist/constructs → constructs}/util/builder.d.ts +0 -0
- package/{dist/constructs → constructs}/util/builder.js +0 -0
- package/{dist/constructs → constructs}/util/duration.d.ts +0 -0
- package/{dist/constructs → constructs}/util/duration.js +0 -0
- package/{dist/constructs → constructs}/util/functionBinding.d.ts +0 -0
- package/{dist/constructs → constructs}/util/functionBinding.js +0 -0
- package/{dist/constructs → constructs}/util/functionUrlCors.d.ts +0 -0
- package/{dist/constructs → constructs}/util/functionUrlCors.js +0 -0
- package/{dist/constructs → constructs}/util/permission.d.ts +0 -0
- package/{dist/constructs → constructs}/util/permission.js +32 -16
- package/{dist/constructs → constructs}/util/python/bundling.d.ts +0 -0
- package/{dist/constructs → constructs}/util/python/bundling.js +0 -0
- package/{dist/constructs → constructs}/util/size.d.ts +0 -0
- package/{dist/constructs → constructs}/util/size.js +0 -0
- package/{dist/constructs → constructs}/util/warning.d.ts +0 -0
- package/{dist/constructs → constructs}/util/warning.js +0 -0
- package/{dist/context → context}/context.d.ts +1 -1
- package/{dist/context → context}/context.js +3 -4
- package/{dist/context → context}/handler.d.ts +0 -0
- package/{dist/context → context}/handler.js +1 -1
- package/{dist/context → context}/index.d.ts +0 -0
- package/{dist/context → context}/index.js +0 -0
- package/{dist/credentials.d.ts → credentials.d.ts} +3 -1
- package/{dist/credentials.js → credentials.js} +11 -3
- package/{dist/error.d.ts → error.d.ts} +0 -0
- package/{dist/error.js → error.js} +0 -0
- package/{dist/iot.d.ts → iot.d.ts} +0 -0
- package/{dist/iot.js → iot.js} +3 -0
- package/logger.d.ts +3 -0
- package/{dist/logger.js → logger.js} +12 -8
- package/node/api/index.d.ts +42 -0
- package/node/api/index.js +88 -0
- package/node/auth/adapter/adapter.d.ts +3 -0
- package/node/auth/adapter/adapter.js +3 -0
- package/node/auth/adapter/facebook.d.ts +2 -0
- package/node/auth/adapter/facebook.js +26 -0
- package/node/auth/adapter/github.d.ts +2 -0
- package/node/auth/adapter/github.js +21 -0
- package/node/auth/adapter/google.d.ts +9 -0
- package/node/auth/adapter/google.js +18 -0
- package/node/auth/adapter/link.d.ts +8 -0
- package/node/auth/adapter/link.js +39 -0
- package/node/auth/adapter/oauth.d.ts +25 -0
- package/node/auth/adapter/oauth.js +52 -0
- package/node/auth/adapter/oidc.d.ts +17 -0
- package/node/auth/adapter/oidc.js +50 -0
- package/node/auth/adapter/twitch.d.ts +2 -0
- package/node/auth/adapter/twitch.js +11 -0
- package/node/auth/auth.d.ts +24 -0
- package/node/auth/auth.js +118 -0
- package/node/auth/index.d.ts +10 -0
- package/node/auth/index.js +10 -0
- package/node/auth/session.d.ts +76 -0
- package/node/auth/session.js +109 -0
- package/node/bucket/index.d.ts +3 -0
- package/node/bucket/index.js +3 -0
- package/node/config/index.d.ts +13 -0
- package/node/config/index.js +88 -0
- package/node/event-bus/index.d.ts +3 -0
- package/node/event-bus/index.js +3 -0
- package/node/function/index.d.ts +3 -0
- package/node/function/index.js +3 -0
- package/node/graphql/index.d.ts +38 -0
- package/node/graphql/index.js +48 -0
- package/node/job/index.d.ts +34 -0
- package/node/job/index.js +51 -0
- package/node/kinesis-stream/index.d.ts +3 -0
- package/node/kinesis-stream/index.js +3 -0
- package/node/queue/index.d.ts +3 -0
- package/node/queue/index.js +3 -0
- package/node/rds/index.d.ts +3 -0
- package/node/rds/index.js +3 -0
- package/node/site/index.d.ts +15 -0
- package/node/site/index.js +64 -0
- package/node/table/index.d.ts +3 -0
- package/node/table/index.js +3 -0
- package/node/topic/index.d.ts +3 -0
- package/node/topic/index.js +3 -0
- package/node/util/index.d.ts +7 -0
- package/node/util/index.js +57 -0
- package/package.json +107 -40
- package/pothos.d.ts +8 -0
- package/pothos.js +156 -0
- package/runtime/handlers/dotnet.d.ts +1 -0
- package/runtime/handlers/dotnet.js +117 -0
- package/runtime/handlers/go.d.ts +1 -0
- package/runtime/handlers/go.js +105 -0
- package/runtime/handlers/java.d.ts +1 -0
- package/runtime/handlers/java.js +97 -0
- package/{dist/runtime → runtime/handlers}/node.d.ts +0 -0
- package/runtime/handlers/node.js +172 -0
- package/runtime/handlers/python.d.ts +1 -0
- package/runtime/handlers/python.js +89 -0
- package/{dist/runtime → runtime}/handlers.d.ts +30 -12
- package/runtime/handlers.js +117 -0
- package/{dist/runtime → runtime}/iot.d.ts +0 -0
- package/{dist/runtime → runtime}/iot.js +1 -1
- package/{dist/runtime → runtime}/runtime.d.ts +2 -0
- package/{dist/runtime → runtime}/runtime.js +0 -0
- package/{dist/runtime → runtime}/server.d.ts +0 -0
- package/{dist/runtime → runtime}/server.js +39 -3
- package/{dist/runtime → runtime}/workers.d.ts +1 -0
- package/{dist/runtime → runtime}/workers.js +12 -4
- package/{dist/cli/sst.d.ts → scrap.d.ts} +0 -0
- package/scrap.js +58 -0
- package/site-env.d.ts +13 -0
- package/site-env.js +47 -0
- package/sst.mjs +21848 -0
- package/{dist/stacks → stacks}/build.d.ts +0 -0
- package/{dist/stacks → stacks}/build.js +18 -9
- package/stacks/deploy.d.ts +8 -0
- package/stacks/deploy.js +105 -0
- package/stacks/index.d.ts +7 -0
- package/stacks/index.js +7 -0
- package/stacks/metadata.d.ts +9 -0
- package/{dist/stacks → stacks}/metadata.js +2 -14
- package/stacks/monitor.d.ts +27 -0
- package/stacks/monitor.js +111 -0
- package/stacks/remove.d.ts +8 -0
- package/stacks/remove.js +80 -0
- package/stacks/synth.d.ts +10 -0
- package/stacks/synth.js +77 -0
- package/support/astro-site-html-stub/index.html +99 -0
- package/support/base-site-archiver.cjs +12 -11
- package/support/base-site-archiver.mjs +20 -0
- package/support/bridge/bridge.mjs +59 -0
- package/{dist/support → support}/custom-resources/index.mjs +44209 -42781
- package/support/dotnet31-bootstrap/Program.cs +17 -0
- package/support/dotnet31-bootstrap/dotnet-bootstrap.csproj +12 -0
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet31-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Encodings.Web.dll +0 -0
- package/support/dotnet31-bootstrap/release/System.Text.Json.dll +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.deps.json +230 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.dll +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.pdb +0 -0
- package/support/dotnet31-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +9 -0
- package/support/dotnet6-bootstrap/Program.cs +17 -0
- package/support/dotnet6-bootstrap/dotnet-bootstrap.csproj +12 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.Core.dll +0 -0
- package/support/dotnet6-bootstrap/release/Amazon.Lambda.RuntimeSupport.dll +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.deps.json +59 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.dll +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.pdb +0 -0
- package/support/dotnet6-bootstrap/release/dotnet-bootstrap.runtimeconfig.json +12 -0
- package/support/edge-function/edge-lambda-version.mjs +3 -0
- package/support/edge-function/edge-lambda.mjs +3 -0
- package/support/edge-function/s3-bucket.mjs +3 -0
- package/{dist/support/base-site-custom-resource/cf-invalidate.py → support/edge-function-code-replacer/lambda-code-updater.py} +56 -30
- package/support/java-runtime/install.sh +25 -0
- package/support/java-runtime/pom.xml +39 -0
- package/support/java-runtime/release/aws-lambda-java-core-1.2.0.jar +0 -0
- package/support/java-runtime/release/aws-lambda-java-runtime-interface-client-1.1.0.jar +0 -0
- package/support/java-runtime/release/aws-lambda-java-serialization-1.0.0.jar +0 -0
- package/support/nextjs-site-html-stub/index.html +99 -0
- package/{dist/support → support}/nodejs-runtime/index.mjs +7822 -2771
- package/support/python-runtime/runtime.py +116 -0
- package/support/rds-migrator/index.mjs +28 -0
- package/support/remix-site-function/edge-server.js +158 -0
- package/support/remix-site-function/polyfill.js +24 -0
- package/support/remix-site-function/regional-server.js +162 -0
- package/support/remix-site-html-stub/index.html +99 -0
- package/support/sls-nextjs-site-build-helper/build.cjs +91 -0
- package/support/sls-nextjs-site-build-helper/index-wrapper.js +19 -0
- package/support/sls-nextjs-site-stub/index.html +99 -0
- package/support/solid-start-site-html-stub/index.html +99 -0
- package/support/ssr-site-function-stub/index.js +5 -0
- package/util/fs.d.ts +4 -0
- package/util/fs.js +46 -0
- package/util/module.d.ts +1 -0
- package/util/module.js +5 -0
- package/util/process.d.ts +2 -0
- package/util/process.js +3 -0
- package/{dist/watcher.d.ts → watcher.d.ts} +0 -0
- package/{dist/watcher.js → watcher.js} +1 -1
- package/.build/sst-debug.log +0 -10
- package/.turbo/turbo-build.log +0 -2
- package/CHANGELOG.md +0 -332
- package/analyze +0 -11090
- package/bin/sst.mjs +0 -3
- package/build.mjs +0 -116
- package/debug.log +0 -6
- package/dist/app.js +0 -92
- package/dist/bootstrap.js +0 -23
- package/dist/cli/commands/build.js +0 -8
- package/dist/cli/commands/deploy.js +0 -20
- package/dist/cli/commands/env.d.ts +0 -0
- package/dist/cli/commands/env.js +0 -1
- package/dist/cli/commands/scrap.d.ts +0 -5
- package/dist/cli/commands/scrap.js +0 -1
- package/dist/cli/commands/start.d.ts +0 -7
- package/dist/cli/commands/start.js +0 -136
- package/dist/cli/program.d.ts +0 -7
- package/dist/cli/ui/deploy.d.ts +0 -6
- package/dist/constructs/nextjs-site/custom-resource/cfn-response.d.ts +0 -19
- package/dist/constructs/nextjs-site/custom-resource/cfn-response.js +0 -94
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda-version.js +0 -138
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/edge-lambda.js +0 -136
- package/dist/constructs/nextjs-site/custom-resource/s3-bucket.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/s3-bucket.js +0 -94
- package/dist/constructs/nextjs-site/custom-resource/util.d.ts +0 -1
- package/dist/constructs/nextjs-site/custom-resource/util.js +0 -4
- package/dist/logger.d.ts +0 -9
- package/dist/runtime/handlers.js +0 -72
- package/dist/runtime/node.js +0 -99
- package/dist/sst.mjs +0 -164202
- package/dist/stacks/deploy.d.ts +0 -33
- package/dist/stacks/deploy.js +0 -168
- package/dist/stacks/index.d.ts +0 -21
- package/dist/stacks/index.js +0 -57
- package/dist/stacks/metadata.d.ts +0 -9
- package/dist/support/base-site-archiver.cjs +0 -115
- package/dist/support/base-site-custom-resource/s3-handler.py +0 -195
- package/dist/support/base-site-custom-resource/s3-upload.py +0 -91
- package/dist/support/bridge/bridge.mjs +0 -86
- package/dist/support/static-site-stub/index.html +0 -90
- package/src/app.ts +0 -140
- package/src/bootstrap.ts +0 -28
- package/src/bus.ts +0 -81
- package/src/cache.ts +0 -34
- package/src/cdk/cloudformation-deployments.ts +0 -730
- package/src/cdk/deploy-stack.ts +0 -1030
- package/src/cli/commands/bind.ts +0 -31
- package/src/cli/commands/build.ts +0 -16
- package/src/cli/commands/deploy.ts +0 -34
- package/src/cli/commands/env.ts +0 -0
- package/src/cli/commands/scrap.ts +0 -5
- package/src/cli/commands/secrets/get.ts +0 -50
- package/src/cli/commands/secrets/list.ts +0 -66
- package/src/cli/commands/secrets/remove.ts +0 -36
- package/src/cli/commands/secrets/secrets.ts +0 -17
- package/src/cli/commands/secrets/set.ts +0 -59
- package/src/cli/commands/start.tsx +0 -162
- package/src/cli/commands/update.ts +0 -100
- package/src/cli/program.ts +0 -22
- package/src/cli/spinner.ts +0 -14
- package/src/cli/sst.ts +0 -50
- package/src/cli/ui/deploy.tsx +0 -139
- package/src/config.ts +0 -226
- package/src/constructs/Api.ts +0 -1448
- package/src/constructs/ApiGatewayV1Api.ts +0 -1481
- package/src/constructs/App.ts +0 -744
- package/src/constructs/AppSyncApi.ts +0 -1045
- package/src/constructs/Auth.ts +0 -252
- package/src/constructs/BaseSite.ts +0 -146
- package/src/constructs/Bucket.ts +0 -670
- package/src/constructs/Cognito.ts +0 -708
- package/src/constructs/Config.ts +0 -4
- package/src/constructs/Construct.ts +0 -77
- package/src/constructs/Cron.ts +0 -235
- package/src/constructs/DebugApp.ts +0 -97
- package/src/constructs/DebugStack.ts +0 -182
- package/src/constructs/EdgeFunction.ts +0 -460
- package/src/constructs/EventBus.ts +0 -651
- package/src/constructs/Function.ts +0 -1329
- package/src/constructs/FunctionalStack.ts +0 -90
- package/src/constructs/GraphQLApi.ts +0 -140
- package/src/constructs/Job.ts +0 -557
- package/src/constructs/KinesisStream.ts +0 -388
- package/src/constructs/Metadata.ts +0 -75
- package/src/constructs/NextjsSite.ts +0 -1498
- package/src/constructs/Parameter.ts +0 -72
- package/src/constructs/Queue.ts +0 -360
- package/src/constructs/RDS.ts +0 -578
- package/src/constructs/ReactStaticSite.ts +0 -66
- package/src/constructs/RemixSite.ts +0 -1397
- package/src/constructs/Script/cfn-response.ts +0 -116
- package/src/constructs/Script/index.ts +0 -103
- package/src/constructs/Script/outbound.ts +0 -59
- package/src/constructs/Script/package.json +0 -3
- package/src/constructs/Script/util.ts +0 -19
- package/src/constructs/Script.ts +0 -270
- package/src/constructs/Secret.ts +0 -66
- package/src/constructs/Stack.ts +0 -319
- package/src/constructs/StaticSite.ts +0 -995
- package/src/constructs/Table.ts +0 -844
- package/src/constructs/Topic.ts +0 -486
- package/src/constructs/ViteStaticSite.ts +0 -99
- package/src/constructs/WebSocketApi.ts +0 -687
- package/src/constructs/context.ts +0 -12
- package/src/constructs/deferred_task.ts +0 -53
- package/src/constructs/descs.d.ts +0 -1
- package/src/constructs/index.ts +0 -39
- package/src/constructs/nextjs-site/cross-region-helper.ts +0 -189
- package/src/constructs/nextjs-site/custom-resource/cfn-response.ts +0 -146
- package/src/constructs/nextjs-site/custom-resource/edge-lambda-version.ts +0 -162
- package/src/constructs/nextjs-site/custom-resource/edge-lambda.ts +0 -167
- package/src/constructs/nextjs-site/custom-resource/s3-bucket.ts +0 -112
- package/src/constructs/nextjs-site/custom-resource/util.ts +0 -11
- package/src/constructs/util/apiGatewayV1AccessLog.ts +0 -106
- package/src/constructs/util/apiGatewayV2AccessLog.ts +0 -139
- package/src/constructs/util/apiGatewayV2Cors.ts +0 -94
- package/src/constructs/util/apiGatewayV2Domain.ts +0 -312
- package/src/constructs/util/appSyncApiDomain.ts +0 -204
- package/src/constructs/util/builder.ts +0 -17
- package/src/constructs/util/duration.ts +0 -27
- package/src/constructs/util/functionBinding.ts +0 -102
- package/src/constructs/util/functionUrlCors.ts +0 -96
- package/src/constructs/util/permission.ts +0 -299
- package/src/constructs/util/python/bundling.ts +0 -174
- package/src/constructs/util/size.ts +0 -13
- package/src/constructs/util/warning.ts +0 -20
- package/src/context/context.ts +0 -79
- package/src/context/handler.ts +0 -53
- package/src/context/index.ts +0 -2
- package/src/credentials.ts +0 -103
- package/src/error.ts +0 -5
- package/src/iot.ts +0 -105
- package/src/logger.ts +0 -35
- package/src/runtime/handlers.ts +0 -121
- package/src/runtime/iot.ts +0 -16
- package/src/runtime/node.ts +0 -111
- package/src/runtime/runtime.ts +0 -27
- package/src/runtime/server.ts +0 -149
- package/src/runtime/workers.ts +0 -96
- package/src/stacks/build.ts +0 -69
- package/src/stacks/deploy.ts +0 -232
- package/src/stacks/index.ts +0 -73
- package/src/stacks/metadata.ts +0 -125
- package/src/watcher.ts +0 -47
- package/sst.config.mjs +0 -6
- package/support/bridge/bridge.ts +0 -136
- package/support/bridge/build.mjs +0 -18
- package/support/custom-resources/auth-keys.ts +0 -113
- package/support/custom-resources/build.mjs +0 -18
- package/support/custom-resources/cfn-response.ts +0 -151
- package/support/custom-resources/index.ts +0 -18
- package/support/custom-resources/secrets-migration.ts +0 -82
- package/support/custom-resources/stack-metadata.ts +0 -75
- package/support/custom-resources/util.ts +0 -44
- package/support/nodejs-runtime/index.ts +0 -69
- package/support/tsconfig.json +0 -11
- package/tsconfig.json +0 -13
- package/yarn-error.log +0 -75
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import url from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { buildErrorResponsesForRedirectToIndex } from "./BaseSite.js";
|
|
5
|
+
import { Fn, Duration, RemovalPolicy, } from "aws-cdk-lib";
|
|
6
|
+
import * as logs from "aws-cdk-lib/aws-logs";
|
|
7
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
8
|
+
import * as cloudfront from "aws-cdk-lib/aws-cloudfront";
|
|
9
|
+
import * as origins from "aws-cdk-lib/aws-cloudfront-origins";
|
|
10
|
+
import { SsrSite } from "./SsrSite.js";
|
|
11
|
+
import { EdgeFunction } from "./EdgeFunction.js";
|
|
12
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
13
|
+
/**
|
|
14
|
+
* The `NextjsSite` construct is a higher level CDK construct that makes it easy to create a Next.js app.
|
|
15
|
+
* @example
|
|
16
|
+
* Deploys a Next.js app in the `my-next-app` directory.
|
|
17
|
+
*
|
|
18
|
+
* ```js
|
|
19
|
+
* new NextjsSite(stack, "web", {
|
|
20
|
+
* path: "my-next-app/",
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export class NextjsSite extends SsrSite {
|
|
25
|
+
constructor(scope, id, props) {
|
|
26
|
+
super(scope, id, {
|
|
27
|
+
buildCommand: "npm_config_yes=true npx open-next@latest build",
|
|
28
|
+
...props,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
initBuildConfig() {
|
|
32
|
+
return {
|
|
33
|
+
serverBuildOutputFile: ".open-next/server-function/index.mjs",
|
|
34
|
+
clientBuildOutputDir: ".open-next/assets",
|
|
35
|
+
clientBuildVersionedSubDir: "_next",
|
|
36
|
+
siteStub: path.resolve(__dirname, "../support/nextjs-site-html-stub"),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
createFunctionForRegional() {
|
|
40
|
+
const { defaults, environment } = this.props;
|
|
41
|
+
let bundlePath, handler;
|
|
42
|
+
if (this.isPlaceholder) {
|
|
43
|
+
bundlePath = path.resolve(__dirname, "../support/ssr-site-function-stub");
|
|
44
|
+
handler = "server.handler";
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
bundlePath = path.join(this.props.path, path.dirname(this.buildConfig.serverBuildOutputFile));
|
|
48
|
+
handler = "index.handler";
|
|
49
|
+
}
|
|
50
|
+
return new lambda.Function(this, `ServerFunction`, {
|
|
51
|
+
description: "Server handler for Next.js",
|
|
52
|
+
handler,
|
|
53
|
+
currentVersionOptions: {
|
|
54
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
55
|
+
},
|
|
56
|
+
logRetention: logs.RetentionDays.THREE_DAYS,
|
|
57
|
+
code: lambda.Code.fromAsset(bundlePath),
|
|
58
|
+
runtime: lambda.Runtime.NODEJS_18_X,
|
|
59
|
+
memorySize: defaults?.function?.memorySize || 512,
|
|
60
|
+
timeout: Duration.seconds(defaults?.function?.timeout || 10),
|
|
61
|
+
environment,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
createCloudFrontDistributionForRegional() {
|
|
65
|
+
const { cdk } = this.props;
|
|
66
|
+
const cfDistributionProps = cdk?.distribution || {};
|
|
67
|
+
const s3Origin = new origins.S3Origin(this.cdk.bucket);
|
|
68
|
+
// Create server behavior
|
|
69
|
+
const { fn: middlewareFn, isMiddlewareEnabled } = this.createMiddlewareEdgeFunctionForRegional();
|
|
70
|
+
const fnUrl = this.serverLambdaForRegional.addFunctionUrl({
|
|
71
|
+
authType: lambda.FunctionUrlAuthType.NONE,
|
|
72
|
+
});
|
|
73
|
+
const serverBehavior = {
|
|
74
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
75
|
+
origin: new origins.HttpOrigin(Fn.parseDomainName(fnUrl.url)),
|
|
76
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
|
|
77
|
+
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
78
|
+
compress: true,
|
|
79
|
+
cachePolicy: cdk?.cachePolicies?.serverRequests ??
|
|
80
|
+
this.createCloudFrontServerCachePolicy(),
|
|
81
|
+
edgeLambdas: isMiddlewareEnabled && !this.isPlaceholder
|
|
82
|
+
? [{
|
|
83
|
+
eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST,
|
|
84
|
+
functionVersion: middlewareFn.currentVersion,
|
|
85
|
+
}]
|
|
86
|
+
: undefined,
|
|
87
|
+
};
|
|
88
|
+
// Create image optimization behavior
|
|
89
|
+
const imageFn = this.createImageOptimizationFunctionForRegional();
|
|
90
|
+
const imageFnUrl = imageFn.addFunctionUrl({
|
|
91
|
+
authType: lambda.FunctionUrlAuthType.NONE,
|
|
92
|
+
});
|
|
93
|
+
const imageBehavior = {
|
|
94
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
95
|
+
origin: new origins.HttpOrigin(Fn.parseDomainName(imageFnUrl.url)),
|
|
96
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_ALL,
|
|
97
|
+
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
98
|
+
compress: true,
|
|
99
|
+
cachePolicy: serverBehavior.cachePolicy,
|
|
100
|
+
};
|
|
101
|
+
// Create statics behavior
|
|
102
|
+
const staticFileBehaviour = {
|
|
103
|
+
origin: s3Origin,
|
|
104
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
105
|
+
allowedMethods: cloudfront.AllowedMethods.ALLOW_GET_HEAD_OPTIONS,
|
|
106
|
+
cachedMethods: cloudfront.CachedMethods.CACHE_GET_HEAD_OPTIONS,
|
|
107
|
+
compress: true,
|
|
108
|
+
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
|
|
109
|
+
};
|
|
110
|
+
// Create default behavior
|
|
111
|
+
// default handler for requests that don't match any other path:
|
|
112
|
+
// - try S3 first
|
|
113
|
+
// - if 403, fall back to lambda handler (mostly for /)
|
|
114
|
+
// - if 404, fall back to lambda handler
|
|
115
|
+
const fallbackOriginGroup = new origins.OriginGroup({
|
|
116
|
+
primaryOrigin: serverBehavior.origin,
|
|
117
|
+
fallbackOrigin: s3Origin,
|
|
118
|
+
fallbackStatusCodes: [404],
|
|
119
|
+
});
|
|
120
|
+
const defaultBehavior = {
|
|
121
|
+
origin: fallbackOriginGroup,
|
|
122
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
123
|
+
compress: true,
|
|
124
|
+
cachePolicy: serverBehavior.cachePolicy,
|
|
125
|
+
edgeLambdas: serverBehavior.edgeLambdas,
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Next.js requests
|
|
129
|
+
*
|
|
130
|
+
* - Public asset
|
|
131
|
+
* Use case: When you request an asset in /public
|
|
132
|
+
* Request: /myImage.png
|
|
133
|
+
* Response cache:
|
|
134
|
+
* - Cache-Control: public, max-age=0, must-revalidate
|
|
135
|
+
* - x-vercel-cache: MISS (1st request)
|
|
136
|
+
* - x-vercel-cache: HIT (2nd request)
|
|
137
|
+
*
|
|
138
|
+
* - SSG page
|
|
139
|
+
* Use case: When you request an SSG page directly
|
|
140
|
+
* Request: /myPage
|
|
141
|
+
* Response cache:
|
|
142
|
+
* - Cache-Control: public, max-age=0, must-revalidate
|
|
143
|
+
* - Content-Encoding: br
|
|
144
|
+
* - x-vercel-cache: HIT (2nd request, not set for 1st request)
|
|
145
|
+
*
|
|
146
|
+
* - SSR page (directly)
|
|
147
|
+
* Use case: When you request an SSR page directly
|
|
148
|
+
* Request: /myPage
|
|
149
|
+
* Response cache:
|
|
150
|
+
* - Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
|
|
151
|
+
* - x-vercel-cache: MISS
|
|
152
|
+
*
|
|
153
|
+
* - SSR pages (user transition)
|
|
154
|
+
* Use case: When the page uses getServerSideProps(), and you request this page on
|
|
155
|
+
* client-side page trasitions. Next.js sends an API request to the server,
|
|
156
|
+
* which runs getServerSideProps()
|
|
157
|
+
* Request: /_next/data/_-fpIB1rqWyRD-EJO59pO/myPage.json
|
|
158
|
+
* Response cache:
|
|
159
|
+
* - Cache-Control: private, no-cache, no-store, max-age=0, must-revalidate
|
|
160
|
+
* - x-vercel-cache: MISS
|
|
161
|
+
*
|
|
162
|
+
* - Image optimization
|
|
163
|
+
* Use case: when you request an image
|
|
164
|
+
* Request: /_next/image?url=%2F_next%2Fstatic%2Fmedia%2F4600x4600.ce39e3d6.jpg&w=256&q=75
|
|
165
|
+
* Response cache:
|
|
166
|
+
* - Cache-Control: public, max-age=31536000, immutable
|
|
167
|
+
* - x-vercel-cache: HIT
|
|
168
|
+
*
|
|
169
|
+
* - API
|
|
170
|
+
* Use case: when you request an API endpoint
|
|
171
|
+
* Request: /api/hello
|
|
172
|
+
* Response cache:
|
|
173
|
+
* - Cache-Control: public, max-age=0, must-revalidate
|
|
174
|
+
* - x-vercel-cache: MISS
|
|
175
|
+
*/
|
|
176
|
+
return new cloudfront.Distribution(this, "Distribution", {
|
|
177
|
+
// these values can be overwritten by cfDistributionProps
|
|
178
|
+
defaultRootObject: "",
|
|
179
|
+
// Override props.
|
|
180
|
+
...cfDistributionProps,
|
|
181
|
+
// these values can NOT be overwritten by cfDistributionProps
|
|
182
|
+
domainNames: this.buildDistributionDomainNames(),
|
|
183
|
+
certificate: this.cdk.certificate,
|
|
184
|
+
defaultBehavior: defaultBehavior,
|
|
185
|
+
additionalBehaviors: {
|
|
186
|
+
"api/*": serverBehavior,
|
|
187
|
+
"_next/data/*": serverBehavior,
|
|
188
|
+
"_next/image*": imageBehavior,
|
|
189
|
+
"_next/*": staticFileBehaviour,
|
|
190
|
+
...(cfDistributionProps.additionalBehaviors || {}),
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
createCloudFrontDistributionForStub() {
|
|
195
|
+
// Keep creating middleware edge function b/c edge function cannot be removed
|
|
196
|
+
// immediately.
|
|
197
|
+
this.createMiddlewareEdgeFunctionForRegional();
|
|
198
|
+
// Create placeholder distribution
|
|
199
|
+
return new cloudfront.Distribution(this, "Distribution", {
|
|
200
|
+
defaultRootObject: "index.html",
|
|
201
|
+
errorResponses: buildErrorResponsesForRedirectToIndex("index.html"),
|
|
202
|
+
domainNames: this.buildDistributionDomainNames(),
|
|
203
|
+
certificate: this.cdk.certificate,
|
|
204
|
+
defaultBehavior: {
|
|
205
|
+
origin: new origins.S3Origin(this.cdk.bucket),
|
|
206
|
+
viewerProtocolPolicy: cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
createCloudFrontServerCachePolicy() {
|
|
211
|
+
return new cloudfront.CachePolicy(this, "ServerCache", {
|
|
212
|
+
queryStringBehavior: cloudfront.CacheQueryStringBehavior.all(),
|
|
213
|
+
headerBehavior: cloudfront.CacheHeaderBehavior.allowList(
|
|
214
|
+
// required by image optimization request
|
|
215
|
+
"accept",
|
|
216
|
+
// required by server request
|
|
217
|
+
"x-op-middleware-request-headers", "x-op-middleware-response-headers", "x-nextjs-data", "x-middleware-prefetch"),
|
|
218
|
+
cookieBehavior: cloudfront.CacheCookieBehavior.all(),
|
|
219
|
+
defaultTtl: Duration.days(0),
|
|
220
|
+
maxTtl: Duration.days(365),
|
|
221
|
+
minTtl: Duration.days(0),
|
|
222
|
+
enableAcceptEncodingBrotli: true,
|
|
223
|
+
enableAcceptEncodingGzip: true,
|
|
224
|
+
comment: "SST server response cache policy",
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
generateBuildId() {
|
|
228
|
+
if (this.isPlaceholder) {
|
|
229
|
+
return "live";
|
|
230
|
+
}
|
|
231
|
+
const filePath = path.join(this.props.path, ".next/BUILD_ID");
|
|
232
|
+
return fs.readFileSync(filePath).toString();
|
|
233
|
+
}
|
|
234
|
+
createImageOptimizationFunctionForRegional() {
|
|
235
|
+
const { defaults, path: sitePath } = this.props;
|
|
236
|
+
let bundlePath, handler;
|
|
237
|
+
if (this.isPlaceholder) {
|
|
238
|
+
bundlePath = path.resolve(__dirname, "../support/ssr-site-function-stub");
|
|
239
|
+
handler = "server.handler";
|
|
240
|
+
}
|
|
241
|
+
else {
|
|
242
|
+
bundlePath = path.join(sitePath, ".open-next/image-optimization-function");
|
|
243
|
+
handler = "index.handler";
|
|
244
|
+
}
|
|
245
|
+
return new lambda.Function(this, `ImageFunction`, {
|
|
246
|
+
description: "Image optimization handler for Next.js",
|
|
247
|
+
handler,
|
|
248
|
+
currentVersionOptions: {
|
|
249
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
250
|
+
},
|
|
251
|
+
logRetention: logs.RetentionDays.THREE_DAYS,
|
|
252
|
+
code: lambda.Code.fromAsset(bundlePath),
|
|
253
|
+
runtime: lambda.Runtime.NODEJS_18_X,
|
|
254
|
+
memorySize: defaults?.function?.memorySize || 512,
|
|
255
|
+
timeout: Duration.seconds(defaults?.function?.timeout || 10),
|
|
256
|
+
environment: {
|
|
257
|
+
BUCKET_NAME: this.cdk.bucket.bucketName,
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
createMiddlewareEdgeFunctionForRegional() {
|
|
262
|
+
const { defaults, environment, path: sitePath } = this.props;
|
|
263
|
+
const middlewarePath = path.resolve(sitePath, ".open-next/middleware-function");
|
|
264
|
+
const isMiddlewareEnabled = fs.existsSync(middlewarePath);
|
|
265
|
+
let bundlePath, handler;
|
|
266
|
+
if (this.isPlaceholder || !isMiddlewareEnabled) {
|
|
267
|
+
bundlePath = path.resolve(__dirname, "../support/ssr-site-function-stub");
|
|
268
|
+
handler = "server.handler";
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
bundlePath = middlewarePath;
|
|
272
|
+
handler = "index.handler";
|
|
273
|
+
}
|
|
274
|
+
const fn = new EdgeFunction(this, "Middleware", {
|
|
275
|
+
bundlePath,
|
|
276
|
+
handler,
|
|
277
|
+
timeout: 5,
|
|
278
|
+
memory: 128,
|
|
279
|
+
permissions: defaults?.function?.permissions,
|
|
280
|
+
environment,
|
|
281
|
+
format: "esm",
|
|
282
|
+
});
|
|
283
|
+
return { fn, isMiddlewareEnabled };
|
|
284
|
+
}
|
|
285
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
|
|
|
2
2
|
import * as sqs from "aws-cdk-lib/aws-sqs";
|
|
3
3
|
import * as lambdaEventSources from "aws-cdk-lib/aws-lambda-event-sources";
|
|
4
4
|
import { getFunctionRef, isCDKConstruct } from "./Construct.js";
|
|
5
|
-
import { Function as Fn
|
|
5
|
+
import { Function as Fn } from "./Function.js";
|
|
6
6
|
import { toCdkDuration } from "./util/duration.js";
|
|
7
7
|
/////////////////////
|
|
8
8
|
// Construct
|
|
@@ -21,10 +21,17 @@ import { toCdkDuration } from "./util/duration.js";
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export class Queue extends Construct {
|
|
24
|
+
id;
|
|
25
|
+
cdk;
|
|
26
|
+
/**
|
|
27
|
+
* The internally created consumer `Function` instance.
|
|
28
|
+
*/
|
|
29
|
+
consumerFunction;
|
|
30
|
+
bindingForAllConsumers = [];
|
|
31
|
+
permissionsAttachedForAllConsumers = [];
|
|
32
|
+
props;
|
|
24
33
|
constructor(scope, id, props) {
|
|
25
34
|
super(scope, props?.cdk?.id || id);
|
|
26
|
-
this.bindingForAllConsumers = [];
|
|
27
|
-
this.permissionsAttachedForAllConsumers = [];
|
|
28
35
|
this.id = id;
|
|
29
36
|
this.props = props || {};
|
|
30
37
|
this.cdk = {};
|
|
@@ -98,7 +105,7 @@ export class Queue extends Construct {
|
|
|
98
105
|
const fn = Fn.fromDefinition(scope, `Consumer_${this.node.id}`, functionDefinition);
|
|
99
106
|
fn.addEventSource(new lambdaEventSources.SqsEventSource(this.cdk.queue, eventSourceProps));
|
|
100
107
|
// Attach permissions
|
|
101
|
-
this.permissionsAttachedForAllConsumers.forEach(
|
|
108
|
+
this.permissionsAttachedForAllConsumers.forEach(permissions => {
|
|
102
109
|
fn.attachPermissions(permissions);
|
|
103
110
|
});
|
|
104
111
|
fn.bind(this.bindingForAllConsumers);
|
|
@@ -144,8 +151,8 @@ export class Queue extends Construct {
|
|
|
144
151
|
data: {
|
|
145
152
|
name: this.cdk.queue.queueName,
|
|
146
153
|
url: this.cdk.queue.queueUrl,
|
|
147
|
-
consumer: getFunctionRef(this.consumerFunction)
|
|
148
|
-
}
|
|
154
|
+
consumer: getFunctionRef(this.consumerFunction)
|
|
155
|
+
}
|
|
149
156
|
};
|
|
150
157
|
}
|
|
151
158
|
/** @internal */
|
|
@@ -155,12 +162,12 @@ export class Queue extends Construct {
|
|
|
155
162
|
variables: {
|
|
156
163
|
queueUrl: {
|
|
157
164
|
environment: this.queueUrl,
|
|
158
|
-
parameter: this.queueUrl
|
|
159
|
-
}
|
|
165
|
+
parameter: this.queueUrl
|
|
166
|
+
}
|
|
160
167
|
},
|
|
161
168
|
permissions: {
|
|
162
|
-
"sqs:*": [this.queueArn]
|
|
163
|
-
}
|
|
169
|
+
"sqs:*": [this.queueArn]
|
|
170
|
+
}
|
|
164
171
|
};
|
|
165
172
|
}
|
|
166
173
|
createQueue() {
|
|
@@ -184,7 +191,7 @@ export class Queue extends Construct {
|
|
|
184
191
|
// TODO
|
|
185
192
|
console.log(toCdkDuration("900 seconds"));
|
|
186
193
|
debugOverrideProps = {
|
|
187
|
-
visibilityTimeout: toCdkDuration("900 seconds")
|
|
194
|
+
visibilityTimeout: toCdkDuration("900 seconds")
|
|
188
195
|
};
|
|
189
196
|
}
|
|
190
197
|
}
|
|
@@ -192,7 +199,7 @@ export class Queue extends Construct {
|
|
|
192
199
|
this.cdk.queue = new sqs.Queue(this, "Queue", {
|
|
193
200
|
queueName: name,
|
|
194
201
|
...sqsQueueProps,
|
|
195
|
-
...debugOverrideProps
|
|
202
|
+
...debugOverrideProps
|
|
196
203
|
});
|
|
197
204
|
}
|
|
198
205
|
}
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import glob from "glob";
|
|
3
|
-
import fs from "fs
|
|
3
|
+
import fs from "fs";
|
|
4
4
|
import * as crypto from "crypto";
|
|
5
5
|
import { Construct } from "constructs";
|
|
6
6
|
import * as cdk from "aws-cdk-lib";
|
|
@@ -29,13 +29,21 @@ const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
export class RDS extends Construct {
|
|
32
|
+
id;
|
|
33
|
+
cdk;
|
|
34
|
+
/**
|
|
35
|
+
* The ARN of the internally created CDK ServerlessCluster instance.
|
|
36
|
+
*/
|
|
37
|
+
migratorFunction;
|
|
38
|
+
props;
|
|
39
|
+
secret;
|
|
32
40
|
constructor(scope, id, props) {
|
|
33
41
|
super(scope, props.cdk?.id || id);
|
|
34
42
|
this.validateRequiredProps(props);
|
|
35
43
|
this.id = id;
|
|
36
44
|
this.cdk = {};
|
|
37
45
|
this.props = props || {};
|
|
38
|
-
|
|
46
|
+
let { migrations, cdk } = this.props;
|
|
39
47
|
// Create the cluster
|
|
40
48
|
if (cdk && isCDKConstruct(cdk.cluster)) {
|
|
41
49
|
this.validateCDKPropWhenIsConstruct();
|
|
@@ -114,12 +122,12 @@ export class RDS extends Construct {
|
|
|
114
122
|
},
|
|
115
123
|
secretArn: {
|
|
116
124
|
environment: this.secretArn,
|
|
117
|
-
parameter: this.secretArn
|
|
125
|
+
parameter: this.secretArn,
|
|
118
126
|
},
|
|
119
127
|
defaultDatabaseName: {
|
|
120
128
|
environment: this.defaultDatabaseName,
|
|
121
|
-
parameter: this.defaultDatabaseName
|
|
122
|
-
}
|
|
129
|
+
parameter: this.defaultDatabaseName,
|
|
130
|
+
},
|
|
123
131
|
},
|
|
124
132
|
permissions: {
|
|
125
133
|
"rds-data:*": [this.clusterArn],
|
|
@@ -250,10 +258,8 @@ export class RDS extends Construct {
|
|
|
250
258
|
// - when invoked from `sst build`, __dirname is `resources/dist`
|
|
251
259
|
// - when running resources tests, __dirname is `resources/src`
|
|
252
260
|
// For now we will do `__dirname/../dist` to make both cases work.
|
|
253
|
-
const srcPath = path.resolve(path.join(__dirname, "../dist/RDS_migrator"));
|
|
254
261
|
const fn = new Fn(this, "MigrationFunction", {
|
|
255
|
-
|
|
256
|
-
handler: "index.handler",
|
|
262
|
+
handler: path.resolve(path.join(__dirname, "../support/rds-migrator/index.handler")),
|
|
257
263
|
runtime: "nodejs16.x",
|
|
258
264
|
timeout: 900,
|
|
259
265
|
memorySize: 1024,
|
|
@@ -266,20 +272,21 @@ export class RDS extends Construct {
|
|
|
266
272
|
// can locate the migration files
|
|
267
273
|
RDS_MIGRATIONS_PATH: app.local ? migrations : migrationsDestination,
|
|
268
274
|
},
|
|
269
|
-
|
|
270
|
-
|
|
275
|
+
// Note that we need to generate a relative path of the migrations off the
|
|
276
|
+
// srcPath because sst.Function internally builds the copy "from" path by
|
|
277
|
+
// joining the srcPath and the from path.
|
|
278
|
+
copyFiles: [
|
|
279
|
+
{
|
|
280
|
+
from: migrations,
|
|
281
|
+
to: migrationsDestination,
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
nodejs: {
|
|
285
|
+
install: ["kysely", "kysely-data-api"],
|
|
271
286
|
format: "esm",
|
|
272
|
-
// Note that we need to generate a relative path of the migrations off the
|
|
273
|
-
// srcPath because sst.Function internally builds the copy "from" path by
|
|
274
|
-
// joining the srcPath and the from path.
|
|
275
|
-
copyFiles: [
|
|
276
|
-
{
|
|
277
|
-
from: path.relative(path.resolve(srcPath), path.resolve(migrations)),
|
|
278
|
-
to: migrationsDestination,
|
|
279
|
-
},
|
|
280
|
-
],
|
|
281
287
|
},
|
|
282
288
|
});
|
|
289
|
+
fn._disableBind = true;
|
|
283
290
|
fn.attachPermissions([this.cdk.cluster]);
|
|
284
291
|
this.migratorFunction = fn;
|
|
285
292
|
}
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
2
|
+
import { SsrSite } from "./SsrSite.js";
|
|
3
|
+
import { EdgeFunction } from "./EdgeFunction.js";
|
|
4
|
+
/**
|
|
5
|
+
* The `RemixSite` construct is a higher level CDK construct that makes it easy to create a Remix app.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* Deploys a Remix app in the `my-remix-app` directory.
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* new RemixSite(stack, "web", {
|
|
13
|
+
* path: "my-remix-app/",
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class RemixSite extends SsrSite {
|
|
18
|
+
protected initBuildConfig(): {
|
|
19
|
+
serverBuildOutputFile: string;
|
|
20
|
+
clientBuildOutputDir: string;
|
|
21
|
+
clientBuildVersionedSubDir: string;
|
|
22
|
+
siteStub: string;
|
|
23
|
+
};
|
|
24
|
+
private createServerLambdaBundle;
|
|
25
|
+
private createServerLambdaBundleWithStub;
|
|
26
|
+
protected createFunctionForRegional(): lambda.Function;
|
|
27
|
+
protected createFunctionForEdge(): EdgeFunction;
|
|
28
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import url from "url";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import * as esbuild from "esbuild";
|
|
5
|
+
import { createRequire } from "module";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
7
|
+
import { Duration, RemovalPolicy } from "aws-cdk-lib";
|
|
8
|
+
import * as logs from "aws-cdk-lib/aws-logs";
|
|
9
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
10
|
+
import { Logger } from "../logger.js";
|
|
11
|
+
import { SsrSite } from "./SsrSite.js";
|
|
12
|
+
import { EdgeFunction } from "./EdgeFunction.js";
|
|
13
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
14
|
+
/**
|
|
15
|
+
* The `RemixSite` construct is a higher level CDK construct that makes it easy to create a Remix app.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* Deploys a Remix app in the `my-remix-app` directory.
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* new RemixSite(stack, "web", {
|
|
23
|
+
* path: "my-remix-app/",
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class RemixSite extends SsrSite {
|
|
28
|
+
initBuildConfig() {
|
|
29
|
+
const { path: sitePath } = this.props;
|
|
30
|
+
const configDefaults = {
|
|
31
|
+
assetsBuildDirectory: "public/build",
|
|
32
|
+
publicPath: "/build/",
|
|
33
|
+
serverBuildPath: "build/index.js",
|
|
34
|
+
serverBuildTarget: "node-cjs",
|
|
35
|
+
};
|
|
36
|
+
// Validate config path
|
|
37
|
+
const configPath = path.resolve(sitePath, "remix.config.js");
|
|
38
|
+
if (!fs.existsSync(configPath)) {
|
|
39
|
+
throw new Error(`Could not find "remix.config.js" at expected path "${configPath}".`);
|
|
40
|
+
}
|
|
41
|
+
// Load config
|
|
42
|
+
const userConfig = require(configPath);
|
|
43
|
+
const config = {
|
|
44
|
+
...configDefaults,
|
|
45
|
+
...userConfig,
|
|
46
|
+
};
|
|
47
|
+
// Validate config
|
|
48
|
+
Object.keys(configDefaults).forEach((key) => {
|
|
49
|
+
const k = key;
|
|
50
|
+
if (config[k] !== configDefaults[k]) {
|
|
51
|
+
throw new Error(`RemixSite: remix.config.js "${key}" must be "${configDefaults[k]}".`);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
serverBuildOutputFile: "build/index.js",
|
|
56
|
+
clientBuildOutputDir: "public",
|
|
57
|
+
clientBuildVersionedSubDir: "build",
|
|
58
|
+
siteStub: path.resolve(__dirname, "../support/remix-site-html-stub"),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
createServerLambdaBundle(wrapperFile) {
|
|
62
|
+
// Create a Lambda@Edge handler for the Remix server bundle.
|
|
63
|
+
//
|
|
64
|
+
// Note: Remix does perform their own internal ESBuild process, but it
|
|
65
|
+
// doesn't bundle 3rd party dependencies by default. In the interest of
|
|
66
|
+
// keeping deployments seamless for users we will create a server bundle
|
|
67
|
+
// with all dependencies included. We will still need to consider how to
|
|
68
|
+
// address any need for external dependencies, although I think we should
|
|
69
|
+
// possibly consider this at a later date.
|
|
70
|
+
// In this path we are assuming that the Remix build only outputs the
|
|
71
|
+
// "core server build". We can safely assume this as we have guarded the
|
|
72
|
+
// remix.config.js to ensure it matches our expectations for the build
|
|
73
|
+
// configuration.
|
|
74
|
+
// We need to ensure that the "core server build" is wrapped with an
|
|
75
|
+
// appropriate Lambda@Edge handler. We will utilise an internal asset
|
|
76
|
+
// template to create this wrapper within the "core server build" output
|
|
77
|
+
// directory.
|
|
78
|
+
Logger.debug(`Creating Lambda@Edge handler for server`);
|
|
79
|
+
// Resolve the path to create the server lambda handler at.
|
|
80
|
+
const serverPath = path.join(this.props.path, "build/server.js");
|
|
81
|
+
// Write the server lambda
|
|
82
|
+
const templatePath = path.resolve(__dirname, `../support/remix-site-function/${wrapperFile}`);
|
|
83
|
+
fs.copyFileSync(templatePath, serverPath);
|
|
84
|
+
Logger.debug(`Bundling server`);
|
|
85
|
+
// Create a directory that we will use to create the bundled version
|
|
86
|
+
// of the "core server build" along with our custom Lamba server handler.
|
|
87
|
+
const outputPath = path.resolve(path.join(this.sstBuildDir, `RemixSiteFunction-${this.node.id}-${this.node.addr}`));
|
|
88
|
+
// Copy the Remix polyfil to the server build directory
|
|
89
|
+
const polyfillSource = path.resolve(__dirname, "../support/remix-site-function/polyfill.js");
|
|
90
|
+
const polyfillDest = path.join(this.props.path, "build/polyfill.js");
|
|
91
|
+
fs.copyFileSync(polyfillSource, polyfillDest);
|
|
92
|
+
const result = esbuild.buildSync({
|
|
93
|
+
entryPoints: [serverPath],
|
|
94
|
+
bundle: true,
|
|
95
|
+
target: "node16",
|
|
96
|
+
platform: "node",
|
|
97
|
+
external: ["aws-sdk"],
|
|
98
|
+
outfile: path.join(outputPath, "server.js"),
|
|
99
|
+
// We need to ensure that the polyfills are injected above other code that
|
|
100
|
+
// will depend on them. Importing them within the top of the lambda code
|
|
101
|
+
// doesn't appear to guarantee this, we therefore leverage ESBUild's
|
|
102
|
+
// `inject` option to ensure that the polyfills are injected at the top of
|
|
103
|
+
// the bundle.
|
|
104
|
+
inject: [polyfillDest],
|
|
105
|
+
});
|
|
106
|
+
if (result.errors.length > 0) {
|
|
107
|
+
result.errors.forEach((error) => console.error(error));
|
|
108
|
+
throw new Error(`There was a problem bundling the server.`);
|
|
109
|
+
}
|
|
110
|
+
return outputPath;
|
|
111
|
+
}
|
|
112
|
+
createServerLambdaBundleWithStub() {
|
|
113
|
+
// Use existing stub bundle in assets
|
|
114
|
+
return path.resolve(__dirname, "../support/ssr-site-function-stub");
|
|
115
|
+
}
|
|
116
|
+
createFunctionForRegional() {
|
|
117
|
+
const { defaults, environment } = this.props;
|
|
118
|
+
const bundlePath = this.isPlaceholder
|
|
119
|
+
? this.createServerLambdaBundleWithStub()
|
|
120
|
+
: this.createServerLambdaBundle("regional-server.js");
|
|
121
|
+
return new lambda.Function(this, `ServerFunction`, {
|
|
122
|
+
description: "Server handler for Remix",
|
|
123
|
+
handler: "server.handler",
|
|
124
|
+
currentVersionOptions: {
|
|
125
|
+
removalPolicy: RemovalPolicy.DESTROY,
|
|
126
|
+
},
|
|
127
|
+
logRetention: logs.RetentionDays.THREE_DAYS,
|
|
128
|
+
code: lambda.Code.fromAsset(bundlePath),
|
|
129
|
+
runtime: lambda.Runtime.NODEJS_16_X,
|
|
130
|
+
memorySize: defaults?.function?.memorySize || 512,
|
|
131
|
+
timeout: Duration.seconds(defaults?.function?.timeout || 10),
|
|
132
|
+
environment,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
createFunctionForEdge() {
|
|
136
|
+
const { defaults, environment } = this.props;
|
|
137
|
+
const bundlePath = this.isPlaceholder
|
|
138
|
+
? this.createServerLambdaBundleWithStub()
|
|
139
|
+
: this.createServerLambdaBundle("edge-server.js");
|
|
140
|
+
return new EdgeFunction(this, `Server`, {
|
|
141
|
+
scopeOverride: this,
|
|
142
|
+
bundlePath,
|
|
143
|
+
handler: "server.handler",
|
|
144
|
+
timeout: defaults?.function?.timeout,
|
|
145
|
+
memory: defaults?.function?.memorySize,
|
|
146
|
+
permissions: defaults?.function?.permissions,
|
|
147
|
+
environment,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
File without changes
|
|
File without changes
|