Setting Up AWS Lambda
Welcome to the AWS Lambda setup guide! This is where we'll create the cloud API that powers your arcade cabinet. This API handles everything from payments to game control!
Important: Read First!
You can only complete this guide AFTER you have:
- Either pulled the pre-built Docker image (Quick Deploy)
- OR built your own image (Custom Build)
- AND pushed the image to your Container Registry
What is AWS Lambda? 
AWS Lambda hosts your Artcade API in the cloud. Think of it as your arcade's brain that:
- Processes payments from Stripe
- Sends "coin pulse" signals to start games
- Handles "game over" signals
- Creates payment QR codes
- Monitors cabinet status
- Manages multiple arcade machines
Why Lambda for Our API?
- No servers to manage - AWS handles everything
- Only pay when your API is actually being used
- Automatically handles multiple cabinets
- Built-in security and monitoring
- Perfect for APIs that handle occasional requests
Prerequisites 
Before starting, ensure you have:
- Completed Basic AWS Setup
- Set up your Container Registry
- Docker image ready in your registry
- IAM user with Lambda permissions
Creating Your Lambda Function 
STEP 1. Open Lambda Service
- Sign in to AWS Console
- Search for "Lambda"
- Click "Create function"
STEP 2. Configure Function
- Select "Container image"
- Set function name to "artcade-api"
- Select your container image URI from the registry
- Click "Create function"
STEP 3. Configure Environment Variables
- Navigate to the Configuration tab
- Click on Environment Variables
- Add the following variables:
STRIPE_API_KEY
: Your Stripe secret keySTRIPE_WEBHOOK_SECRET
: Your Stripe webhook secretMQTT_USERNAME
: Your EMQX usernameMQTT_PASSWORD
: Your EMQX passwordMQTT_BROKER
: Your EMQX broker addressMQTT_PORT
: Usually 8883 for SSL/TLS connectionPRICE_ID
: Your Stripe Price ID for the game
Security Best Practices
Always use AWS Secrets Manager or AWS Systems Manager Parameter Store for sensitive information like API keys and passwords in a production environment.
Testing Your Lambda 
- Navigate to the Test tab
- Create a new test event
- Select API Gateway HTTP API template
- Save and run the test
- Check results in the execution log
Monitoring Setup 
-
Set Up CloudWatch Monitoring
- Navigate to CloudWatch in AWS Console
- Create alarms for:
- Error rates
- Function duration
- Invocation counts
- Set notification thresholds
Free Tier Limits
- 1M free requests per month
- 400,000 GB-seconds compute time
- Perfect for arcade cabinets!
Next Steps 
Once your Lambda function is set up, you'll need to:
- Understand how API Gateway works
- Configure API Gateway for your Lambda
- Test the complete system
Continue to API Gateway Introduction โ Back to Container Registry
Troubleshooting 
Common Lambda issues:
-
Container errors:
- Check your Docker image
- Verify the image URI
- Look at CloudWatch logs
-
Permission errors:
- Check IAM roles
- Verify execution permissions
- Review security settings
-
Environment issues:
- Verify all variables are set
- Check for typos in values
- Confirm secrets are properly stored
Need Help?
- Check Troubleshooting Guide
- Review CloudWatch logs
- Ask your teacher or mentor