Skip to content

twilio-infra-as-code/voting-system-demo

Repository files navigation

Voting system with Twilio Phone Numbers, Functions and AWS DynamoDB

A simple phone based voting system backed by Twilio Phone Numbers and Functions that receives the vote as a DTMF and stores it in AWS DynamobDB.

This solution is used for the webinar: Building Communication Workflows with Twilio, Pulumi, and AWS

Pre-requisites

Deploying and running the program

  1. Clone this project

    $ git clone https://github.com/twilio-infra-as-code/voting-system
  2. Install dependencies

    $ npm install
  3. Select Twilio project / profile

    $ twilio profile:use <profile-name>
  4. Create a new stack called dev:

    $ twilio infra:environment:new dev
  5. Set the AWS region:

    $ pulumi config set aws:region us-east-1
    
  6. Create a new file called .env.<stack-name> (where <environment-name> is the name of the environment / Pulumi stack created above, e.g. .env.dev). The file should contain definition for the following variables:

    • AWS_ACCESS_KEY_ID: AWS access key (to provision the dynamo DB)
    • AWS_SECRET_ACCESS_KEYAWS access key secret
    • INCOMING_NUMBER_SID: Twilio phone number sid (PNxxxxxxxxx)
    • MENU_MESSAGE: (optional) Default: Welcome. Press 1 to leave a vote
    • VOTE_MESSAGE: (optionl) Default: Please enter your vote from 1 to 5
  7. Edit the file Pulumi.dev.yaml and add a value for the following variables:

    • voting-system:dynamoClientAccessKeyId: AWS access key to create records in DynamoDB from Twilio serverless
    • voting-system:dynamoClientSecretAccessKey: AWS access key secret
  8. Run the following command to preview and deploy changes:

    $ twilio infra:deploy

Clean up

  1. Run the following command to tear down all resources:

    $ twilio infra:destroy
  2. To delete the stack itself you need to use the Pulumi CLI directly:

    $ pulumi stack rm <environment-name>

    Note that this command deletes all deployment history from the Pulumi Console.

About

Demo of a voting system using Twilio, Pulumi and AWS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published