Skip to content

Commit ad23ea9

Browse files
author
ljacobsson
committed
fix local debug issue for large stacks
1 parent 2739024 commit ad23ea9

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "samp-cli",
3-
"version": "1.0.23",
3+
"version": "1.0.24",
44
"description": "CLI tool for extended productivity with AWS Serverless Application Model (SAM)",
55
"main": "index.js",
66
"scripts": {

src/commands/local/lib/connect.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const timer = new Date().getTime();
4747
let certData, endpoint, stack, functions, template;
4848
const policyName = "lambda-debug-policy";
4949

50-
const packageVersion = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', '..','..', 'package.json'))).version;
50+
const packageVersion = JSON.parse(fs.readFileSync(path.join(__dirname, '..', '..', '..', '..', 'package.json'))).version;
5151

5252
const zipFilePath = path.join(os.homedir(), '.lambda-debug', `relay-${accountId}-${packageVersion}.zip`);
5353

@@ -144,8 +144,15 @@ if (!fs.existsSync(".lambda-debug")) {
144144
const stackName = envConfig.stack_name;
145145

146146
template = yamlParse(fs.readFileSync(findSAMTemplateFile('.')).toString());
147-
148147
stack = await cfnClient.send(new ListStackResourcesCommand({ StackName: stackName }));
148+
let token = stack.NextToken;
149+
if (token) {
150+
do {
151+
const page = await cfnClient.send(new ListStackResourcesCommand({ StackName: stackName, NextToken: token }));
152+
stack.StackResourceSummaries = stack.StackResourceSummaries.concat(page.StackResourceSummaries);
153+
token = page.NextToken;
154+
} while (token);
155+
}
149156

150157
functions = Object.keys(template.Resources).filter(key => template.Resources[key].Type === 'AWS::Serverless::Function');
151158
if (process.env.includeFunctions) {
@@ -173,7 +180,7 @@ if (!fs.existsSync(".lambda-debug")) {
173180
console.log(`Error installing npm packages in relay folder: ${npmInstall.error}`);
174181
process.exit(1);
175182
}
176-
183+
177184
//create zip file of relay folder
178185
const output = fs.createWriteStream(zipFilePath);
179186
const archive = archiver('zip', {
@@ -276,7 +283,7 @@ client.on('connect', async function () {
276283

277284
client.on('message', async function (topic, message) {
278285
const obj = JSON.parse(message.toString());
279-
process.env = {...obj.envVars, LOCAL_DEBUG: true};
286+
process.env = { ...obj.envVars, LOCAL_DEBUG: true };
280287
const result = await routeEvent(obj.event, obj.context, stack, functionSources);
281288
client.publish(`lambda-debug/callback/${mac}/${obj.sessionId}`, JSON.stringify(result || {}));
282289
});

0 commit comments

Comments
 (0)