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
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
/* eslint-disable no-console */
|
|
3
|
-
import url from "url";
|
|
4
|
-
import { httpRequest } from "./outbound.js";
|
|
5
|
-
import { log } from "./util.js";
|
|
6
|
-
|
|
7
|
-
export const CREATE_FAILED_PHYSICAL_ID_MARKER =
|
|
8
|
-
"AWSCDK::CustomResourceProviderFramework::CREATE_FAILED";
|
|
9
|
-
export const MISSING_PHYSICAL_ID_MARKER =
|
|
10
|
-
"AWSCDK::CustomResourceProviderFramework::MISSING_PHYSICAL_ID";
|
|
11
|
-
|
|
12
|
-
export interface CloudFormationResponseOptions {
|
|
13
|
-
readonly reason?: string;
|
|
14
|
-
readonly noEcho?: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface CloudFormationEventContext {
|
|
18
|
-
StackId: string;
|
|
19
|
-
RequestId: string;
|
|
20
|
-
PhysicalResourceId?: string;
|
|
21
|
-
LogicalResourceId: string;
|
|
22
|
-
ResponseURL: string;
|
|
23
|
-
Data?: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function submitResponse(
|
|
27
|
-
status: "SUCCESS" | "FAILED",
|
|
28
|
-
event: CloudFormationEventContext,
|
|
29
|
-
options: CloudFormationResponseOptions = {}
|
|
30
|
-
) {
|
|
31
|
-
const json: AWSLambda.CloudFormationCustomResourceResponse = {
|
|
32
|
-
Status: status,
|
|
33
|
-
Reason: options.reason || status,
|
|
34
|
-
StackId: event.StackId,
|
|
35
|
-
RequestId: event.RequestId,
|
|
36
|
-
PhysicalResourceId: event.PhysicalResourceId || MISSING_PHYSICAL_ID_MARKER,
|
|
37
|
-
LogicalResourceId: event.LogicalResourceId,
|
|
38
|
-
NoEcho: options.noEcho,
|
|
39
|
-
Data: event.Data,
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
log("submit response to cloudformation", json);
|
|
43
|
-
|
|
44
|
-
const responseBody = JSON.stringify(json);
|
|
45
|
-
|
|
46
|
-
const parsedUrl = url.parse(event.ResponseURL);
|
|
47
|
-
await httpRequest(
|
|
48
|
-
{
|
|
49
|
-
hostname: parsedUrl.hostname,
|
|
50
|
-
path: parsedUrl.path,
|
|
51
|
-
method: "PUT",
|
|
52
|
-
headers: {
|
|
53
|
-
"content-type": "",
|
|
54
|
-
"content-length": responseBody.length,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
responseBody
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export const includeStackTraces = true; // for unit tests
|
|
62
|
-
|
|
63
|
-
export function safeHandler(block: (event: any) => Promise<void>) {
|
|
64
|
-
return async (event: any) => {
|
|
65
|
-
// ignore DELETE event when the physical resource ID is the marker that
|
|
66
|
-
// indicates that this DELETE is a subsequent DELETE to a failed CREATE
|
|
67
|
-
// operation.
|
|
68
|
-
if (
|
|
69
|
-
event.RequestType === "Delete" &&
|
|
70
|
-
event.PhysicalResourceId === CREATE_FAILED_PHYSICAL_ID_MARKER
|
|
71
|
-
) {
|
|
72
|
-
log("ignoring DELETE event caused by a failed CREATE event");
|
|
73
|
-
await submitResponse("SUCCESS", event);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
try {
|
|
78
|
-
await block(event);
|
|
79
|
-
} catch (e: any) {
|
|
80
|
-
// tell waiter state machine to retry
|
|
81
|
-
if (e instanceof Retry) {
|
|
82
|
-
log("retry requested by handler");
|
|
83
|
-
throw e;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!event.PhysicalResourceId) {
|
|
87
|
-
// special case: if CREATE fails, which usually implies, we usually don't
|
|
88
|
-
// have a physical resource id. in this case, the subsequent DELETE
|
|
89
|
-
// operation does not have any meaning, and will likely fail as well. to
|
|
90
|
-
// address this, we use a marker so the provider framework can simply
|
|
91
|
-
// ignore the subsequent DELETE.
|
|
92
|
-
if (event.RequestType === "Create") {
|
|
93
|
-
log(
|
|
94
|
-
"CREATE failed, responding with a marker physical resource id so that the subsequent DELETE will be ignored"
|
|
95
|
-
);
|
|
96
|
-
event.PhysicalResourceId = CREATE_FAILED_PHYSICAL_ID_MARKER;
|
|
97
|
-
} else {
|
|
98
|
-
// otherwise, if PhysicalResourceId is not specified, something is
|
|
99
|
-
// terribly wrong because all other events should have an ID.
|
|
100
|
-
log(
|
|
101
|
-
`ERROR: Malformed event. "PhysicalResourceId" is required: ${JSON.stringify(
|
|
102
|
-
event
|
|
103
|
-
)}`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// this is an actual error, fail the activity altogether and exist.
|
|
109
|
-
await submitResponse("FAILED", event, {
|
|
110
|
-
reason: includeStackTraces ? e.stack : e.message,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export class Retry extends Error {}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import * as cfnResponse from "./cfn-response.js";
|
|
2
|
-
import { invokeFunction } from "./outbound.js";
|
|
3
|
-
import { log } from "./util.js";
|
|
4
|
-
|
|
5
|
-
export const handler = cfnResponse.safeHandler(async (
|
|
6
|
-
cfnRequest: AWSLambda.CloudFormationCustomResourceEvent
|
|
7
|
-
) => {
|
|
8
|
-
log("onEventHandler", cfnRequest);
|
|
9
|
-
|
|
10
|
-
// Invoke user function on Create and on Update
|
|
11
|
-
const fnCreate = cfnRequest.ResourceProperties.UserCreateFunction;
|
|
12
|
-
const fnUpdate = cfnRequest.ResourceProperties.UserUpdateFunction;
|
|
13
|
-
const fnDelete = cfnRequest.ResourceProperties.UserDeleteFunction;
|
|
14
|
-
const fnParams = JSON.parse(cfnRequest.ResourceProperties.UserParams);
|
|
15
|
-
if (cfnRequest.RequestType === "Create" && fnCreate) {
|
|
16
|
-
await invokeUserFunction(fnCreate, { params: fnParams });
|
|
17
|
-
} else if (cfnRequest.RequestType === "Update" && fnUpdate) {
|
|
18
|
-
await invokeUserFunction(fnUpdate, { params: fnParams });
|
|
19
|
-
} else if (cfnRequest.RequestType === "Delete" && fnDelete) {
|
|
20
|
-
await invokeUserFunction(fnDelete, { params: fnParams });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Build response
|
|
24
|
-
return cfnResponse.submitResponse("SUCCESS", {
|
|
25
|
-
...cfnRequest,
|
|
26
|
-
PhysicalResourceId: defaultPhysicalResourceId(cfnRequest),
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
async function invokeUserFunction(functionName: string, payload: any) {
|
|
31
|
-
log(`executing user function ${functionName} with payload`, payload);
|
|
32
|
-
|
|
33
|
-
const resp = await invokeFunction({
|
|
34
|
-
FunctionName: functionName,
|
|
35
|
-
Payload: JSON.stringify(payload),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
log("user function response:", resp, typeof resp);
|
|
39
|
-
|
|
40
|
-
if (resp.FunctionError) {
|
|
41
|
-
log("user function threw an error:", resp.FunctionError);
|
|
42
|
-
|
|
43
|
-
const jsonPayload = parseJsonPayload(resp.Payload);
|
|
44
|
-
|
|
45
|
-
// Note: custom resources have a response limit of 4k. Limit the
|
|
46
|
-
// error message to 1000 characters.
|
|
47
|
-
const errorMessage = (jsonPayload.errorMessage || "error").substring(
|
|
48
|
-
0,
|
|
49
|
-
1000
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// append a reference to the log group.
|
|
53
|
-
const message = [
|
|
54
|
-
errorMessage,
|
|
55
|
-
"",
|
|
56
|
-
`Logs: /aws/lambda/${functionName}`, // cloudwatch log group
|
|
57
|
-
"",
|
|
58
|
-
].join("\n");
|
|
59
|
-
|
|
60
|
-
const e = new Error(message);
|
|
61
|
-
|
|
62
|
-
// the output that goes to CFN is what's in `stack`, not the error message.
|
|
63
|
-
// if we have a remote trace, construct a nice message with log group information
|
|
64
|
-
if (jsonPayload.trace) {
|
|
65
|
-
// skip first trace line because it's the message
|
|
66
|
-
e.stack = [message, ...jsonPayload.trace.slice(1)].join("\n");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function parseJsonPayload(payload: any): any {
|
|
74
|
-
if (!payload) {
|
|
75
|
-
return {};
|
|
76
|
-
}
|
|
77
|
-
const text = payload.toString();
|
|
78
|
-
try {
|
|
79
|
-
return JSON.parse(text);
|
|
80
|
-
} catch (e) {
|
|
81
|
-
throw new Error(
|
|
82
|
-
`return values from user-handlers must be JSON objects. got: "${text}"`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function defaultPhysicalResourceId(
|
|
88
|
-
req: AWSLambda.CloudFormationCustomResourceEvent
|
|
89
|
-
): string {
|
|
90
|
-
switch (req.RequestType) {
|
|
91
|
-
case "Create":
|
|
92
|
-
return req.RequestId;
|
|
93
|
-
|
|
94
|
-
case "Update":
|
|
95
|
-
case "Delete":
|
|
96
|
-
return req.PhysicalResourceId;
|
|
97
|
-
|
|
98
|
-
default:
|
|
99
|
-
throw new Error(
|
|
100
|
-
`Invalid "RequestType" in request "${JSON.stringify(req)}"`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/* istanbul ignore file */
|
|
2
|
-
import * as https from "https";
|
|
3
|
-
import { createRequire } from "module";
|
|
4
|
-
const require = createRequire(import.meta.url);
|
|
5
|
-
const AWS = require("aws-sdk");
|
|
6
|
-
import type { StepFunctions, Lambda } from "aws-sdk";
|
|
7
|
-
import type { ConfigurationOptions } from "aws-sdk/lib/config-base";
|
|
8
|
-
|
|
9
|
-
const FRAMEWORK_HANDLER_TIMEOUT = 900000; // 15 minutes
|
|
10
|
-
|
|
11
|
-
// In order to honor the overall maximum timeout set for the target process,
|
|
12
|
-
// the default 2 minutes from AWS SDK has to be overriden:
|
|
13
|
-
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Config.html#httpOptions-property
|
|
14
|
-
const awsSdkConfig: ConfigurationOptions = {
|
|
15
|
-
httpOptions: { timeout: FRAMEWORK_HANDLER_TIMEOUT },
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
async function defaultHttpRequest(
|
|
19
|
-
options: https.RequestOptions,
|
|
20
|
-
responseBody: string
|
|
21
|
-
) {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
try {
|
|
24
|
-
const request = https.request(options, resolve);
|
|
25
|
-
request.on("error", reject);
|
|
26
|
-
request.write(responseBody);
|
|
27
|
-
request.end();
|
|
28
|
-
} catch (e) {
|
|
29
|
-
reject(e);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let sfn: StepFunctions;
|
|
35
|
-
let lambda: Lambda;
|
|
36
|
-
|
|
37
|
-
async function defaultStartExecution(
|
|
38
|
-
req: StepFunctions.StartExecutionInput
|
|
39
|
-
): Promise<StepFunctions.StartExecutionOutput> {
|
|
40
|
-
if (!sfn) {
|
|
41
|
-
sfn = new AWS.StepFunctions(awsSdkConfig);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return sfn.startExecution(req).promise();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function defaultInvokeFunction(
|
|
48
|
-
req: Lambda.InvocationRequest
|
|
49
|
-
): Promise<Lambda.InvocationResponse> {
|
|
50
|
-
if (!lambda) {
|
|
51
|
-
lambda = new AWS.Lambda(awsSdkConfig);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return lambda.invoke(req).promise();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const startExecution = defaultStartExecution;
|
|
58
|
-
export const invokeFunction = defaultInvokeFunction;
|
|
59
|
-
export const httpRequest = defaultHttpRequest;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
export function getEnv(name: string): string {
|
|
4
|
-
const value = process.env[name];
|
|
5
|
-
if (!value) {
|
|
6
|
-
throw new Error(`The environment variable "${name}" is not defined`);
|
|
7
|
-
}
|
|
8
|
-
return value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function log(title: any, ...args: any[]) {
|
|
12
|
-
console.log(
|
|
13
|
-
"[provider-framework]",
|
|
14
|
-
title,
|
|
15
|
-
...args.map((x) =>
|
|
16
|
-
typeof x === "object" ? JSON.stringify(x, undefined, 2) : x
|
|
17
|
-
)
|
|
18
|
-
);
|
|
19
|
-
}
|
package/src/constructs/Script.ts
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import url from "url";
|
|
3
|
-
import { Construct } from "constructs";
|
|
4
|
-
import * as cdk from "aws-cdk-lib";
|
|
5
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
6
|
-
import { App } from "./App.js";
|
|
7
|
-
import {
|
|
8
|
-
Function as Fn,
|
|
9
|
-
FunctionProps,
|
|
10
|
-
FunctionDefinition,
|
|
11
|
-
} from "./Function.js";
|
|
12
|
-
import { SSTConstruct } from "./Construct.js";
|
|
13
|
-
import { Permissions } from "./util/permission.js";
|
|
14
|
-
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
|
|
15
|
-
|
|
16
|
-
export interface ScriptProps {
|
|
17
|
-
/**
|
|
18
|
-
* An object of input parameters to be passed to the script. Made available in the `event` object of the function.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```js
|
|
22
|
-
* import { Script } from "@serverless-stack/resources";
|
|
23
|
-
*
|
|
24
|
-
* new Script(stack, "Script", {
|
|
25
|
-
* onCreate: "src/script.create",
|
|
26
|
-
* params: {
|
|
27
|
-
* hello: "world",
|
|
28
|
-
* },
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
params?: Record<string, any>;
|
|
33
|
-
defaults?: {
|
|
34
|
-
/**
|
|
35
|
-
* The default function props to be applied to all the Lambda functions in the API. The `environment`, `permissions` and `layers` properties will be merged with per route definitions if they are defined.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```js
|
|
39
|
-
* new Script(stack, "Api", {
|
|
40
|
-
* defaults: {
|
|
41
|
-
* function: {
|
|
42
|
-
* timeout: 20,
|
|
43
|
-
* }
|
|
44
|
-
* }
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
function?: FunctionProps;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Creates the function that runs when the Script is created.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```js
|
|
55
|
-
* new Script(stack, "Api", {
|
|
56
|
-
* onCreate: "src/function.handler",
|
|
57
|
-
* })
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
onCreate?: FunctionDefinition;
|
|
61
|
-
/**
|
|
62
|
-
* Creates the function that runs on every deploy after the Script is created
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```js
|
|
66
|
-
* new Script(stack, "Api", {
|
|
67
|
-
* onUpdate: "src/function.handler",
|
|
68
|
-
* })
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
onUpdate?: FunctionDefinition;
|
|
72
|
-
/**
|
|
73
|
-
* Create the function that runs when the Script is deleted from the stack.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```js
|
|
77
|
-
* new Script(stack, "Api", {
|
|
78
|
-
* onDelete: "src/function.handler",
|
|
79
|
-
* })
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
onDelete?: FunctionDefinition;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/////////////////////
|
|
86
|
-
// Construct
|
|
87
|
-
/////////////////////
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The `Script` construct is a higher level CDK construct that makes it easy to run a script in a Lambda function during the deployment process.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
*
|
|
94
|
-
* ```js
|
|
95
|
-
* import { Script } from "@serverless-stack/resources";
|
|
96
|
-
*
|
|
97
|
-
* new Script(stack, "Script", {
|
|
98
|
-
* onCreate: "src/function.create",
|
|
99
|
-
* onUpdate: "src/function.update",
|
|
100
|
-
* onDelete: "src/function.delete",
|
|
101
|
-
* });
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
export class Script extends Construct {
|
|
105
|
-
/**
|
|
106
|
-
* The internally created onCreate `Function` instance.
|
|
107
|
-
*/
|
|
108
|
-
public readonly createFunction?: Fn;
|
|
109
|
-
/**
|
|
110
|
-
* The internally created onUpdate `Function` instance.
|
|
111
|
-
*/
|
|
112
|
-
public readonly updateFunction?: Fn;
|
|
113
|
-
/**
|
|
114
|
-
* The internally created onDelete `Function` instance.
|
|
115
|
-
*/
|
|
116
|
-
public readonly deleteFunction?: Fn;
|
|
117
|
-
protected readonly props: ScriptProps;
|
|
118
|
-
|
|
119
|
-
constructor(scope: Construct, id: string, props: ScriptProps) {
|
|
120
|
-
super(scope, id);
|
|
121
|
-
if ((props as any).function) this.checkDeprecatedFunction();
|
|
122
|
-
|
|
123
|
-
// Validate deprecated "function" prop
|
|
124
|
-
|
|
125
|
-
// Validate at least 1 function is provided
|
|
126
|
-
if (!props.onCreate && !props.onUpdate && !props.onDelete) {
|
|
127
|
-
throw new Error(
|
|
128
|
-
`Need to provide at least one of "onCreate", "onUpdate", or "onDelete" functions for the "${this.node.id}" Script`
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const root = scope.node.root as App;
|
|
133
|
-
this.props = props;
|
|
134
|
-
|
|
135
|
-
this.createFunction = this.createUserFunction("onCreate", props.onCreate);
|
|
136
|
-
this.updateFunction = this.createUserFunction("onUpdate", props.onUpdate);
|
|
137
|
-
this.deleteFunction = this.createUserFunction("onDelete", props.onDelete);
|
|
138
|
-
const crFunction = this.createCustomResourceFunction();
|
|
139
|
-
this.createCustomResource(root, crFunction);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Binds additional resources to the script
|
|
144
|
-
*
|
|
145
|
-
* @example
|
|
146
|
-
* ```js
|
|
147
|
-
* script.bind([STRIPE_KEY, bucket]);
|
|
148
|
-
* ```
|
|
149
|
-
*/
|
|
150
|
-
public bind(constructs: SSTConstruct[]): void {
|
|
151
|
-
this.createFunction?.bind(constructs);
|
|
152
|
-
this.updateFunction?.bind(constructs);
|
|
153
|
-
this.deleteFunction?.bind(constructs);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Grants additional permissions to the script
|
|
158
|
-
*
|
|
159
|
-
* @example
|
|
160
|
-
* ```js
|
|
161
|
-
* script.attachPermissions(["s3"]);
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
public attachPermissions(permissions: Permissions): void {
|
|
165
|
-
this.createFunction?.attachPermissions(permissions);
|
|
166
|
-
this.updateFunction?.attachPermissions(permissions);
|
|
167
|
-
this.deleteFunction?.attachPermissions(permissions);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
protected createUserFunction(
|
|
171
|
-
type: string,
|
|
172
|
-
fnDef?: FunctionDefinition
|
|
173
|
-
): Fn | undefined {
|
|
174
|
-
if (!fnDef) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// function is construct => return function directly
|
|
179
|
-
if (fnDef instanceof Fn) {
|
|
180
|
-
// validate live dev is not enabled
|
|
181
|
-
if (fnDef._isLiveDevEnabled) {
|
|
182
|
-
throw new Error(
|
|
183
|
-
`Live Lambda Dev cannot be enabled for functions in the Script construct. Set the "enableLiveDev" prop for the function to "false".`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return Fn.fromDefinition(
|
|
188
|
-
this,
|
|
189
|
-
`${type}Function`,
|
|
190
|
-
fnDef,
|
|
191
|
-
this.props.defaults?.function,
|
|
192
|
-
`The "defaults.function" cannot be applied if an instance of a Function construct is passed in. Make sure to define the "${type}" function using FunctionProps, so the Script construct can apply the "defaults.function" to them.`
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// function is string => create function
|
|
197
|
-
else if (typeof fnDef === "string") {
|
|
198
|
-
return Fn.fromDefinition(
|
|
199
|
-
this,
|
|
200
|
-
`${type}Function`,
|
|
201
|
-
{
|
|
202
|
-
handler: fnDef,
|
|
203
|
-
enableLiveDev: false,
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
timeout: 900,
|
|
207
|
-
...this.props.defaults?.function,
|
|
208
|
-
}
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// function is props => create function
|
|
213
|
-
return Fn.fromDefinition(
|
|
214
|
-
this,
|
|
215
|
-
`${type}Function`,
|
|
216
|
-
{
|
|
217
|
-
...fnDef,
|
|
218
|
-
enableLiveDev: false,
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
timeout: 900,
|
|
222
|
-
...this.props.defaults?.function,
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
private createCustomResourceFunction(): lambda.Function {
|
|
228
|
-
const handler = new lambda.Function(this, "ScriptHandler", {
|
|
229
|
-
code: lambda.Code.fromAsset(path.join(__dirname, "Script")),
|
|
230
|
-
runtime: lambda.Runtime.NODEJS_16_X,
|
|
231
|
-
handler: "index.handler",
|
|
232
|
-
timeout: cdk.Duration.minutes(15),
|
|
233
|
-
memorySize: 1024,
|
|
234
|
-
});
|
|
235
|
-
this.createFunction?.grantInvoke(handler);
|
|
236
|
-
this.updateFunction?.grantInvoke(handler);
|
|
237
|
-
this.deleteFunction?.grantInvoke(handler);
|
|
238
|
-
|
|
239
|
-
return handler;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
private createCustomResource(app: App, crFunction: lambda.Function): void {
|
|
243
|
-
// Note: "BuiltAt" is set to current timestamp to ensure the Custom
|
|
244
|
-
// Resource function is run on every update.
|
|
245
|
-
//
|
|
246
|
-
// Do not use the current timestamp in Live mode, b/c we want the
|
|
247
|
-
// this custom resource to remain the same in CloudFormation template
|
|
248
|
-
// when rebuilding infrastructure. Otherwise, there will always be
|
|
249
|
-
// a change when rebuilding infrastructure b/c the "BuildAt" property
|
|
250
|
-
// changes on each build.
|
|
251
|
-
const builtAt = app.local ? app.debugStartedAt : Date.now();
|
|
252
|
-
new cdk.CustomResource(this, "ScriptResource", {
|
|
253
|
-
serviceToken: crFunction.functionArn,
|
|
254
|
-
resourceType: "Custom::SSTScript",
|
|
255
|
-
properties: {
|
|
256
|
-
UserCreateFunction: this.createFunction?.functionName,
|
|
257
|
-
UserUpdateFunction: this.updateFunction?.functionName,
|
|
258
|
-
UserDeleteFunction: this.deleteFunction?.functionName,
|
|
259
|
-
UserParams: JSON.stringify(this.props.params || {}),
|
|
260
|
-
BuiltAt: builtAt,
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
private checkDeprecatedFunction(): void {
|
|
266
|
-
throw new Error(
|
|
267
|
-
`The "function" property has been replaced by "onCreate" and "onUpdate". More details on upgrading - https://docs.sst.dev/constructs/Script#upgrading-to-v0460`
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
}
|
package/src/constructs/Secret.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Construct } from "constructs";
|
|
2
|
-
import { App } from "./App.js";
|
|
3
|
-
import { SSTConstruct } from "./Construct.js";
|
|
4
|
-
import { ENVIRONMENT_PLACEHOLDER, getParameterPath, getParameterFallbackPath, FunctionBindingProps } from "./util/functionBinding.js";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The `Secret` construct is a higher level CDK construct that makes it easy to manage app secrets.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ### Using the minimal config
|
|
11
|
-
*
|
|
12
|
-
* ```js
|
|
13
|
-
* import { Config } from "@serverless-stack/resources";
|
|
14
|
-
*
|
|
15
|
-
* new Config.Secret(stack, "STRIPE_KEY");
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export class Secret extends Construct implements SSTConstruct {
|
|
19
|
-
public readonly id: string;
|
|
20
|
-
public readonly name: string;
|
|
21
|
-
|
|
22
|
-
constructor(scope: Construct, id: string) {
|
|
23
|
-
super(scope, id);
|
|
24
|
-
this.id = id;
|
|
25
|
-
this.name = id;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/** @internal */
|
|
29
|
-
public getConstructMetadata() {
|
|
30
|
-
return {
|
|
31
|
-
type: "Secret" as const,
|
|
32
|
-
data: {
|
|
33
|
-
name: this.name,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @internal */
|
|
39
|
-
public getFunctionBinding(): FunctionBindingProps {
|
|
40
|
-
const app = this.node.root as App;
|
|
41
|
-
return {
|
|
42
|
-
clientPackage: "config",
|
|
43
|
-
variables: {
|
|
44
|
-
value: {
|
|
45
|
-
environment: ENVIRONMENT_PLACEHOLDER,
|
|
46
|
-
// SSM parameters will be created manually via CLI
|
|
47
|
-
parameter: undefined,
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
permissions: {
|
|
51
|
-
"ssm:GetParameters": [
|
|
52
|
-
`arn:aws:ssm:${app.region}:${app.account}:parameter${getParameterPath(this, "value")}`,
|
|
53
|
-
`arn:aws:ssm:${app.region}:${app.account}:parameter${getParameterFallbackPath(this, "value")}`
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public static create<T extends string[]>(scope: Construct, ...parameters: T) {
|
|
60
|
-
const result: Record<string, Secret> = {};
|
|
61
|
-
for (const name of parameters) {
|
|
62
|
-
result[name] = new Secret(scope, name);
|
|
63
|
-
}
|
|
64
|
-
return result as { [key in T[number]]: Secret };
|
|
65
|
-
}
|
|
66
|
-
}
|