This project contains source code and supporting files for a serverless HL7 parser that can be deployed with the SAM CLI. It includes the following files and folders.
- hl7_receiver - Code for the application's Lambda function.
 - events - Invocation events that you can use to invoke the function.
 - tests - Unit tests for the application code.
 - template.yaml - A template that defines the application's AWS resources.
 
The application uses several AWS resources, including Lambda functions and an API Gateway API. These resources are defined in the template.yaml file in this project.
The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.
To use the SAM CLI, you need the following tools.
- SAM CLI - Install the SAM CLI
 - Python 3 installed
 - Docker - Install Docker community edition
 
To build the application for the first time, run the following in your shell:
sam build --use-containerThe SAM CLI installs dependencies defined in hl7_receiver/requirements.txt, creates a deployment package, and saves it in the .aws-sam/build folder.
Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the events folder in this project.
Run functions locally and invoke them with the sam local invoke command.
aws-lambda-hl7-parser$ sam local invoke Hl7ReceiverFunction --event events/event.jsonThe SAM CLI can also emulate your application's API. Use the sam local start-api to run the API locally on port 3000.
aws-lambda-hl7-parser$ sam local start-api
aws-lambda-hl7-parser$ curl http://localhost:3000/The SAM CLI reads the application template to determine the API's routes and the functions that they invoke. The Events property on each function's definition includes the route and method for each path.
      Events:
        Hl7Receiver:
          Type: Api
          Properties:
            Path: /hl7-inbound
            Method: postTests are defined in the tests folder in this project. Use PIP to install the test dependencies and run tests.
aws-lambda-hl7-parser$ pip install -r tests/requirements.txt --user
# unit test
aws-lambda-hl7-parser$ python -m pytest tests/unit -vSee the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.
The application template uses AWS Serverless Application Model (AWS SAM) to define application resources. AWS SAM is an extension of AWS CloudFormation with a simpler syntax for configuring common serverless application resources such as functions, triggers, and APIs. For resources not included in the SAM specification, you can use standard AWS CloudFormation resource types.