Skip to content

Commit

Permalink
fix: don't error on failed lambda update
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoffelen committed Sep 7, 2024
1 parent 795eadf commit 29f2b80
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions packages/api/src/events/auto-trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,33 +98,37 @@ export const autoTrace = async () => {
console.log(`Found ${lambdasWithoutLayer.length} lambdas to update`);

for (const lambda of lambdasWithoutLayer) {
const updateFunctionConfigurationCommand =
new UpdateFunctionConfigurationCommand({
FunctionName: lambda.FunctionName,
Layers: [
...(lambda.Layers || [])
.map((layer) => layer.Arn)
.filter((arn) => !arn.startsWith(arnBase)),
process.env.LAMBDA_LAYER_ARN,
],
Environment: {
...(lambda.Environment || {}),
Variables: {
...(lambda.Environment?.Variables || {}),
AUTO_TRACE_HOST: edgeEndpoint,
AWS_LAMBDA_EXEC_WRAPPER: lambdaExecWrapper,
try {
const updateFunctionConfigurationCommand =
new UpdateFunctionConfigurationCommand({
FunctionName: lambda.FunctionName,
Layers: [
...(lambda.Layers || [])
.map((layer) => layer.Arn)
.filter((arn) => !arn.startsWith(arnBase)),
process.env.LAMBDA_LAYER_ARN,
],
Environment: {
...(lambda.Environment || {}),
Variables: {
...(lambda.Environment?.Variables || {}),
AUTO_TRACE_HOST: edgeEndpoint,
AWS_LAMBDA_EXEC_WRAPPER: lambdaExecWrapper,
},
},
},
});

const res = await new LambdaClient().send(
updateFunctionConfigurationCommand,
);
console.log(res);

console.log(`✓ Updated ${lambda.FunctionName}`);

// TODO: save function info in DynamoDB
});

const res = await new LambdaClient().send(
updateFunctionConfigurationCommand,
);
console.log(res);

console.log(`✓ Updated ${lambda.FunctionName}`);
// TODO: save function info in DynamoDB
} catch (e) {
console.log(`✗ Failed to update ${lambda.FunctionName}`);
console.error(e);
}
}

await releaseLock("auto-trace");
Expand Down

0 comments on commit 29f2b80

Please sign in to comment.