AWS lambda functions to clock-in/clock-out from teamspirit deployed via Serverless framework
Go to root directory of project
# download Selenium 2.37
$ pip3.6 install -t layers/seleniumLayer/selenium/python/lib/python3.6/site-packages selenium==2.37
# download chrome driver
$ cd layers/seleniumLayer
$ mkdir chromedriver
$ cd chromedriver
$ curl -SL https://chromedriver.storage.googleapis.com/2.37/chromedriver_linux64.zip > chromedriver.zip
$ unzip chromedriver.zip
$ rm chromedriver.zip
# download chrome binary
$ curl -SL https://github.com/adieuadieu/serverless-chrome/releases/download/v1.0.0-41/stable-headless-chromium-amazonlinux-2017-03.zip > headless-chromium.zip
$ unzip headless-chromium.zip
$ rm headless-chromium.zip
Do this if you don't have serverless in your machine yet
npm config set prefix /usr/local
and then,
npm i -g serverless
Go to root directory of project
$ cd layers
$ sls deploy
Go to root directory of project
$ cd lambda
$ cp config.dev.json.example config.dev.json
Edit config.dev.json
file and set your teamspirit credentails.
Note: These credentials would be stored as enviroment variables for lambda functions. Alternatively, you could use Paramter store or Secrets Manager to store them. More details here
Go to root directory of project
$ cd lambda
$ sls deploy
Check serverless logs or log into AWS console navigate to API gateway to find generated API endpoints(/clockIn and /clockOut) Or, you could invoke lambdas directly
$ cd lambda
$ sls invoke --function teamspirit-lambda-dev-clock_in
$ sls invoke --function teamspirit-lambda-dev-clock_out
The generated API endpoints could be triggered via google assistant as well by creating a custom google action, connecting it with a dialogue flow agent and adding the API endpoints(clockIn/clockOut) as webhooks in the fulfillment section. Example.