Hrushikesh Patel
Hrushikesh Patel

Reputation: 296

How to know which s3 bucket trigger which lambda?

How to know which s3 bucket trigger which lambda without going to all lambdas?

Upvotes: 4

Views: 5752

Answers (3)

Mahesh
Mahesh

Reputation: 159

You can look into these triggers under a bucket events itself. When you open a s3 bucket, navigate to Properties and under that Events. You can however delete or edit the resource triggered from that panel. Hope it helps

Upvotes: 6

Brandon Miller
Brandon Miller

Reputation: 5065

This can be a bit difficult since the command line options for Lambda require that you use aws lambda get-policy in order to find out which resources are allowed to perform the lambda:InvokeFunction action on a given function. These permissions aren't shown as part of the lambda configuration for aws lambda get-function-configuration. Use bash and jq to get a list of functions and spit out their allowed invokers. Like this:

aws lambda list-functions | jq '.Functions[].FunctionName' --raw-output | while read f; do
  policy=$( aws lambda get-policy --function-name ${f} | jq '.Policy | fromjson | .Statement[] | select(.Effect=="Allow") | select(.Action=="lambda:InvokeFunction") | .Condition.ArnLike[]' --raw-output )
  echo "FUNCTION ${f} CAN BE INVOKED FROM:"
  echo ${policy}
done

This will list the arn of the resources that are allowed to use the action lambda:InvokeFunction on the all Lambda functions returned from list-functions.

Upvotes: 4

user189198
user189198

Reputation:

When you set up triggers on your S3 Bucket, you can select which Lambda function is invoked.

Check out this document for more information: https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html.

Here's a more comprehensive document that deep dives on S3 event notifications: https://docs.aws.amazon.com/AmazonS3/latest/user-guide/enable-event-notifications.html

If you select the Lambda Function destination type, do the following:

In Lambda Function, type or choose the name of the Lambda function that you want to receive notifications from Amazon S3.

If you don't have any Lambda functions in the region that contains your bucket, you'll be prompted to enter a Lambda function ARN. In Lambda Function ARN, type the ARN of the Lambda function that you want to receive notifications from Amazon S3.

(Optional) You can also choose Add Lambda function ARN from the menu and type the ARN of the Lambda function in Lambda function ARN.

Upvotes: 0

Related Questions