In this application we have 7 AWS Lambda functions:
- 6 of them are used like API calls (using the Amazon API Gateway service)
- 1 of them is triggered by a scheduler (using the Amazon CloudWatch service).
All functions are located in functions directory.
All unit tests are located in tests directory.
-
add_participant - Adds a new participant into the current poll and returns the new participant ID. (REST POST method)
Lambda policies/permisions (used DynamoDB operation - table):
get_item - fp.config
get_item - fp.polls
query - fp.participants
put_item - fp.participantsRequest body:
{ "person" : "", "friend" : "" }
-
delete_participant - Deletes a participant from the current poll. (REST DELETE method)
Lambda policies/permisions (used DynamoDB operation - table):
get_item - fp.config
delete_item - fp.participantsRequest body:
{ "participant_id" : "" }
-
get_old_polls - Returns 5 polls at most, older than the oldest poll on the web site. (REST GET method)
Lambda policies/permisions (used DynamoDB operation - table):
batch_get_item - fp.pollsRequest body:
{ "last_poll" : "" }
-
get_poll_participants - Returns all participants from the chosen poll. (REST GET method)
Lambda policies/permisions (used DynamoDB operation - table):
query - fp.participantsRequest body:
{ "poll_id" : "" }
-
get_site_data - Returns all data needed to start the web site (current poll info, current poll participants, all persons - for stats, 3 polls older than the current). (REST GET method)
Lambda policies/permisions (used DynamoDB operation - table):
get_item - fp.config
batch_get_item - fp.polls
query - fp.participants
scan - fp.personsRequest body:
{}
-
update_current_poll - Updates the current poll info (end, dt, title, note, locDesc, locUrl, need, max - some of these or all). (REST PUT method)
Lambda policies/permisions (used DynamoDB operation - table):
get_item - fp.admins
get_item - fp.config
query - fp.participants
update_item - fp.pollsRequest body:
{ "adimin_name" : "", "admin_password" : "", "title" : "", "note" : "", "locUrl" : "", "locDesc" : "", "max" : "", "need" : "", "end" : "", "dt" : "" }
-
check_if_current_poll_expired - Checks if the current poll is expired (if current date is greater than the end date from the current poll). If the current poll is expired then if there are enough participants updates the persons table with the participants from the current poll, otherwise deletes all participants, and at the end updates the current poll id in the config table and creates a new poll.
This function will be executed (with the CloudWatch Event Rule that triggers on a schedule) every day after midnight at 00:05 (or 22:05 according to GMT, eu-central-1 region is GMT +2), cron expression: 5 22 * * ? *.Lambda policies/permisions (used DynamoDB operation - table):
get_item - fp.config
get_item - fp.polls
query - fp.participants
scan - fp.persons
batch_write_item - fp.persons
update_item - fp.persons
put_item - fp.polls
update_item - fp.config