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

SIGNAL '19 - Leveraging the Serverless API to manage your deployment process

SIGNAL '19 - Leveraging the Serverless API to manage your deployment process

Twilio's Serverless products allow customers to deploy business-critical telecommunications with baked-in reliability, low latency, and minimal maintenance. However, using these products requires a lot of manual work in the Twilio Console. The new Serverless API and CLI allow for more control over the deployment process for more sophisticated workflows, which can be done right in your terminal!

Dominik Kundel

August 07, 2019
Tweet

More Decks by Dominik Kundel

Other Decks in Technology

Transcript

  1. SERVICES • Main container for your application • Forms the

    basis of your domain • Can have multiple services per account
  2. SERVICES curl -X POST https://serverless.twilio.com/v1/Services \ -d "IncludeCredentials=True" \ -d

    "UniqueName=signal-corgis" \ -d "FriendlyName=Corgis App" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  3. ENVIRONMENTS & VARIABLES • Maintain testing environments instead of deploying

    directly to prod • Environment variables to keep track of configurations easily
  4. FUNCTIONS AND ASSETS • Functions: snippets of code • Assets:

    static files • Wrappers for the actual content
  5. FUNCTIONS AND ASSETS curl -X POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions \ -d

    "FriendlyName=Get Corgi Name" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token curl -X POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Assets \ -d "FriendlyName=Cheddar Picture" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  6. FUNCTION AND ASSET VERSIONS • Upload the content of the

    Function or Asset • Allows for references to previous Versions
  7. Services Function Versions Assets Functions Variables Environments Asset Versions Create

    a Version with a path and visibility /get-name /cheddar [private] [public]
  8. FUNCTION VERSIONS curl -X POST https://serverless-upload.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Functions/ ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Versions \ -F

    "Content=@create_name.js; type=application/javascript" \ -F "Path=/get-name" \ -F "Visibility=public" \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token
  9. BUILDS • Bundle Function and Asset Versions • Include npm

    packages as dependencies • Ex: ‘dog-names’ (dog name generator)
  10. Services Function Versions Assets Functions Builds Variables Environments Asset Versions

    Build a package with specific Function & Asset Versions /get-name /cheddar dog-names: ^2.0.0
  11. BUILDS curl -X POST https://serverless.twilio.com/v1/Services/ ZSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Builds \ -u ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX:your_auth_token -d

    "FunctionVersions=ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -d "AssetVersions=ZHXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -d 'Dependencies=[{"name": "dog-names", "version": "^2.0.0"}]'
  12. DEPLOYMENTS • Connects a Build to an Environment • A

    Build can be connected to multiple Environments
  13. Services Function Versions Assets Functions Builds Variables Environments Asset Versions

    Deployments Activate a Build in an Environment /get-name /cheddar dog-names: ^2.0.0 active in: dev
  14. BENEFITS OF THE API • Multiple environments without credential swapping

    • More control over how you deploy & deployment automation • Ability to incorporate complicated deployment workflows (i.e. rollbacks) • Build tools and integrations for your IDE, CI/CD workflows, etc.
  15. SERVERLESS TOOLKIT • CLI to deal with anything Serverless •

    Node.js helper library to built your own integrations • Collection of Function & Asset templates to get you started quicker • github.com/twilio-labs/serverless-toolkit
  16. • Serverless API documentation: twilio.com/docs/runtime/functions-assets-api • Check out the Serverless

    Toolkit: github.com/twilio-labs/serverless-toolkit • Check our existing templates: github.com/twilio-labs/function-templates • Slides: twil.io/signal-serverless-api • Contribute ❤ WHAT’S NEXT?