Lambda function that can be connected with AWS API Gateway to replace Twilio from Auth0 passwordless sms connection.
- Go to Lambda functions and press on the create function button
- Inside create function select Use a blueprint. In the search bar, search for microservice-http-endpoint. Select it and then click Configure.
- Inside basic information, enter a function name and under Execution role click Create a new role from AWS policy templates. Enter the Role name. The important part is to remove the Simple microservice permissions Dynamo DB and add the Amazon SNS publish policy SNS.
- Inside the API Gateway trigger select Create an API. Select HTTP API and set the security to Open
- Click on the Create function button to complete the creation process
- A similar page as below will be visible
- Upload the
code.zip
file in the upload from section and change the secret and any other necessary values inside the code and deploy it
- Go API Gateway in AWS and you can find the API that was created
- You can find the invoke URL of the API, copy it to the clipboard
- In IAM roles, find the role that is linked to the lambda function you just created and find the SNS Publish Policy in the Permission policies. Edit it to make it look like in the image (
"Resource": "*"
)
- Refer to this documentation by Auth0 and update your sms connection
{
"options":{
"strategy":"sms",
"provider":"sms_gateway",
"gateway_url":"paste your gateway url here",
"from":"+1 234 567",
"template":"Your verification code is: @@password@@",
"brute_force_protection":true,
"forward_req_info":"true",
"disable_signup":false,
"name":"sms",
"syntax":"md_with_macros",
"totp":{
"time_step":300,
"length":6
},
"gateway_authentication":{
"secret":"add your secret (256bit) here and use the same in the index.js in lambda function",
"method":"bearer",
"subject":"urn:Auth0",
"audience":"urn:MySmsGateway",
"secret":"testingtoken",
"secret_base64_encoded":false
}
},
"is_domain_connection":false,
"enabled_clients":[]
}