|
13 | 13 | from localstack.aws.api.events import PutEventsRequestEntry
|
14 | 14 | from localstack.aws.api.lambda_ import InvocationType
|
15 | 15 | from localstack.aws.api.s3 import (
|
| 16 | + AccountId, |
16 | 17 | BucketName,
|
17 | 18 | BucketRegion,
|
18 | 19 | Event,
|
@@ -97,6 +98,8 @@ class S3EventNotificationContext:
|
97 | 98 | key_name: ObjectKey
|
98 | 99 | xray: str
|
99 | 100 | bucket_location: BucketRegion
|
| 101 | + bucket_account_id: AccountId |
| 102 | + caller: AccountId |
100 | 103 | key_size: int
|
101 | 104 | key_etag: str
|
102 | 105 | key_version_id: str
|
@@ -154,8 +157,10 @@ def from_request_context(
|
154 | 157 | event_type=EVENT_OPERATION_MAP.get(request_context.operation.wire_name, ""),
|
155 | 158 | event_time=datetime.datetime.now(),
|
156 | 159 | region=request_context.region,
|
| 160 | + caller=request_context.account_id, # TODO: use it for `userIdentity` |
157 | 161 | bucket_name=bucket_name,
|
158 | 162 | bucket_location=bucket.location,
|
| 163 | + bucket_account_id=bucket.account_id, # TODO: use it for bucket owner identity |
159 | 164 | key_name=quote(key.name),
|
160 | 165 | key_etag=etag,
|
161 | 166 | key_size=key_size,
|
@@ -201,8 +206,10 @@ def from_request_context_native(
|
201 | 206 | event_type=EVENT_OPERATION_MAP.get(request_context.operation.wire_name, ""),
|
202 | 207 | event_time=datetime.datetime.now(),
|
203 | 208 | region=request_context.region,
|
| 209 | + caller=request_context.account_id, # TODO: use it for `userIdentity` |
204 | 210 | bucket_name=bucket_name,
|
205 | 211 | bucket_location=s3_bucket.bucket_region,
|
| 212 | + bucket_account_id=s3_bucket.bucket_account_id, # TODO: use it for bucket owner identity |
206 | 213 | key_name=quote(s3_object.key),
|
207 | 214 | key_etag=etag,
|
208 | 215 | key_size=key_size,
|
@@ -375,7 +382,7 @@ def _get_event_payload(
|
375 | 382 | awsRegion=ctx.region,
|
376 | 383 | eventTime=timestamp_millis(ctx.event_time),
|
377 | 384 | eventName=ctx.event_type.removeprefix("s3:"),
|
378 |
| - userIdentity={"principalId": "AIDAJDPLRKLG7UEXAMPLE"}, |
| 385 | + userIdentity={"principalId": "AIDAJDPLRKLG7UEXAMPLE"}, # TODO: use the real one? |
379 | 386 | requestParameters={
|
380 | 387 | "sourceIPAddress": "127.0.0.1"
|
381 | 388 | }, # TODO sourceIPAddress was previously extracted from headers ("X-Forwarded-For")
|
|
0 commit comments