X12 EDI Converter AWS Lambda Function

Overview

You can install the converter as a Lambda function in the AWS environment.

With the Lambda, you get the same functionality as the CLI tool, and you also get the benefits of the AWS Lambda scalability.

The converter Lambda reads X12 EDI files from an S3 bucket and outputs the converted files into another S3 bucket.

You can run the converter Lambda by invoking it with the event containing bucket names.

You can also use a trigger on an S3 bucket so that the converter automatically converts all new files from the that bucket.

Installation

Create a Lambda function with the Java 17 or Java 21 runtime.

Grant permissions to the function to read objects from the input bucket and to write objects to the output bucket.

Modify “General Configuration” to allocate 10GB of ephemeral storage. The converter first downloads files to the ephemeral storage, so the size of the storage should be large enough to accommodate your EDI files.

Define environment variables:

  • EDI_LICENSE with the value of your license.
  • OUT_BUCKET: name of the output bucket. You can also provide the bucket name as part of the event.
  • CONVERSION_MODE: JSON, JSONL, or CSV. JSON is the default.

Download the zip file of the function from this link.

Deploy the zip file using AWS GUI or the following command:

aws lambda update-function-code --function-name <Your Function Name> --zip-file fileb://<path to file>/ediconvert-lambda-2.11.zip

Configure event handlers as described below.

Running the Converter Lambda from a Trigger

With a trigger, the converter automatically converts new files from the input bucket.

Create a trigger on the input bucket for the s3:ObjectCreated:* event types.

Set the event handler to hdi.aws.ConverterTriggerEventHandler::handleRequest for the Lambda function. (Runtime Settings/Handler).

You must define the OUT_BUCKET environment variable to point to the output bucket.

Running the Converter Lambda Manually

You can invoke the converter Lambda manually or from a scheduler. Set the event handler to hdi.aws.ConverterEventHandler::handleRequest.

Here are the fields of the event:

  • inputBucketName. Name of the bucket containing the EDI files. Required.
  • objectKey: Name of the file in the input bucket. Required.
  • outputBucketName. Name of the output bucket. If not defined, the converter will use the value from the OUT_BUCKET environment variable.

To invoke the converter:

aws lambda invoke --function-name <Your Function Name> --cli-binary-format raw-in-base64-out --payload '{ "inputBucketName": "<your bucket>",  "objectKey": "<file name>"}' response.json