s3
Lambda event
- class awsmate.s3.LambdaNotificationEvent(event_object: dict)
Bases:
LambdaEventMapping of the input event received by an AWS Lambda function triggered by AWS S3 Notification.
- Parameters:
event_object (dict) – The parameter
eventreceived by the AWS Lambda function handler.- Raises:
TypeError – If
event_objectis not adict.
Examples
>>> def lambda_handler(raw_event, context): >>> from awsmate.s3 import LambdaNotificationEvent >>> event = LambdaNotificationEvent(raw_event)
- object_key() str
Returns the key of the S3 object that is the subject of this notification.
The returned value is URL decoded.
- Returns:
The key of the S3 object.
- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure does not allow retrieving this key.
Examples
>>> event.objet_key() 'path/to/object'
- object_size() int | None
Returns the size of the S3 object that is the subject of this notification.
The size is only defined for object creation events, not for deletions.
- Returns:
The size of the S3 object in bytes or
Noneif not defined- Return type:
int
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure is invalid.
Examples
>>> event.objet_size() 43168
- object_etag() str | None
Returns the eTag of the S3 object that is the subject of this notification.
The eTag is only defined for object creation events, not for deletions.
- Returns:
The eTag of the S3 object or
Noneif not defined.- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure is invalid.
Examples
>>> event.objet_etag() '8b38dac3b5c48c44704ec934eabae5a2'
- object_url() str
Returns the complete URL of the S3 object that is the subject of this notification.
The returned value is URL decoded.
- Returns:
The URL of the S3 object.
- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure is invalid.
Examples
>>> event.object_url() 's3://my-example-s3-bucket/path/to/object'
- bucket_name() str
Returns the name of the S3 bucket that is the subject of this notification.
- Returns:
The name of the S3 bucket.
- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure does not allow retrieving this bucket name.
Examples
>>> event.bucket_name() 'my-example-s3-bucket'
- bucket_arn() str
Returns the arn of the S3 bucket that is the subject of this notification.
- Returns:
The arn of the S3 bucket.
- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure does not allow retrieving this bucket arn.
Examples
>>> event.bucket_arn() 'arn:aws:s3:::my-example-s3-bucket'
- event_name() str
Returns the name of the S3 event that triggered this notification.
- Returns:
The S3 event name.
- Return type:
str
- Raises:
awsmate.lambdafunction.AwsEventSpecificationError – If the event structure does not allow retrieving this event name.
Examples
>>> event.event_name() 'ObjectCreated:Put'