Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(aws-s3objectlambda): support multiple transformationConfigurations #28064

Open
2 tasks done
sakurai-ryo opened this issue Nov 19, 2023 · 2 comments
Open
2 tasks done
Labels
@aws-cdk/aws-s3objectlambda effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2

Comments

@sakurai-ryo
Copy link
Contributor

sakurai-ryo commented Nov 19, 2023

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.



(This implementation is natural because multiple S3 APIs were not supported at the time this L2 Construct was created. #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.

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

  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.

  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.

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

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

v2.110.0

Environment details (OS name and version, etc.)

MacOS

@sakurai-ryo sakurai-ryo added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 19, 2023
@pahud
Copy link
Contributor

pahud commented Nov 21, 2023

Thank you for your detailed feature request and we appreciate your PR.

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Nov 21, 2023
@sakurai-ryo
Copy link
Contributor Author

Implementation in progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3objectlambda effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants