Amazon.CDK.AWS.S3ObjectLambda.Alpha
The CDK Construct Library for AWS::S3ObjectLambda (Stability: Experimental)
Install
| Product | Versions |
|---|---|
| .NET |
README
AWS::S3ObjectLambda Construct Library
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.
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.S3;
using Amazon.CDK.AWS.S3ObjectLambda.Alpha;
using Amazon.CDK;
var stack = new Stack();
var bucket = new Bucket(stack, "MyBucket");
var handler = new Function(stack, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromAsset("lambda.zip")
});
new AccessPoint(stack, "MyObjectLambda", new AccessPointProps {
Bucket = bucket,
Handler = handler,
AccessPointName = "my-access-point",
Payload = new Dictionary<string, object> {
{ "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:
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.S3;
using Amazon.CDK.AWS.S3ObjectLambda.Alpha;
using Amazon.CDK;
var stack = new Stack();
var bucket = new Bucket(stack, "MyBucket");
var handler = new Function(stack, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromAsset("lambda.zip")
});
new AccessPoint(stack, "MyObjectLambda", new AccessPointProps {
Bucket = bucket,
Handler = 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:
using Amazon.CDK.AWS.Lambda;
using Amazon.CDK.AWS.S3;
using Amazon.CDK.AWS.S3ObjectLambda.Alpha;
using Amazon.CDK;
var stack = new Stack();
var bucket = new Bucket(stack, "MyBucket");
var handler = new Function(stack, "MyFunction", new FunctionProps {
Runtime = Runtime.NODEJS_LATEST,
Handler = "index.handler",
Code = Code.FromAsset("lambda.zip")
});
new AccessPoint(stack, "MyObjectLambda", new AccessPointProps {
Bucket = bucket,
Handler = handler,
AccessPointName = "my-access-point",
Payload = new Dictionary<string, object> {
{ "prop", "value" }
}
});
Accessing the S3 AccessPoint ARN
If you need access to the s3 accesspoint, you can get its ARN like so:
using Amazon.CDK.AWS.S3ObjectLambda.Alpha;
AccessPoint accessPoint;
var s3AccessPointArn = accessPoint.S3AccessPointArn;
This is only supported for AccessPoints created in the stack - currently you're unable to get the S3 AccessPoint ARN for imported AccessPoints. To do that you'd have to know the S3 bucket name beforehand.
Changes from Previous Version
Adoption Assessment
A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.