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.157.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d60185df16e92c538785afa14034bd8d35780af5e1ae8d9f11f71ede5366ea8b |
|
MD5 | ea2a77ddc313db47bd9b3a901c8064a4 |
|
BLAKE2b-256 | 3f38ef59ef1a7e6220348f0fd3785c79a3873d3be8b79b42a3791c0431681809 |
Hashes for aws_cdk.aws_s3objectlambda-1.157.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b19d615d86728ab370d00643928c48a0ed0b5c5fe90af8e32be828ed5e11d70 |
|
MD5 | b652562dbad657512f400c20502be0c3 |
|
BLAKE2b-256 | 49870cbf4fc5ecc13f6f2fc7ff93f860a9f2e3447663ea21adce9894c1eb65d5 |