X12 EDI Converter AWS Lambda Function
Overview
You can install our EDI converter as an AWS Lambda function.
With the Lambda, you get the same functionality as our EDI CLI tool, and you also get all the benefits of the AWS Lambda scalability.
The converter’s Lambda function 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 an event containing object keys, e.g., from AWS Event bridge.
You can also use a trigger on an S3 bucket so that the converter automatically converts all new files from the that bucket.
Current release: 2.11.3.
Installation and Configuration
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. You can do it by modifying the function’s role in the IAM console. For example, to grant read/write access to all buckets, add the following fragment to the policy:
{
"Sid": "AllowS3Access",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
Modify “General Configuration” to allocate enough ephemeral storage. The converter first downloads files to the ephemeral storage, so the size of the storage should be large enough to accommodate your largest EDI file. If your EDI files are small, you can keep the default 512MB storage size. Make sure to enable “SnapStart” if this is the case.
Install the function’s code. You can install the code from our public s3 bucket or by running the following AWS CLI command:
aws lambda update-function-code --function-name <Your function name> \
--s3-bucket ediconverter --s3-key ediconvert-lambda-2.11.zip
You need a license key to run the converter. Request your trial license key here and then define the EDI_LICENSE_KEY
environment variable with the value of the key.
Configure the function’s event handler. The default event handler is hdi.aws.ConverterEventHandler::handleRequest
. If you want to run the function from an S3 trigger, use the hdi.aws.ConverterTriggerEventHandler::handleRequest
event handler.
Increase the function’s timeout to 2 minutes. If your EDI files are large, set it to 5 minutes.
Running the Converter’s Lambda Function
The function’s hdi.aws.ConverterEventHandler::handleRequest
event handler accepts the event with the following fields:
inBucket
: Name of the bucket containing the EDI files. If not defined, the converter will use the value from theIN_BUCKET
environment variable.inKey
: Name of the EDI file in the input bucket. You must provide one ofinKey
orinKeys
.inKeys
: List of EDI file names in the input bucket- outBucket: Name of the bucket for converted files. If not defined, the converter will use the value from the
OUT_BUCKET
environment variable. outFormat
: The format to convert EDI files to. Must be JSON or JSONL. JSONL (NDJSON) is the format with line-separated JSON objects, which is easier to parse than large JSON arrays. Defaults to JSON. You can also define theOUT_FORMAT
environment variable and set its value toJSONL
.isSplitMode
: The “split mode” for EDI parsing, see here for more details. Defaults toTrue
. This field must be set to false for all transactions other than 837/835.warningsInOutput
: Include EDI parser warnings in the output files, see documentation on error handling for more details. You can also define theOUTPUT_WARNINGS
environment variable and set its value toTrue
.
Here is an example:
{
"inBucket": "ediin",
"inKeys": ["edi-1.dat", "edi-2.dat"],
"outBucket": "ediout"
}
To invoke the function using the AWS CLI:
aws lambda invoke --function-name <Your Function Name> --cli-binary-format raw-in-base64-out \
--payload '{ "inBucket": "ediin", "inKeys": ["edi-1.dat", "edi-2.dat"], "outBucket": "ediout" }' response.json
The function returns a list of converted input object keys and corresponding output object keys, e.g.:
[
{"inBucket":"ediin","inKey":"edi-1.dat","outBucket":"ediout","outKey":"edi-1.json","outFormat":"JSON"},
{"inBucket":"ediin","inKey":"edi-2.dat","outBucket":"ediout","outKey":"edi-2.json","outFormat":"JSON"}
]
The name of the output file matches the name of the input file with the appropriate extension (.json or .jsonl).
Running the Converter’s Lambda Function from a Trigger
You can create a trigger on an input S3 bucket to invoke the function whenever a new file arrives.
Change the converter’s event handler to hdi.aws.ConverterTriggerEventHandler::handleRequest
(Runtime Settings/Handler). You must also define the OUT_BUCKET
environment variable.