Package Exports
- @architect/plugin-lambda-invoker
- @architect/plugin-lambda-invoker/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@architect/plugin-lambda-invoker) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@architect/plugin-lambda-invoker
Interactively invoke Lambdas in Architect Sandbox with arbitrary events
Install
Into your existing Architect project:
npm i @architect/plugin-lambda-invoker --save-devAdd the following to your Architect project manifest (usually app.arc):
@plugins
architect/plugin-lambda-invokerUsage
While Sandbox is running, type i in your terminal to bring up the Lambda invocation menu. Then select the Lambda you'd like to invoke.
By default, this plugin will populate your menu with all @events, @queues, @scheduled, and @tables-streams; you can limit this menu (or expand it with additional pragmas) by adding the following setting to a pref[erence]s.arc file:
@sandbox
invoker http scheduled # This would populate @http + @scheduled Lambdas, and ignore all othersTip: you can navigate the invocation menu by typing numbers (zero-indexed)!
Invocation mocks
By default, Lambdas are invoked with an empty payload ({}); if you'd like to invoke your Lambdas with arbitrary payloads, create a file containing invocation mocks.
Invocation mock files live in your root with one of these filenames: sandbox-invoke-mocks.json or sandbox-invoke-mocks.js. These files should be structured like so:
Assuming this project manifest:
@events
background-task
@queues
analytics
@scheduled
backup-databaseIf you wanted to add one or more mocks to each of the three Lambdas above, create the following sandbox-invoke-mocks.js (or equivalent JSON) file with the format of [pragmaName][lambdaName][mockName]:
module.exports = {
events: {
'background-task': {
'my-first-mock': { /* payload */ },
'another-mock': { /* payload */ },
}
},
queues: {
analytics: {
'one-more-mock': { /* payload */ },
'just-a-mock': { /* payload */ },
}
},
scheduled: {
'backup-database': {
'a-mock-for-this': { /* payload */ },
'the-last-mock': { /* payload */ },
}
},
}Tip: when using
sandbox-invoke-mocks.js, you can dynamically (synchronously) generate mocks on startup
