Skip to content

Commit

Permalink
fix: ignore inline funcs during cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Aug 23, 2023
1 parent 50b30f9 commit cd310dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "samp-cli",
"version": "1.0.47",
"version": "1.0.48",
"description": "CLI tool for extended productivity with AWS Serverless Application Model (SAM)",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion src/commands/local/lib/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ const updatePromises = functions.map(async functionName => {
try {
const func = template.Resources[functionName];
const physicalId = stackResources.find(resource => resource.LogicalResourceId === functionName).PhysicalResourceId;

validateNotIntrinsicFunction(func.Properties.Timeout, "Timeout", "number");
validateNotIntrinsicFunction(func.Properties.MemorySize, "MemorySize", "number");
validateNotIntrinsicFunction(func.Properties.Handler, "Handler", "string");
validateNotIntrinsicFunction(func.Properties.Runtime, "Runtime", "string");
await lambdaClient.send(new UpdateFunctionConfigurationCommand({
FunctionName: physicalId,
Timeout: func.Properties.Timeout,
Expand Down Expand Up @@ -104,6 +107,13 @@ const updatePromises = functions.map(async functionName => {

});

function validateNotIntrinsicFunction(obj, name, expectedDataType) {
if (typeof obj === "object") {
console.log(`Tried to restore ${name}, but it's set using an intrinsic function which isn't supported. Please use a ${expectedDataType} instead`);
process.exit(1);
}
}

// Wait for all promises to resolve
await Promise.all(updatePromises);
console.log("Finished restoring functions");
Expand Down

0 comments on commit cd310dd

Please sign in to comment.