admin管理员组

文章数量:1122832

I was reading some documentations, but could not find a way to see them. I was trying to use Cloudtrail, but it seems like it only shows an event record for the api call performed.

{
"eventVersion": "1.09",
"userIdentity": {
    "type": "AssumedRole",
    ...
    }
},
"eventTime": "2024-11-22T16:52:55Z",
"eventSource": "logs.amazonaws",
"eventName": "CreateLogStream",
"awsRegion": "us-east-1",
"sourceIPAddress": ...,
"userAgent": ...,
"requestParameters": {
    ...
},
"responseElements": null,
"requestID": "df538....b987-2f...24a",
"eventID": "f3e....9f7-8aaf-e00...3d21",
"readOnly": false,
"eventType": "AwsApiCall",
"apiVersion": "20140328",
"managementEvent": true,
"recipientAccountId": "....",
"eventCategory": "Management",
"tlsDetails": {

    ...
}

}

How can we see the actual request context? e.g. when an lambda function makes a request to download an object in S3. I am hopping to see the request context,so I can debug the condition section of my policy by seeing what keys are present.

I was reading some documentations, but could not find a way to see them. I was trying to use Cloudtrail, but it seems like it only shows an event record for the api call performed.

{
"eventVersion": "1.09",
"userIdentity": {
    "type": "AssumedRole",
    ...
    }
},
"eventTime": "2024-11-22T16:52:55Z",
"eventSource": "logs.amazonaws.com",
"eventName": "CreateLogStream",
"awsRegion": "us-east-1",
"sourceIPAddress": ...,
"userAgent": ...,
"requestParameters": {
    ...
},
"responseElements": null,
"requestID": "df538....b987-2f...24a",
"eventID": "f3e....9f7-8aaf-e00...3d21",
"readOnly": false,
"eventType": "AwsApiCall",
"apiVersion": "20140328",
"managementEvent": true,
"recipientAccountId": "....",
"eventCategory": "Management",
"tlsDetails": {

    ...
}

}

How can we see the actual request context? e.g. when an lambda function makes a request to download an object in S3. I am hopping to see the request context,so I can debug the condition section of my policy by seeing what keys are present.

Share Improve this question edited Nov 22, 2024 at 19:48 user3463521 asked Nov 22, 2024 at 17:00 user3463521user3463521 5782 gold badges7 silver badges18 bronze badges 1
  • Did you check on S3 events instead (PutObject or GetObject)? – fa44 Commented Nov 22, 2024 at 21:22
Add a comment  | 

1 Answer 1

Reset to default 0

CloudTrail is primarily designed to log AWS API calls and events, not the payload or the full request context. To capture the full context or actual content of requests (e.g., a Lambda function downloading an S3 object), you need to use additional configuration.
1 - You can enable S3 Access Logs

2 - Use Lambda’s Logging Mechanisms

logging.info(f"Downloaded object {object_key} from {bucket_name}")
logging.info(f"Response metadata: {response['ResponseMetadata']}")

3 - Enable S3 Object-Level CloudTrail Data Events

These methods, used in combination, will give you a comprehensive view of the actual requests and their contexts. Let me know if you need help implementing any of these!

本文标签: amazon web servicesHow can see what request context looks like for an AWS requestStack Overflow