Skip to content

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:

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:

Creating Your Lambda Function ๐Ÿ”ง

STEP 1. Open Lambda Service

  1. Sign in to AWS Console
  2. Search for "Lambda"
  3. Click "Create function"

STEP 2. Configure Function

  1. Select "Container image"
  2. Set function name to "artcade-api"
  3. Select your container image URI from the registry
  4. Click "Create function"

STEP 3. Configure Environment Variables

  1. Navigate to the Configuration tab
  2. Click on Environment Variables
  3. Add the following variables:
    • STRIPE_API_KEY: Your Stripe secret key
    • STRIPE_WEBHOOK_SECRET: Your Stripe webhook secret
    • MQTT_USERNAME: Your EMQX username
    • MQTT_PASSWORD: Your EMQX password
    • MQTT_BROKER: Your EMQX broker address
    • MQTT_PORT: Usually 8883 for SSL/TLS connection
    • PRICE_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 ๐Ÿงช

  1. Navigate to the Test tab
  2. Create a new test event
  3. Select API Gateway HTTP API template
  4. Save and run the test
  5. Check results in the execution log

Monitoring Setup ๐Ÿ“ˆ

  1. Set Up CloudWatch Monitoring

    1. Navigate to CloudWatch in AWS Console
    2. Create alarms for:
      • Error rates
      • Function duration
      • Invocation counts
    3. 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:

  1. Understand how API Gateway works
  2. Configure API Gateway for your Lambda
  3. Test the complete system

Continue to API Gateway Introduction โ†’ Back to Container Registry

Troubleshooting ๐Ÿ”ง

Common Lambda issues:

  1. Container errors:

    • Check your Docker image
    • Verify the image URI
    • Look at CloudWatch logs
  2. Permission errors:

    • Check IAM roles
    • Verify execution permissions
    • Review security settings
  3. Environment issues:

    • Verify all variables are set
    • Check for typos in values
    • Confirm secrets are properly stored

Need Help?