The CDK Construct Library for AWS::S3ObjectLambda
Project description
AWS::S3ObjectLambda Construct Library
---AWS CDK v1 has reached End-of-Support on 2023-06-01. This package is no longer being updated, and users should migrate to AWS CDK v2.
For more information on how to migrate, see the Migrating to AWS CDK v2 guide.
This construct library allows you to define S3 object lambda access points.
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_s3objectlambda as s3objectlambda
import aws_cdk.core as cdk
stack = cdk.Stack()
bucket = s3.Bucket(stack, "MyBucket")
handler = lambda_.Function(stack, "MyFunction",
runtime=lambda_.Runtime.NODEJS_14_X,
handler="index.handler",
code=lambda_.Code.from_asset("lambda.zip")
)
s3objectlambda.AccessPoint(stack, "MyObjectLambda",
bucket=bucket,
handler=handler,
access_point_name="my-access-point",
payload={
"prop": "value"
}
)
Handling range and part number requests
Lambdas are currently limited to only transforming GetObject
requests. However, they can additionally support GetObject-Range
and GetObject-PartNumber
requests, which needs to be specified in the access point configuration:
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_s3objectlambda as s3objectlambda
import aws_cdk.core as cdk
stack = cdk.Stack()
bucket = s3.Bucket(stack, "MyBucket")
handler = lambda_.Function(stack, "MyFunction",
runtime=lambda_.Runtime.NODEJS_14_X,
handler="index.handler",
code=lambda_.Code.from_asset("lambda.zip")
)
s3objectlambda.AccessPoint(stack, "MyObjectLambda",
bucket=bucket,
handler=handler,
access_point_name="my-access-point",
supports_get_object_range=True,
supports_get_object_part_number=True
)
Pass additional data to Lambda function
You can specify an additional object that provides supplemental data to the Lambda function used to transform objects. The data is delivered as a JSON payload to the Lambda:
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_s3objectlambda as s3objectlambda
import aws_cdk.core as cdk
stack = cdk.Stack()
bucket = s3.Bucket(stack, "MyBucket")
handler = lambda_.Function(stack, "MyFunction",
runtime=lambda_.Runtime.NODEJS_14_X,
handler="index.handler",
code=lambda_.Code.from_asset("lambda.zip")
)
s3objectlambda.AccessPoint(stack, "MyObjectLambda",
bucket=bucket,
handler=handler,
access_point_name="my-access-point",
payload={
"prop": "value"
}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for aws-cdk.aws-s3objectlambda-1.204.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cbd99ceb48afe3f74f9b5e06ffe3927c39243baaddcd94418dda2384624988e |
|
MD5 | afba22981e771afaeb2f8582547d8fdf |
|
BLAKE2b-256 | 9500afc46024bcbf5eaa33d297fb6414e909ff8410406e7b59dc08bf2e13bb77 |
Hashes for aws_cdk.aws_s3objectlambda-1.204.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46341be1b55ac659789eeaf4f239ab6707a2665e48675efbdbbda1765da7bc32 |
|
MD5 | 4561359ebffb6476c02bb0377a67cbac |
|
BLAKE2b-256 | eb14be30e2e8b99ee6d865d7e960d197c45bf09fd290269b7e57c3e125d87c89 |