Skip to content

Commit

Permalink
fix: use method with higher rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoffelen committed Sep 7, 2024
1 parent 65c9578 commit 7a1a39a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ provider:
- lambda:ListFunctions
- lambda:UpdateFunctionConfiguration
- lambda:GetLayerVersion
- lambda:GetFunction
- lambda:ListTags
Resource:
- "*"
Expand Down
9 changes: 6 additions & 3 deletions packages/api/src/events/auto-trace.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {
GetFunctionCommand,
LambdaClient,
ListFunctionsCommand,
ListTagsCommand,
UpdateFunctionConfigurationCommand,
} from "@aws-sdk/client-lambda";
import {
ApiGatewayV2Client,
GetApisCommand,
} from "@aws-sdk/client-apigatewayv2";
import pLimit from "p-limit";

import { acquireLock, releaseLock } from "../lib/locks";
import Logger from "../lib/logger";
import { put } from "../lib/database";
Expand Down Expand Up @@ -79,10 +80,12 @@ const updateLambda = async (lambda, arnBase, edgeEndpoint) => {
};

const getLambdaTags = async (lambda) => {
// try not to run into the 100 requests per second limit
await new Promise((resolve) => setTimeout(resolve, 250));
const lambdaClient = new LambdaClient();
const { Tags } = await lambdaClient.send(
new ListTagsCommand({
Resource: lambda.FunctionArn,
new GetFunctionCommand({
FunctionName: lambda.FunctionName,
}),
);

Expand Down

0 comments on commit 7a1a39a

Please sign in to comment.