Never Propel Marmalade

    @aws-cdk/aws-s3objectlambda-alpha
    TypeScript icon, indicating that this package has built-in type declarations

    2.38.0-alpha.0 • Public • Published

    AWS::S3ObjectLambda Construct Library


    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 * as lambda from 'aws-cdk-lib/aws-lambda';
    import * as s3 from 'aws-cdk-lib/aws-s3';
    import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha';
    import * as cdk from 'aws-cdk-lib';
    
    const stack = new cdk.Stack();
    const bucket = new s3.Bucket(stack, 'MyBucket');
    const handler = new lambda.Function(stack, 'MyFunction', {
    	runtime: lambda.Runtime.NODEJS_14_X,
    	handler: 'index.handler',
    	code: lambda.Code.fromAsset('lambda.zip'),
    });
    new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', {
    	bucket,
    	handler,
    	accessPointName: '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 * as lambda from 'aws-cdk-lib/aws-lambda';
    import * as s3 from 'aws-cdk-lib/aws-s3';
    import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha';
    import * as cdk from 'aws-cdk-lib';
    
    const stack = new cdk.Stack();
    const bucket = new s3.Bucket(stack, 'MyBucket');
    const handler = new lambda.Function(stack, 'MyFunction', {
    	runtime: lambda.Runtime.NODEJS_14_X,
    	handler: 'index.handler',
    	code: lambda.Code.fromAsset('lambda.zip'),
    });
    new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', {
    	bucket,
    	handler,
    	accessPointName: 'my-access-point',
    	supportsGetObjectRange: true,
    	supportsGetObjectPartNumber: 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 * as lambda from 'aws-cdk-lib/aws-lambda';
    import * as s3 from 'aws-cdk-lib/aws-s3';
    import * as s3objectlambda from '@aws-cdk/aws-s3objectlambda-alpha';
    import * as cdk from 'aws-cdk-lib';
    
    const stack = new cdk.Stack();
    const bucket = new s3.Bucket(stack, 'MyBucket');
    const handler = new lambda.Function(stack, 'MyFunction', {
    	runtime: lambda.Runtime.NODEJS_14_X,
    	handler: 'index.handler',
    	code: lambda.Code.fromAsset('lambda.zip'),
    });
    new s3objectlambda.AccessPoint(stack, 'MyObjectLambda', {
    	bucket,
    	handler,
    	accessPointName: 'my-access-point',
    	payload: {
    		prop: "value",
    	},
    });

    Install

    npm i @aws-cdk/aws-s3objectlambda-alpha

    DownloadsWeekly Downloads

    143

    Version

    2.38.0-alpha.0

    License

    Apache-2.0

    Unpacked Size

    183 kB

    Total Files

    12

    Last publish

    Collaborators

    • romainmuller
    • amzn-oss
    • rix0rrr
    • aws-cdk-team