a phone ownership validation microservice
A phone ownership validation microservice
muphone is an AWS lambda microservice that allows you to validate ownership of a
user provided phone number. This is frequently needed in “sign up” scenarios on
many websites. Here are the typical steps of a validation workflow:
The service is RESTful and can easily integrate with any http clients
available.
Firt, create a local runtime environment and install all the dependencies
in muphone/build to prepare for deployment on AWS lambda:
git clone https://github.com/magnus1984/muphone.git
cd muphone
virtualenv -p python3.6 .runtimeenv
source .runtimeenv/bin/activate
pip install -r requirements.txt -t muphone/build
cp muphone/*.py muphone/build
The API should now be ready for deployment.
The microservice uses AWS CloudFormation for automated deployment. Once you have
completed the setup steps, you can deploy using the aws cli
aws s3api create-bucket --bucket <YOUR-S3-BUCKET> --region ca-central-1 --create-bucket-configuration LocationConstraint=ca-central-1
aws cloudformation package --template-file template.yaml --s3-bucket <YOUR-S3-BUCKET> --output-template-file packaged.yaml
aws cloudformation deploy --template-file packaged.yaml --stack-name <YOUR-STACK-NAME> --capabilities CAPABILITY_IAM
Once deployed, you can get the url of your endpoint by querying the stack
aws cloudformation describe-stacks --stack-name <YOUR-STACK-NAME> --query 'Stacks[0].Outputs[0].OutputValue'
Example use httpie for the client library
http POST https://your.url.endpoint/phone number=<YOUR-PHONE-NUMBER>
http GET https://your.url.endpoint/phone number==<YOUR-E164-FORMATTED-NUMBER>
NOTE: the API automatically persist in a dynamodb table the phone number submitted
in the E164 format. To query the status of a previously submitted number, it is
your responsability to convert to the E164 format.
http POST https://your.url.endpoint/phone/validation number=<YOUR-PHONE-NUMBER> validation_code=<YOUR-VALIDATION-CODE>
There is a live demo available here: https://cmx94tf3ee.execute-api.ca-central-1.amazonaws.com/Prod/
Jonathan Pelletier (jomagnus1984@gmail.com, jonathan.pelletier1@gmail.com)