AWS Lambda SmartApp fails with ClosestRegionNotFoundError

I have registered a SmartApp on my dev account with AWS Lambda. I followed all the steps from the docs, but when I try to install the SmartApp from the mobile app, I get the infamous “Something went wrong” error. I checked the live logs of the SmartApp and found this:

"error\":{\"code\":\"ClosestRegionNotFoundError\",\"message\":\"Couldn't find closest region.\",\"target\":\"\",\"details\":[]}

I searched in Google and here, but I can’t find any mention of this error. The lambda region is eu-west-1. The SmartApp settings page correctly shows the region:

Is there any region limitation on lambda invocation? I am asking because there’s zero references to this in the docs, not a single mention of AWS regions.

I found a couple more things:

  • Updating the function ARN for the existing app always fails in the UI
  • After I recreated the lambda in us-east-2, it started to work

Apparently, SmartThings has limitations on lambda regions, which are not documented.

Sorry about that, I’ll create a report for that to be specified in the SmartApp docs. The ST Schema integration also has the option to use Lambda functions, there, the supported regions are specified:

  • ap-northeast-1 (Tokyo)
  • us-east-1 (N. Virginia)
  • eu-west-1 (Ireland)

Also, if your SmartThings location is from another region, you won’t be able to install the Lambda function. For example, if a user lives in India, the SmartApp should be in the ap-northeast-1 region.

You can see the region of your location by making a query to the Locations endpoint. This is an sample using Postman:

Note: Create your Personal Access Token (PAT) here.
You can also use the SmartThings CLI

Ok, I see. So, it should’ve worked with eu-west-1 but it doesn’t because, maybe, my account was previously registered with the region US. It has been changed after lots of back and forth with support, but the hub endpoint is still in the US as it seems. It might explain also why I cannot invite people who are registered in the country I live but invites for accounts in the US are fine. It’s quite strange, this system, I must admit.

Oh, so you already contacted Customer Support and they made some changes, do you have an active ticket with them? If so, can you share its number, please? If not, the last ticket number can help me track that and ask the team what was the latest status

It’s been a while. They changed my account region, but it doesn’t affect the invites issue, and I can now see that my hub still reports to the US.

Mmm ok, well, please confirm the countryCode shown in the location description, based on that, change the SmartApp region (if necessary) and check if it’s installed correctly.
Did you use the sample provided in this repo?