@kirkelliott/zap 0.1.6 → 0.1.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +42 -0
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -152,6 +152,48 @@ program
152
152
  const files = await walkZap(demoDir, 'demo');
153
153
  await Promise.all(files.map(({ filePath, key }) => deployFile(b, filePath, key)));
154
154
  });
155
+ program
156
+ .command('debug')
157
+ .description('show Lambda function URL auth config and resource-based policy')
158
+ .action(async () => {
159
+ const cfg = readConfig();
160
+ const region = cfg.region ?? 'us-east-1';
161
+ const fn = cfg.functionArn ?? cfg.function ?? 'zap-runtime';
162
+ const lambda = new client_lambda_1.LambdaClient({ region });
163
+ try {
164
+ const { Configuration } = await lambda.send(new client_lambda_1.GetFunctionCommand({ FunctionName: fn }));
165
+ console.log(`state: ${Configuration?.State} (${Configuration?.StateReason ?? 'ok'})`);
166
+ }
167
+ catch (err) {
168
+ console.log('function: not found -', err.message);
169
+ }
170
+ try {
171
+ const { AuthType, FunctionUrl } = await lambda.send(new client_lambda_1.GetFunctionUrlConfigCommand({ FunctionName: fn }));
172
+ console.log(`url: ${FunctionUrl}`);
173
+ console.log(`auth type: ${AuthType}`);
174
+ }
175
+ catch (err) {
176
+ console.log('function url: not found -', err.message);
177
+ }
178
+ try {
179
+ const { Policy } = await lambda.send(new client_lambda_1.GetPolicyCommand({ FunctionName: fn }));
180
+ console.log('\nresource policy:');
181
+ console.log(JSON.stringify(JSON.parse(Policy), null, 2));
182
+ }
183
+ catch (err) {
184
+ console.log('\nresource policy: none -', err.message);
185
+ }
186
+ try {
187
+ const payload = { version: '2.0', rawPath: '/ping', rawQueryString: '', headers: {}, requestContext: { http: { method: 'GET', path: '/ping' } }, isBase64Encoded: false };
188
+ const { Payload, FunctionError } = await lambda.send(new client_lambda_1.InvokeCommand({ FunctionName: fn, Payload: JSON.stringify(payload) }));
189
+ const result = Payload ? JSON.parse(Buffer.from(Payload).toString()) : null;
190
+ console.log(`\ndirect invoke: ${FunctionError ? 'ERROR' : 'ok'}`);
191
+ console.log(JSON.stringify(result, null, 2));
192
+ }
193
+ catch (err) {
194
+ console.log('\ndirect invoke failed:', err.message);
195
+ }
196
+ });
155
197
  program
156
198
  .command('repair')
157
199
  .description('re-apply Lambda Function URL public access permissions')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kirkelliott/zap",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Drop a .zap file in S3. It becomes an API endpoint.",
5
5
  "main": "dist/handler.js",
6
6
  "bin": {