AWS Lex bots import

If you are trying to import a Lex bot from a different account, you will encounter this error.

Lex can’t access the Lambda function arn:xxxx:function:bot-api in the context of intent arn:xxxxx:OpenOrderAmount:$LATEST. Check the resource based policy on the function and try your request again.

I tried replacing the correct ARN id of the function in the target environment but that won’t work. Lex tries to give execution permission when attaching a function to the fulfillment but it doesn’t do it while importing. I hope someday the AWS Lex wakes up and makes this process simple. Until then, here is a solution

The solution is simple:

1. open the json file and remove all codeHook elements. These are inside the fuulfillmentActivity element

2. Zip the file and import

It will successfully import. Now you have to manually link the function for each of the intents.

--

--