The CDK Construct Library for AWS::S3ObjectLambda
Project description
AWS::S3ObjectLambda Construct Library
---All classes with the
Cfn
prefix in this module (CFN Resources) are always stable and safe to use.
The APIs of higher level constructs in this module are experimental and under active development. They are subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model and breaking changes will be announced in the release notes. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.
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.193.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e774722705ecc10276a4131b931e614451fc6f03c85ea3e519cbac0ed55bb99c |
|
MD5 | 590eb6d50728e50be14a9488aa9ecd18 |
|
BLAKE2b-256 | 60716517ad299a3439e28f7318c4d8d5d52995f8123024f2cfb4ee52613c8543 |
Hashes for aws_cdk.aws_s3objectlambda-1.193.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff5e7215e9fdc6cfa9d61d1463bf0f7942816103dd9eed978b879c4e7e1784b2 |
|
MD5 | b8f00897e70f1b2d889ad96b1140d30a |
|
BLAKE2b-256 | 4c1691d28ac66ebb8828e987c09acb4756c006cb506b0c24f4cd6710c7855a66 |