Tutorial: 2 Minute OpenClaw Setup on AWS

Get OpenClaw running on AWS in just 2 minutes with this quick tutorial. Includes spot instance setup and cost optimization tips.

Tutorial: 2 Minute OpenClaw Setup on AWS

Want to run your own AI assistant powered by Claude? This tutorial will have you up and running on AWS in about 2 minutes.

Why AWS Spot Instances?

Save ~70% on compute costs while running OpenClaw 24/7. Perfect for personal use or development.

What you'll need:

  • AWS account
  • Anthropic API key (get one here)
  • Telegram account (for chat interface)

Step 1: Launch EC2 Instance (30 seconds)

# Launch Ubuntu 24.04 spot instance (t3.large recommended)
# AWS Console → EC2 → Launch Instance
# - Name: openclaw
# - AMI: Ubuntu 24.04 LTS
# - Instance type: t3.large
# - Request Spot Instance: ✅
# - Storage: 8 GB (default is fine)
# - Security group: Allow SSH (port 22)

Cost: ~$0.025/hour (spot) vs $0.0832/hour (on-demand)

Step 2: Install OpenClaw (1 minute)

SSH into your instance and run:

# Install OpenClaw
curl -fsSL https://openclaw.ai/install | bash

# Run the setup wizard
openclaw onboard

The wizard will ask you for:

  • Your Anthropic API key
  • What messaging platform you want (choose Telegram)
  • Your Telegram bot token (get from @BotFather)

Step 3: Pair with Telegram (30 seconds)

  1. Open your Telegram bot
  2. Send any message
  3. OpenClaw will reply with a pairing code
  4. Run: openclaw pairing approve telegram <code>

Done! 🎉 Your AI assistant is live.

Bonus: Spot Instance Protection

Spot instances can be reclaimed by AWS with 2 minutes notice. Get notified when this happens:

# Save to ~/.openclaw/scripts/spot-monitor.sh
#!/bin/bash
while true; do
    TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
        -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
    
    TERM=$(curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
        http://169.254.169.254/latest/meta-data/spot/instance-action \
        | jq -r '.time // empty')
    
    if [ ! -z "$TERM" ]; then
        # Send Telegram notification via OpenClaw
        curl -X POST http://localhost:18789/api/v1/message/send \
            -H "Authorization: Bearer $(openclaw config get gateway.auth.token)" \
            -H "Content-Type: application/json" \
            -d '{"channel":"telegram","to":"YOUR_CHAT_ID","message":"Instance terminating soon!"}'
        exit 0
    fi
    sleep 30
done

Run as a systemd service for automatic monitoring.

Cost Breakdown

Monthly costs (assuming 24/7 operation):

  • EC2 t3.large spot: ~$18/month
  • EBS storage (8GB): ~$0.80/month
  • Data transfer: ~$1-2/month (minimal)
  • Anthropic API: Pay-as-you-go (varies by usage)

Total infrastructure: ~$20-21/month

Compare to managed solutions at $100+/month - you're saving 80%!

Next Steps

  • Configure additional models (Haiku for simple tasks)
  • Set up browser automation
  • Enable web search
  • Add heartbeat monitoring
  • Connect to Discord, Slack, WhatsApp

Check out the official docs for more.

Troubleshooting

Can't connect to Telegram?

openclaw status
openclaw gateway restart

Need to update?

openclaw update

Check logs:

tail -f ~/.openclaw/logs/gateway.log

Questions? Join the OpenClaw Discord or check the GitHub repo.