Package software.amazon.awscdk.services.s3objectlambda


@Stability(Experimental) @Deprecated package software.amazon.awscdk.services.s3objectlambda
Deprecated.

AWS::S3ObjectLambda Construct Library

---

End-of-Support

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 software.amazon.awscdk.services.lambda.*;
 import software.amazon.awscdk.services.s3.*;
 import software.amazon.awscdk.services.s3objectlambda.*;
 import software.amazon.awscdk.core.*;
 
 Stack stack = new Stack();
 Bucket bucket = new Bucket(stack, "MyBucket");
 Function handler = Function.Builder.create(stack, "MyFunction")
         .runtime(Runtime.NODEJS_14_X)
         .handler("index.handler")
         .code(Code.fromAsset("lambda.zip"))
         .build();
 AccessPoint.Builder.create(stack, "MyObjectLambda")
         .bucket(bucket)
         .handler(handler)
         .accessPointName("my-access-point")
         .payload(Map.of(
                 "prop", "value"))
         .build();
 

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 software.amazon.awscdk.services.lambda.*;
 import software.amazon.awscdk.services.s3.*;
 import software.amazon.awscdk.services.s3objectlambda.*;
 import software.amazon.awscdk.core.*;
 
 Stack stack = new Stack();
 Bucket bucket = new Bucket(stack, "MyBucket");
 Function handler = Function.Builder.create(stack, "MyFunction")
         .runtime(Runtime.NODEJS_14_X)
         .handler("index.handler")
         .code(Code.fromAsset("lambda.zip"))
         .build();
 AccessPoint.Builder.create(stack, "MyObjectLambda")
         .bucket(bucket)
         .handler(handler)
         .accessPointName("my-access-point")
         .supportsGetObjectRange(true)
         .supportsGetObjectPartNumber(true)
         .build();
 

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 software.amazon.awscdk.services.lambda.*;
 import software.amazon.awscdk.services.s3.*;
 import software.amazon.awscdk.services.s3objectlambda.*;
 import software.amazon.awscdk.core.*;
 
 Stack stack = new Stack();
 Bucket bucket = new Bucket(stack, "MyBucket");
 Function handler = Function.Builder.create(stack, "MyFunction")
         .runtime(Runtime.NODEJS_14_X)
         .handler("index.handler")
         .code(Code.fromAsset("lambda.zip"))
         .build();
 AccessPoint.Builder.create(stack, "MyObjectLambda")
         .bucket(bucket)
         .handler(handler)
         .accessPointName("my-access-point")
         .payload(Map.of(
                 "prop", "value"))
         .build();
 
Deprecated: 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 https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html