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
-
Clone this project
$ git clone https://github.com/twilio-infra-as-code/voting-system
-
Install dependencies
$ npm install
-
Select Twilio project / profile
$ twilio profile:use <profile-name>
-
Create a new stack called
dev
:$ twilio infra:environment:new dev
-
Set the AWS region:
$ pulumi config set aws:region us-east-1
-
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_KEY
AWS access key secretINCOMING_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
-
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 serverlessvoting-system:dynamoClientSecretAccessKey
: AWS access key secret
-
Run the following command to preview and deploy changes:
$ twilio infra:deploy
-
Run the following command to tear down all resources:
$ twilio infra:destroy
-
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.