Async, event-driven service that awards points and maintains action-stat counters when users performs actions.
Producer services (EventBridge events)
│
▼
EventBridge Bus ─────► EventBridge Rules
│
▼
UserRewardsConsumerFunction
│ │
▼ ▼
UserPointsHistory UserActionStats
- AWS CLI - Install the AWS CLI
- You DO NOT have to create an AWS account to use AWS CLI for this project, skip these steps if you don't want to create an AWS account
- AWS CLI looks for credentials when using it, but doesn't validate. So will need to set some fake one. But the region name matters, use any valid region name.
$ aws configure $ AWS Access Key ID: [ANYTHING YOU WANT] $ AWS Secret Access Key: [ANYTHING YOUR HEART DESIRES] $ Default region nam: us-east-1 $ Default output format [None]: (YOU CAN SKIP)
- SAM CLI - Install the SAM CLI
- You DO NOT need to create an aws account to use SAM CLI for this project, skip these steps if you don't want to create an aws account
- Note: if you are getting the following error:
runtime is not supportedwhen runningsam build --use-containermake sure your SAM CLI version is up to date
- Python 3 - Install Python 3
- Docker - Install Docker
Guide that was used: https://betterprogramming.pub/how-to-deploy-a-local-serverless-application-with-aws-sam-b7b314c3048c
Follow these steps to get Dynamodb running locally
-
Start a local DynamoDB service
$ docker compose up # OR if you want to run it in the background: $ docker compose up -d -
Create tables
$ ./local_scripts/create_local_dynamodb_tables.py
# 1. Create a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# 2. Install dependencies
make install# Run all tests with verbose output
make test
# Run with coverage report (generates htmlcov/)
make test-cov
# Run a single test file
PYTHONPATH=functions/fridge_report_consumer pytest tests/test_rules.py -v# Build Lambda package (resolves dependencies)
make build
# Invoke locally with a FridgeReportUpdated event (both reports present)
make invoke-fridge-report-updated
# Invoke locally with a FridgeReportUpdated event (no previous report)
make invoke-fridge-report-updated-new-only
# Use sam local invoke directly with any event file
sam local invoke UserRewardsConsumerFunction \
--event events/status_update_created.json \
--env-vars env.local.json# First-time guided deploy (creates samconfig.toml)
sam deploy --guided
# Subsequent deploys
make deploy
# Override environment
make deploy ENV=stagingSee LICENSE.