aws / aws/aws-cdk

(aws-s3objectlambda): support multiple transformationConfigurations

Open
#28,064 2 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/aws-s3objectlambda effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

**This feature request contains a breaking change to the `aws-s3objectlambda` module.**
**However, since this module is still in alpha, I think we can discuss breaking changes as well!**

CloudFormation allows us to specify multiple `transactionConfigurations`, each of which can specify a different Lambda or target S3 APIs.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3objectlambda-accesspoint-objectlambdaconfiguration.html

Currently, however, `AccessPoint` construct cannot specify multiple transactionsformation configurations.
Only one Lambda function can be specified in `AccessPointProps`, and the constructor of the `AccessPoint` class is hardcoded with an array.
https://github.com/aws/aws-cdk/blob/c66e197f6f8840da6475383dbf2421c3b06ea417/packages/%40aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts#L48
https://github.com/aws/aws-cdk/blob/c66e197f6f8840da6475383dbf2421c3b06ea417/packages/%40aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts#L231
(This implementation is natural because multiple S3 APIs were not supported at the time this L2 Construct was created. https://github.com/aws/aws-cdk/pull/15833)

Therefore, I would like to change the `AccessPointProps` interface to allow multiple transactionsConfigurations to be set.
This change would cause a breaking change because it would change a required property (e.g. `AccessPointProps.handler`).

### Use Case

The ability to specify multiple transactionsConfigurations in an `AccessPoint` construct allows users more flexibility in object transformation.
This can be configured in Cloudformation as follows.

```yaml
Resources:
MyS3ObjectLambdaAccessPoint:
Type: AWS::S3ObjectLambda::AccessPoint
Properties:
Name: sample
ObjectLambdaConfiguration:
SupportingAccessPoint: hoge
TransformationConfigurations:
- Actions: [ GetObject]
ContentTransformation:
AwsLambda:
FunctionArn: hoge
- Actions: [ ListObjects ]
ContentTransformation:
AwsLambda:
FunctionArn: hoge
```

From the user's point of view, it would be nice to be able to use `AccessPoint` constructs in this way
```ts
const accessPoint = new AccessPoint(stack, 'MyObjectLambda', {
bucket,
accessPointName: 'obj-lambda',
supportsGetObjectRange: true,
supportsGetObjectPartNumber: true,
transformationConfigurations: [{
actions: [S3ObjectLambdaAction.GET_OBJECT],
handler,
payload: { foo: 10 },
}],
});
```
instead of the current way of using them in this way.
```ts
const accessPoint = new AccessPoint(stack, 'MyObjectLambda', {
bucket,
handler,
accessPointName: 'obj-lambda',
supportsGetObjectRange: true,
supportsGetObjectPartNumber: true,
payload: { foo: 10 },
});
```

### Proposed Solution

Remove the `AccessPointProps.handler` property and accept an array of `TransformationConfiguration`.
```diff
export interface AccessPointProps {
// ....

- readonly handler: lambda.IFunction;

+ /**
+ * The configurations for the S3 Object Lambda Access Point transformation.
+ */
+ readonly transformationConfigurations: TransformationConfiguration[];
}

+export interface TransformationConfiguration {
+ /**
+ * Whether the Lambda function can process `HeadObject-PartNumber` requests.
+ *
+ * @default - [S3ObjectLambdaAction.GET_OBJECT]
+ */
+ readonly actions?: S3ObjectLambdaAction[];

+ /**
+ * The Lambda function used to transform objects.
+ */
+ readonly handler: lambda.IFunction;

+ /**
+ * Additional JSON that provides supplemental data passed to the
+ * Lambda function on every request.
+ *
+ * @default - No data.
+ */
+ readonly payload?: { [key: string]: any };
+}

+ /**
+ * The actions for the Object Lambda Access Point configuration.
+ */
+ export enum S3ObjectLambdaAction {
+ /**
+ * Action to invoke a Lambda function for the GetObject operation
+ */
+ GET_OBJECT = 'GetObject',
+ /**
+ * Action to invoke a Lambda function for the HeadObject operation
+ */
+ HEAD_OBJECT = 'HeadObject',
+ /**
+ * Action to invoke a Lambda function for the ListObject operation
+ */
+ LIST_OBJECT = 'ListObject',
+ /**
+ * Action to invoke a Lambda function for the ListObjectV2 operation
+ */
+ LIST_OBJECT_V2 = 'ListObjectV2',
+ }
```

### Other Information

_No response_

### Acknowledgements

- [X] I may be able to implement this feature request
- [X] This feature might incur a breaking change

### CDK version used

v2.110.0

### Environment details (OS name and version, etc.)

MacOS

Contributor guide

Open the contributing guide

Research direction

Start with packages/@aws-cdk/aws-s3objectlambda-alpha/lib/access-point.ts, especially the AccessPointProps definition and the constructor areas linked in the issue. Compare the current single-handler configuration with the proposed TransformationConfiguration array and enum. Done means AccessPoint can represent multiple transformation configurations, including their actions, handlers, and optional payloads, while preserving the intended CloudFormation shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, typescript
Domain
cloud, infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.