Cloud Development Intermediate
Develop with Claude Code on cloud platforms — from major cloud providers like AWS, GCP, and Azure to cloud IDEs like GitHub Codespaces and Gitpod. Learn setup, configuration, and cost optimization for each platform.
AWS EC2 + Claude Code
# Launch an EC2 instance (Amazon Linux 2023 or Ubuntu) # Install Node.js and Claude Code $ ssh -i my-key.pem ec2-user@ec2-xx-xx-xx-xx.compute.amazonaws.com # Install Node.js via nvm $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash $ source ~/.bashrc $ nvm install 20 # Install Claude Code $ npm install -g @anthropic-ai/claude-code # Use AWS Secrets Manager for API key $ export ANTHROPIC_API_KEY=$(aws secretsmanager get-secret-value \ --secret-id claude-api-key \ --query SecretString --output text) # Start developing $ cd /home/ec2-user/my-project $ claude
Google Cloud Shell
Google Cloud Shell provides a free, ephemeral VM with 5GB of persistent storage:
# Google Cloud Shell already has Node.js # Open Cloud Shell from console.cloud.google.com # Install Claude Code $ npm install -g @anthropic-ai/claude-code # Store API key in Secret Manager $ export ANTHROPIC_API_KEY=$(gcloud secrets versions access latest \ --secret=claude-api-key) # Clone your project and start coding $ git clone https://github.com/your-org/project.git $ cd project $ claude -p "Set up the development environment and run the app"
Azure VM
# SSH into your Azure VM $ ssh azureuser@my-vm.eastus.cloudapp.azure.com # Install Node.js $ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - $ sudo apt-get install -y nodejs # Install Claude Code $ sudo npm install -g @anthropic-ai/claude-code # Use Azure Key Vault for API key $ export ANTHROPIC_API_KEY=$(az keyvault secret show \ --vault-name my-vault \ --name claude-api-key \ --query value -o tsv) $ claude
GitHub Codespaces
GitHub Codespaces provides a full development environment in the cloud, accessible from your browser:
{
"name": "Claude Code Development",
"image": "mcr.microsoft.com/devcontainers/javascript-node:20",
"postCreateCommand": "npm install -g @anthropic-ai/claude-code && npm install",
"secrets": {
"ANTHROPIC_API_KEY": {
"description": "Your Anthropic API key for Claude Code"
}
},
"customizations": {
"codespaces": {
"openFiles": ["CLAUDE.md"]
}
}
}
ANTHROPIC_API_KEY as a Codespace secret in your GitHub repository settings (Settings → Secrets and Variables → Codespaces). It will be automatically available as an environment variable.
Gitpod
image: file: .gitpod.Dockerfile tasks: - name: Setup init: | npm install -g @anthropic-ai/claude-code npm install command: | echo "Claude Code ready! Run 'claude' to start." vscode: extensions: - anthropic.claude-code
FROM gitpod/workspace-node-lts RUN npm install -g @anthropic-ai/claude-code
Cloud Platform Comparison
| Platform | Free Tier | Persistent Storage | Best For |
|---|---|---|---|
| AWS EC2 | t2.micro (750 hrs/mo) | Yes (EBS) | Full control, production-like environments |
| Google Cloud Shell | Free (with limits) | 5GB home directory | Quick tasks, GCP-integrated projects |
| Azure VM | B1s (750 hrs/mo) | Yes (managed disk) | Enterprise, Azure-integrated projects |
| GitHub Codespaces | 60 hrs/mo (2-core) | Yes (per codespace) | GitHub-hosted projects, team onboarding |
| Gitpod | 50 hrs/mo | Limited | Open source projects, quick iterations |
| Railway | $5 free credit | Yes | Quick deployments, small projects |
Cost Optimization
Running Claude Code in the cloud adds both compute costs and API costs. Here are strategies to minimize expenses:
- Right-size instances: Claude Code itself needs minimal compute (1 vCPU, 1GB RAM). Don't overprovision.
- Use spot/preemptible instances: Save 60-90% on compute for development workloads.
- Auto-shutdown: Configure instances to stop after idle periods.
- Use
-pmode: One-shot commands are cheaper than long interactive sessions (less token overhead). - Cache results: Store Claude's analysis output to avoid re-running the same queries.
- Batch operations: Group related tasks into a single Claude session rather than multiple separate calls.
# Auto-shutdown script for EC2 (add to cron) # Stops instance after 30 minutes of no SSH sessions #!/bin/bash IDLE=$(who | wc -l) if [ "$IDLE" -eq 0 ]; then sudo shutdown -h now fi
Multi-Environment Setup
Configure different Claude Code settings for different environments:
# ~/.bashrc - environment-specific configuration case "$(hostname)" in dev-*) export ANTHROPIC_API_KEY=$(aws secretsmanager get-secret-value --secret-id claude-dev --query SecretString --output text) ;; staging-*) export ANTHROPIC_API_KEY=$(aws secretsmanager get-secret-value --secret-id claude-staging --query SecretString --output text) ;; prod-*) # Read-only analysis only in production export ANTHROPIC_API_KEY=$(aws secretsmanager get-secret-value --secret-id claude-prod --query SecretString --output text) alias claude='claude --allowedTools "Read,Grep,Glob"' ;; esac
Try It Yourself
Try setting up Claude Code in a GitHub Codespace — it's the quickest way to get started with cloud development. Next, learn best practices for secure and efficient remote usage.
Next: Best Practices →
Lilly Tech Systems