Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
Find who invoked AWS Lambda function

I have Lambda function written in Python 3.7.

This Lambda function is invoked by some users through AWS CLI using:

  aws lambda invoke --function-name stXXX-XXX out --log-type Tail

I want to capture who invoked my Lambda function through AWS CLI in my code.

As there any way I can find who invoke my Lambda function in python boto3 code?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Yes. Generally for that you would have to enable logging data event in CloudTrail:

  • Logging AWS Lambda API calls with AWS CloudTrail

By default logging of lambda invocations is disabled as it can lead to a lot of logs.

The log event contains information about what IAM user or role invoked the function. For example:

      "userIdentity": {
        "type": "IAMUser",
        "principalId": "A1B2C3D4E5F6G7EXAMPLE",
        "arn": "arn:aws:iam::999999999999:user/myUserName",
        "accountId": "999999999999",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "userName": "myUserName"
      },
over 4 years ago · Santiago Trujillo Report

0

It appears that your situation is:

  • You have an AWS Lambda function that Starts an Amazon EC2 instance
  • You want the Lambda function to detect who has made the request and then confirm that they are on an authorization list before starting the Amazon EC2 instance

Unfortunately, information about 'who' invoked the Lambda function (or, more specifically, which IAM entity invoked it) is not available.

The AWS Lambda context object in Python does not provide this information to the Lambda function.

A "more correct" way would be to control the IAM permissions that determine who can invoke this Lambda function. Only correctly authorized persons should have permission to call lambda:Invoke on this function. Similarly, it is important to limit who can use iam:PassRole on the IAM Role used by this function, since it has permissions to start the EC2 instance and it could be used on other functions unless PassRole is restricted.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!