Skip to main content

The CDK Construct Library for AWS::S3ObjectLambda

Project description

AWS::S3ObjectLambda Construct Library

---

cfn-resources: Stable

All classes with the Cfn prefix in this module (CFN Resources) are always stable and safe to use.

cdk-constructs: Experimental

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

aws-cdk.aws-s3objectlambda-1.186.1.tar.gz (73.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_cdk.aws_s3objectlambda-1.186.1-py3-none-any.whl (72.7 kB view details)

Uploaded Python 3

File details

Details for the file aws-cdk.aws-s3objectlambda-1.186.1.tar.gz.

File metadata

File hashes

Hashes for aws-cdk.aws-s3objectlambda-1.186.1.tar.gz
Algorithm Hash digest
SHA256 7d5df6637ad628712b7837fdcb8e52b588ee35a009db2c94a2fb93e175b26742
MD5 37e4c75a2d3b6353a411c5ce8134149a
BLAKE2b-256 0bf0cb8946bf7a913ec92f6199afc2776c6aad7258579ce070a77194bbb5a46d

See more details on using hashes here.

File details

Details for the file aws_cdk.aws_s3objectlambda-1.186.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_cdk.aws_s3objectlambda-1.186.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dce2a4042f16bbe60cc0b2431677a32f0cf2cfc8ee85e1390356e2e4c824a922
MD5 5099081c4f22b2457a7d4d5ccb3b3c27
BLAKE2b-256 0a5c601c2458c08b733f2e4517c57579a0df5698ea60099e13af96ae3412169b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page