Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gautric/dmn-lambda

DMN KYC implementation into AWS Lambda
https://github.com/gautric/dmn-lambda

aws aws-lambda dmn java-11 kogito kyc

Last synced: 10 days ago
JSON representation

DMN KYC implementation into AWS Lambda

Awesome Lists containing this project

README

        

# DMN Lambda

image::https://github.com/gautric/dmn-lambda/actions/workflows/build-and-deploy-dmn-lambda-pipeline.yml/badge.svg[Build and Deploy DMN Lambda]
image::https://img.shields.io/badge/DMN-1.3-blue?style=flat-square[DMN]
image::https://img.shields.io/badge/Quarkus-2.13-blue?style=flat-square&logo=quarkus&logoColor=white[Quarkus 2.13]
image::https://img.shields.io/badge/AWS-Lambda-%23FF9900?style=flat-square&logo=amazon-aws&logoColor=white[Lambda]

## DMN

link:https://www.omg.org/dmn/[DMN™](Decision Model and Notation™) is an link:https://www.omg.org/[OMG] standard to develop complex rules engine.
This standard provides some graphical components designer can use easily for building complex rule system.
Designer is mainly a business analyst, because DMN is a low-code standard.

## Requirements

* AWS Account with Lamdba Function Grant

## Compile

This sample uses Maven configuration file. Execute the command below to compile/build.

mvn clean package

## Deploy

Here is the command to deploy the DMN Lambda function to AWS.

sam deploy --confirm-changeset -t src/main/aws/sam.tmpl.yaml

This command will create all stuffs into AWS infrastructure for executing the Lambda.

### Lambda URL

To retrieve URL Lambda.

export AWS_STACK_NAME=dmn-lambda-sam

aws apigatewayv2 get-apis --output json --query "Items[?Tags.\"aws:cloudformation:stack-name\"=='${AWS_STACK_NAME}'].ApiEndpoint | [0] " | jq -r

You should get this kind of output.

```
https://AAABBBDDDCCCC.execute-api.AWS_REGION.amazonaws.com
```

Execute this command once for exporting DMN_LAMBDA_URL to bash env

export DMN_LAMBDA_URL=`aws apigatewayv2 get-apis --output json --query "Items[?Tags.\"aws:cloudformation:stack-name\"=='${AWS_STACK_NAME}'].ApiEndpoint | [0] " | jq -r`

### CURL Execution

Execute a curl command

curl ${DMN_LAMBDA_URL}/KYC -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw '{"PEP":true,"Amount":100000,"Fiscal Residency":"FR"}' | jq

```
{
"Amount Rule": "HIGH",
"Level to Int": "function Level to Int( Level )",
"Max Level": "function Max Level( list of Level )",
"KYC": {
"Score": "HIGH",
"Level": 150
},
"Fiscal Residency Rule": "LOW",
"Amount": 100000,
"Int to Level": "function Int to Level( Int )",
"PEP Rule": "HIGH",
"PEP": true,
"Fiscal Residency": "FR",
"Level to Score": "function Level to Score( Level )"
}

```

### Newman (Postman) Execution

A Postman collection is available inside `src/main/postman` folder. Newman provides a command line tool to execute a postman collection. Don't forget to pass some AWS Credential too.

newman run src/main/postman/KYC-DMN.postman_collection.json --env-var DMN_LAMBDA_URL=${DMN_LAMBDA_URL} --env-var AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} --env-var AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} --env-var AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION} --verbose

Here is the Newman output.

```
newman

KYC-DMN

→ Call DMN
POST https://AAABBBDDDCCCC.execute-api.AWS_REGION.amazonaws.com/KYC
200 OK ★ 229ms time ★ 721B↑ 534B↓ size ★ 12↑ 5↓ headers ★ 0 cookies
┌ ↑ raw ★ 52B
│ {"PEP":true,"Amount":100000,"Fiscal Residency":"FR"}

┌ ↓ application/json ★ text ★ json ★ utf8 ★ 352B
│ {"Amount Rule":"HIGH","Level to Int":"function Level to Int( Level )","Max Level":"function Max Level( list of Level )","KYC":{"Score":"HIGH","Level":150},"Fiscal Residency Rule":"LOW","Amount":1000
│ 00,"Int to Level":"function Int to Level( Int )","PEP Rule":"HIGH","PEP":true,"Fiscal Residency":"FR","Level to Score":"function Level to Score( Level )"}

prepare wait dns-lookup tcp-handshake ssl-handshake transfer-start download process total
78ms 9ms 37ms 24ms 58ms 89ms 8ms 481µs 307ms

✓ response must be valid and have a body

┌─────────────────────────┬────────────────────┬───────────────────┐
│ │ executed │ failed │
├─────────────────────────┼────────────────────┼───────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ requests │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ test-scripts │ 2 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ prerequest-scripts │ 1 │ 0 │
├─────────────────────────┼────────────────────┼───────────────────┤
│ assertions │ 1 │ 0 │
├─────────────────────────┴────────────────────┴───────────────────┤
│ total run duration: 394ms │
├──────────────────────────────────────────────────────────────────┤
│ total data received: 352B (approx) │
├──────────────────────────────────────────────────────────────────┤
│ average response time: 229ms [min: 229ms, max: 229ms, s.d.: 0µs] │
├──────────────────────────────────────────────────────────────────┤
│ average DNS lookup time: 37ms [min: 37ms, max: 37ms, s.d.: 0µs] │
├──────────────────────────────────────────────────────────────────┤
│ average first byte time: 89ms [min: 89ms, max: 89ms, s.d.: 0µs] │
└──────────────────────────────────────────────────────────────────┘
```