Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[IBM Developer Summit] Twilio Serverless API

[IBM Developer Summit] Twilio Serverless API

Overview of Twilio Serverless API for deploying Functions and Assets

vinci chen

July 26, 2019
Tweet

Other Decks in Technology

Transcript

  1. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. SERVICES • Main

    container for application • Define a descriptive base domain • Can have multiple services in one account ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  2. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. SERVICES curl -X

    POST https://serverless.twilio.com/v1/Services \ --data-urlencode "IncludeCredentials=True" \ --data-urlencode “UniqueName=ibm-summit“ \ --data-urlencode “FriendlyName=ibm-summit” \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  3. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. FUNCTIONS & ASSETS

    • Functions: code snippets (node.js) • Assets: static files • Not the actual content of the function/asset ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  4. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. FUNCTIONS & ASSETS

    curl -X POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions \ --data-urlencode “FriendlyName=Hello World” \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token curl -X POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Assets \ --data-urlencode “FriendlyName=ID Picture” \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  5. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. FUNCTION & ASSET

    VERSIONS • The actual content of the function/asset • Allows for versioning • Can change the path and visibility ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  6. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. FUNCTION VERSIONS curl

    -X POST https://serverless-upload.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions/ ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Versions \ -F “[email protected]; type=application/javascript" \ -F “Path=/hello-world” \ -F "Visibility=public" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  7. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. ASSET VERSIONS curl

    -X POST https://serverless-upload.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Assets/ ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Versions \ -F “[email protected]" \ -F “Path=/id-pic” \ -F “Visibility=private" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  8. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. BUILDS • Bundle

    of function versions, asset versions, and npm dependencies • Build validations done in this step ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  9. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. BUILDS curl -X

    POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token --data-urlencode “FunctionVersions=ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX” --data-urlencode “AssetVersions=ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”
  10. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. ENVIRONMENTS & VARIABLES

    • Can deploy code to different environments instead of deploying directly to production • Can save configurations for environments in variables ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  11. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. ENVIRONMENTS curl -X

    POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments \ --data-urlencode “UniqueName=development" \ --data-urlencode “DomainSuffix=dev" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  12. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. VARIABLES curl -X

    POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments \ ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Variables --data-urlencode “Key=email" \ --data-urlencode “[email protected]“ \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  13. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. DEPLOYMENTS • Activate

    a build in a given environment • Can activate the same build in multiple environments • Can roll back a build ‣Services ‣Functions ‣Versions ‣Assets ‣Versions ‣Builds ‣Environments ‣Variables ‣Deployments
  14. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. DEPLOYMENTS curl -X

    POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Environments \ ZEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Deployments --data-urlencode “BuildSid=ZBXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  15. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. BENEFITS OF THE

    API • Multiple environments, no more credential swapping • Full control on how you deploy • Roll back/forward • Can automate deployments and build integrations with IDE, CI/CD workflows, etc.
  16. © 2017 TWILIO, INC. ALL RIGHTS RESERVED. SERVERLESS API &

    CLI npm install twilio-cli -g twilio plugins:install @twilio-labs/plugin-serverless twilio login twilio serverless:init example http://signal.twilio.com/ SIGNAL: CUSTOMER & DEVELOPER CONFERENCE (AUG. 6-7) Email [email protected] for API access SERVERLESS19 for $20 Twilio credit