AWS Lambda Action

Dear PureCloud Developers

Wishing you are well.

I was wondering if I could ask for help with a test AWS Lambda Action?

I have created a "Hello world" GET request on Lambda available from the following resource
https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?key1=helloworld

And I would like to create a data action that calls it from PureCloud.

The URL to call is https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?key1=helloworld and I have used the attached Data Action (which is copied in text below) Samuel-AWS-Helloworld-20181005212536.custom.json (1.4 KB)

I can call it in postman, when I call it from the Data actions I receive the following error:

This is my first try at AWS Lambda calls, any assistance and guidance will be extremely appreciated. Thank you.

8. Execute: [Lambda error] Caused by: 1 validation error detected: Value 'https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?key1=helloworld' at 'functionName' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-.]+)(:($LATEST|[a-zA-Z0-9-]+))? (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: 56640aea-c891-11e8-898c-7f629d28ef3b) [6318f5cb-827b-42ee-9a48-8634e9e48140]

{
"status": 400,
"code": "the request could not be understood by the server due to malformed syntax.",
"entityName": "https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?key1=helloworld",
"message": "[Lambda error] Caused by: 1 validation error detected: Value 'https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?key1=helloworld' at 'functionName' failed to satisfy constraint: Member must satisfy regular expression pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-\.]+)(:(\$LATEST|[a-zA-Z0-9-]+))? (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: 56640aea-c891-11e8-898c-7f629d28ef3b) [6318f5cb-827b-42ee-9a48-8634e9e48140]",
"messageParams": {},
"contextId": "6318f5cb-827b-42ee-9a48-8634e9e48140",
"details": [],
"errors": []
}

{
"name": "Samuel AWS Helloworld - Exported 2018-10-05 @ 21:25",
"integrationType": "aws-lambda-data-actions",
"actionType": "custom",
"config": {
"request": {
"requestUrlTemplate": "https://9g0ewror34.execute-api.ap-southeast-2.amazonaws.com/prod/helloworld?{input.key}", "requestType": "GET", "headers": { "Content-Type": "application/x-www-form-urlencoded", "x-api-key": "zzzzzzzzzzzz" }, "requestTemplate": "{input.rawRequest}"
},
"response": {
"translationMap": {
"total": ".test" }, "translationMapDefaults": {}, "successTemplate": "{\n \"test\": {test}\n }"
}
},
"contract": {
"input": {
"inputSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Get total from datatable",
"description": "AWS HelloWorld",
"type": "object",
"required": [
"key"
],
"properties": {
"key": {
"description": "key",
"type": "string"
}
}
}
},
"output": {
"successSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "title",
"description": "description",
"type": "object",
"properties": {
"total": {
"type": "integer"
}
}
}
}
},
"secure": false
}

Hello Samuel!

The Lambda Data Actions integration invokes your lambda directly just using the ARN of the lambda. You received that error because you provided a URL to your lambda, when the configuration requires just the ARN. Your ARN should look something like arn:aws:lambda:us-east-1:000000000000:function:test-lambda.

With the Lambda Data Action integration, you also don't need to specify any x-api-key headers in the action. All the auth is taken care of for you based on the role configured in the integration credentials
(here is the doc page for setting up the role)

We have an example lambda function documented here, and I've attacehd a data action export that invokes that lambda. If you change your lambda code to be the example code and update the ARN in the data action, you should have a working example.

.example-lambda-action-2018100582633.custom.json (1.2 KB)

Let us know if that gets you up and going.

-Chris

2 Likes

Hi Samuel,

I also noticed the endpoint returns a string: "key1 value is helloworld"

The response must be a valid json object, so a sample response would be:

{
"key1": "key1 value is helloworld"
}

1 Like

Dear ChrisDibble and Smith_Rj

Hope you are keeping well.

Just a short note to thank you very much for your help and input on the AWS Lambda Action. This certainly helped to get me going. Thank you!

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.