Skip to content

The sharedEventID about CloudTrail Lambda Events of Invoke Function

0

I invoke a lambda function asynchronously, then I get two CloudTrail events: Invoke Event by IAM User and InvokeExecution by AWSService. But the sharedEventID is only present in events originating from InvokeExecution Event. I think both events should either have a sharedEventID or not have one at all. It doesn't make sense for only one event to have a sharedEventID while the other does not.

{
  "eventVersion":"1.08",
  "userIdentity":{
    "type":"IAMUser",
    "principalId":"AIDAUU4J64HSSSSSSSSSS",
    "arn":"arn:aws:iam::319727000000:user/zhuanggong",
    "accountId":"319727000000",
    "accessKeyId":"AIDAUU4J64HSSSSSSSSSS",
    "userName":"zhuanggong"
  },
  "eventTime":"2024-05-31T03:03:20Z",
  "eventSource":"lambda.amazonaws.com",
  "eventName":"Invoke",
  "awsRegion":"us-east-1",
  "sourceIPAddress":"140.205.11.7",
  "userAgent":"aws-cli/2.15.61 md/awscrt#0.19.19 ua/2.0 os/macos#23.4.0 md/arch#x86_64 lang/python#3.11.8 md/pyimpl#CPython cfg/retry-mode#standard md/installer#exe md/prompt#off md/command#lambda.invoke",
  "requestParameters":{
    "functionName":"arn:aws:lambda:us-east-1:319727000000:function:hello-world",
    "invocationType":"Event"
  },
  "responseElements":null,
  "additionalEventData":{
    "functionVersion":"arn:aws:lambda:us-east-1:319727000000:function:hello-world:$LATEST"
  },
  "requestID":"b262a886-720a-4417-a9b5-65f8682b403e",
  "eventID":"11387d14-aff5-482d-90fd-e0988f0afb03",
  "readOnly":false,
  "resources":[
    {
      "accountId":"319727000000",
      "type":"AWS::Lambda::Function",
      "ARN":"arn:aws:lambda:us-east-1:319727000000:function:hello-world"
    }
  ],
  "eventType":"AwsApiCall",
  "managementEvent":false,
  "recipientAccountId":"319727000000",
  "eventCategory":"Data",
  "tlsDetails":{
    "tlsVersion":"TLSv1.2",
    "clientProvidedHostHeader":"lambda.us-east-1.amazonaws.com"
  }
}
{
    "eventVersion":"1.08",
    "userIdentity":{
        "type":"AWSService",
        "invokedBy":"lambda.amazonaws.com"
    },
    "eventTime":"2024-05-31T03:03:21Z",
    "eventSource":"lambda.amazonaws.com",
    "eventName":"InvokeExecution",
    "awsRegion":"us-east-1",
    "sourceIPAddress":"lambda.amazonaws.com",
    "userAgent":"lambda.amazonaws.com",
    "requestParameters":{
        "functionName":"arn:aws:lambda:us-east-1:319727000000:function:hello-world",
        "logType":"None",
        "contentType":"application/json"
    },
    "responseElements":null,
    "additionalEventData":{
        "functionVersion":"arn:aws:lambda:us-east-1:319727000000:function:hello-world:$LATEST"
    },
    "requestID":"b262a886-720a-4417-a9b5-65f8682b403e",
    "eventID":"e13a6695-8212-49d8-aee0-061977853a3d",
    "readOnly":false,
    "resources":[
        {
            "accountId":"319727000000",
            "type":"AWS::Lambda::Function",
            "ARN":"arn:aws:lambda:us-east-1:319727000000:function:hello-world"
        }
    ],
    "eventType":"AwsApiCall",
    "managementEvent":false,
    "recipientAccountId":"319727000000",
    "sharedEventID":"35fe88d8-4f7e-4fe8-bbf7-99e920afe8b3",
    "eventCategory":"Data"
}

asked 2 years ago711 views

1 Answer
1

Hi - This documentation explains how lambda async invocation works - https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#async-overview

For asynchronous invocation, Lambda places the event in a queue and returns a success response without additional information. A separate process reads events from the queue and sends them to your function. To invoke a function asynchronously, set the invocation type parameter to Event.

So even though these events happened very close to each other, they are two separate events. If you need to tie these two events together, you can use requestID field, which has same ID for both.

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

  • Hi, thanks for your answer. But I am still confused, what is sharedEventID used for? I read the CloudTrail documentation https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-record-contents.html , but I still can't understand it.

  • hi - As stated in the documentation, sharedEventID is a GUID generated by CloudTrail to uniquely identify CloudTrail events from the same AWS action that is sent to different AWS accounts. It is present only when CloudTrail events are delivered to multiple accounts.

  • There is a sharedEventID in the InvokeExecution event which the eventId is e13a6695-8212-49d8-aee0-061977853a3d, so will this event be sent to other accounts?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.