Accessing Services Deployed as AWS Lambda

◷ Reading Time: 6 minutes

We learned how to deploy a service as AWS Lambda. Now let’s see how to access the services.

Get Service Details Using Services URL

To demonstrate how to retrieve service information, we will be using Postman. But you can use any API testing tool for this.

Retrieve All the Available Services

You can use the Services URL to get the list of available services along with their details. For example, if your package has three services, you can retrieve the service details of all three services.

AWS URLs are case sensitive.

Request

Response

[
    {
        "packageId": "fda5255b65484b9ca2fb9eef0b39e779",
        "packageName": "age-service",
        "serviceName": "person_growing_state",
        "serviceId": "7763bdfbdf7f4e8c9a8b50288aa45d18",
        "packageVersion": "1",
        "serviceVersion": "1",
        "packageUri": "/fda5255b65484b9ca2fb9eef0b39e779/7763bdfbdf7f4e8c9a8b50288aa45d18/decision.function.frdp",
        "parameters": {
            "href": "/Services/age-service/1/person_growing_state/1"
        },
        "execute": {
            "href": "/Execute/age-service/1/person_growing_state/1"
        }
    },
    {
        "packageId": "fda5255b65484b9ca2fb9eef0b39e779",
        "packageName": "age-service",
        "serviceName": "person_growing_state",
        "serviceId": "70b88c070aa84511a148460a8b663511",
        "packageVersion": "1",
        "serviceVersion": null,
        "packageUri": "/fda5255b65484b9ca2fb9eef0b39e779/70b88c070aa84511a148460a8b663511/decision.function.frdp",
        "parameters": {
            "href": "/Services/age-service/1/person_growing_state"
        },
        "execute": {
            "href": "/Execute/age-service/1/person_growing_state"
        }
    }
]

Retrieve Information on Input

You can retrieve further information on the input data structure, entry URI, and concept.

Request

Service’s parameters.href value retrieved from the Services Uri

Response

In this response, we can see that the

[
    {
        "name": "person",
        "direction": "InOut",
        "assembly": "PersonConcept.xml",
        "type": "Person",
        "concept": {
            "filename": "PersonConcept.xml",
            "types": [
                {
                    "name": "Person",
                    "type": "Fact",
                    "members": [
                        {
                            "name": "Age",
                            "type": "int"
                        },
                        {
                            "name": "Title",
                            "fact": "Title"
                        }
                    ]
                },
                {
                    "name": "Title",
                    "type": "Option",
                    "members": [
                        {
                            "name": "Infant"
                        },
                        {
                            "name": "Kid"
                        },
                        {
                            "name": "Teen"
                        },
                        {
                            "name": "Young"
                        },
                        {
                            "name": "Adult"
                        },
                        {
                            "name": "Immortal"
                        }
                    ]
                }
            ],
            "namespace": "Samples"
        }
    }
]

Execute the Service

Using the Execute Url, we can execute the service and retrieve output from our AWS Lambda deployed in AWS.

Request

For the request body, the original input should be re-formatted as below, surrounded by an inputs tag. If you use the original input instead, it will give an error with the message, “Incorrect number of parameters specified.”


  "inputs": [
            {
              "name": "person",
              "value": {
                "Age":50,
                "Title": null
              }
            }
        ]
}


The original input
{
     "person":
     {
         "Age":50,
         "Title":null
     }
 }

Response

It will run the app deployed in AWS, and provide the results accordingly. In this example, since we entered 50 as age, it returned ‘Adult 2’ as the title. In the decision table, you can see that we have defined the age group 39-99 as ‘Adult’.

{
    "isCanceled": false,
    "invocationId": "arn:aws:lambda:us-west-2:627175391071:function:age-service-132633758128829094",
    "elapsed": "00:00:00.0014247",
    "outputs": [
        {
            "name": "person",
            "value": "{\"Age\":50,\"Title\":\"Adult 2\"}"
        }
    ]
}

Checking your API in AWS Console

On your AWS Console API page, you will see all APIs created by FlexRule through AWS Lambda deploy.

The Lambda Name and API ID are needed for updating an existing Lambda. Also in the Execute and Service URL the API ID is part of the URL.

The code as seen in the Execute and Service URLs are to be found in Lambda page of the AWS Console.

Updated on April 21, 2021

Was this article helpful?

Related Articles