# Couldn't add device (AWS lambda)

**URL:** <https://community.smartthings.com/t/couldnt-add-device-aws-lambda/222299>\
**Category:** Support\
**Created:** [March 9, 2021, 6:43am UTC](https://community.smartthings.com/t/couldnt-add-device-aws-lambda/222299 "2021-03-09T06:43:30Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![nayelyz](https://avatars.discourse-cdn.com/v4/letter/n/59ef9b/32.png) [@nayelyz](https://community.smartthings.com/u/nayelyz)\
**Post date:** [March 19, 2021, 10:50pm UTC](https://community.smartthings.com/t/couldnt-add-device-aws-lambda/222299/11 "2021-03-19T22:50:41Z")

</div>

Hi, sorry for the delay.

> [@Rohit007](#):
>
> Yes the OAuth server is working

So, this means using a WebHook project, the installation was successful?

> [@Rohit007](#):
>
> And ran into this error

Ok, to avoid this issue, make sure you:

1. Have your Lambda function in the correct region (`us-east-1`, `ap-northeast-1` or `eu-west-1`)
2. You configured correctly your AWS CLI (the correct key and region selected)
3. You provided the permissions to your Lambda function (using the correct AWS CLI profile and `principal` value)

```auto
aws lambda add-permission --function-name functionName --profile profileName --principal 148790070172 --statement-id smartthings --action lambda:InvokeFunction

```

1. The configuration and code of your Lambda function are correct  
a. The project must have the `node_modules` \> `st-schema` directory.  
b. In the runtime configuration, you need to see that the handler info matches your file. Eg. if your file is named `index.js`, `index.handler` it’s correct.

 ![image](https://global.discourse-cdn.com/smartthings/original/3X/f/3/f320d51dfa3ebbdc53c7c610e5560543341310eb.png)

---

_[View the full topic](https://community.smartthings.com/t/couldnt-add-device-aws-lambda/222299)._
