You can develop a SmartThings SmartApp as an AWS Lambda function. This requires that you grant SmartThings permission to execute your Lambda function. You must also register your Lambda function with SmartThings as a SmartApp to be integrated into SmartThings. The steps below will guide you through the hosting process.
Ensure that you deployed your Lambda function on AWS properly. Serverless CLI makes this task much smoother. Assuming you have AWS credentials configured correctly and a minimal
serverless.yml, it can be as easy as typing serverless deploy. For examples on implementing serverless computing, see our Lambda examples.
To confirm that your Lambda function is deployed properly:
- Login to your AWS console
- Navigate to Services > Lambda. You should see your function listed here.
Next, you will need to grant SmartThings permission to execute this Lambda function. There are two ways you can grant permissions; only one method is required.
See smartthings apps:authorize for info on how to authorize using the SmartThings CLI.
To authorize using the AWS CLI, execute the following command in a terminal shell.
<my-profile-name>is your named profile as stored in your AWS config file. See here for more information.
<my-function-name>is the name of your Lambda function in AWS. This is the same as the value of the environment variable
LAMBDA_FUNCTION_NAME. You can locate this environment variable on your Lambda function page of your AWS console.
<PRINCIPAL ID FROM SMARTTHINGS>is the account id to which you are granting the permission to execute your Lambda function. Use
906037444270for SmartApp and
148790070172for SmartThings Schema.
To confirm that the permission is properly granted to the SmartThings account:
- Navigate to the Lambda function page on your AWS console,
- Click the Triggers tab and click the View function policy down arrow. This will display JSON description showing that SmartThings can now invoke your function.
Before you register your SmartApp, make a note of the ARN for your Lambda function. You can find the ARN of your Lambda function from the Lambda function page on your AWS console. Read more about ARNs on Amazon's documentation.
After making a note of your ARN, head to SmartApp Registration to complete the registration process.