Guides

Compute Instance Management

Complete guide to managing Lambda compute instances.


Instance Lifecycle

Understanding the complete lifecycle of a Lambda instance.


Creating Instances

You can create instances using the Dashboard (recommended for beginners) or the CLI (for automation).

Option 1: Using the Dashboard

  1. Go to dashboard.lambda.io/instances
  2. Click "Create Instance"
  3. Fill in the configuration:
    • Name: my-instance
    • Type: compute-4x
    • Region: us-west-1
    • Image: ubuntu-22.04
  4. (Optional) Add SSH keys, tags, and advanced options
  5. Click "Launch Instance"

Option 2: Using the CLI

Basic Creation:

lambda create instance \
  --name my-instance \
  --type compute-4x \
  --region us-west-1 \
  --image ubuntu-22.04

Advanced Creation:

lambda create instance \
  --name production-api \
  --type compute-8x \
  --region eu-west-1 \
  --image ubuntu-22.04 \
  --ssh-keys key_abc123,key_def456 \
  --tags env=production,app=api,team=backend \
  --encryption-key ~/.keys/master-key.pem \
  --user-data ./cloud-init.sh \
  --firewall-preset web-server \
  --monitoring enabled \
  --backup-schedule daily \
  --wait

Creation Options Explained

OptionDescriptionRequired
--nameInstance nameYes
--typeInstance type (compute-, memory-, etc.)Yes
--regionGeographic regionYes
--imageOS imageYes
--ssh-keysSSH key IDs (comma-separated)No
--tagsKey=value tagsNo
--encryption-keyCustom encryption keyNo
--user-dataInitialization scriptNo
--firewall-presetPreset firewall configNo
--monitoringEnable monitoringNo
--backup-scheduleAuto-snapshot scheduleNo
--waitWait until readyNo

Instance Types

Choosing the Right Type

Compute-Optimized (compute-*)

Best for:

  • Web servers
  • API backends
  • Microservices
  • CI/CD runners
  • General purpose workloads

Specifications:

TypevCPURAMStoragePrice/hr
compute-1x12 GB25 GB$0.05
compute-2x24 GB50 GB$0.10
compute-4x48 GB100 GB$0.20
compute-8x816 GB200 GB$0.40
compute-16x1632 GB400 GB$0.80
compute-32x3264 GB800 GB$1.60

Memory-Optimized (memory-*)

Best for:

  • Databases (PostgreSQL, MySQL, MongoDB)
  • Redis/Memcached
  • Elasticsearch
  • Big data analytics
  • In-memory processing

Specifications:

TypevCPURAMStoragePrice/hr
memory-2x216 GB50 GB$0.15
memory-4x432 GB100 GB$0.30
memory-8x864 GB200 GB$0.60
memory-16x16128 GB400 GB$1.20
memory-32x32256 GB800 GB$2.40

Storage-Optimized (storage-*)

Best for:

  • Data warehouses
  • Log aggregation
  • Search engines
  • Time-series databases
  • High-throughput workloads

Specifications:

TypevCPURAMStorageIOPSPrice/hr
storage-2x28 GB500 GB10K$0.20
storage-4x416 GB1 TB20K$0.40
storage-8x832 GB2 TB40K$0.80
storage-16x1664 GB4 TB80K$1.60

GPU-Enabled (gpu-*)

Best for:

  • Machine learning training
  • Deep learning inference
  • Video transcoding
  • Scientific computing
  • Graphics rendering

Specifications:

TypeGPUvCPURAMStoragePrice/hr
gpu-1x1x A100 40GB864 GB500 GB$2.50
gpu-2x2x A100 40GB16128 GB1 TB$5.00
gpu-4x4x A100 40GB32256 GB2 TB$10.00
gpu-h100-1x1x H100 80GB8128 GB1 TB$4.00
gpu-h100-2x2x H100 80GB16256 GB2 TB$8.00

Managing Instances

Listing Instances

# List all instances
lambda list instances

# Filter by status
lambda list instances --status running

# Filter by region
lambda list instances --region us-west-1

# Filter by tags
lambda list instances --tag env=production

# JSON output
lambda list instances --output json

Getting Instance Details

# Basic info
lambda status inst_abc123

# Detailed info
lambda info inst_abc123 --verbose

# JSON output
lambda info inst_abc123 --output json

Starting, Stopping, and Restarting

Via Dashboard:

  1. Go to Dashboard → Instances
  2. Click on your instance
  3. Use action buttons:
    • Start - Power on stopped instance
    • Stop - Gracefully shut down
    • Force Stop - Immediate shutdown
    • Restart - Reboot instance

Via CLI:

# Start stopped instance
lambda start inst_abc123

# Stop running instance
lambda stop inst_abc123

# Force stop (immediate, no graceful shutdown)
lambda stop inst_abc123 --force

# Restart instance
lambda restart inst_abc123

# All with wait flag
lambda start inst_abc123 --wait

Resizing Instances

Via Dashboard:

  1. Go to your instance page
  2. Click "Resize" button
  3. Select new instance type
  4. Click "Resize Instance"
  5. Instance will restart automatically with new resources

Via CLI:

# Resize to larger type
lambda resize inst_abc123 --type compute-8x

# Resize with wait
lambda resize inst_abc123 --type memory-16x --wait

# Check if resize requires restart
lambda resize inst_abc123 --type storage-4x --dry-run

Note: Resizing causes brief downtime (typically 30-60 seconds).


Instance Configuration

User Data (Cloud-Init)

Execute scripts at instance creation:

# Create init script
cat > init.sh << 'EOF'
#!/bin/bash
apt update && apt upgrade -y
apt install -y nginx docker.io
systemctl enable nginx
systemctl start nginx
echo "Setup complete" > /var/log/init-complete.log
EOF

# Create instance with user data
lambda create instance \
  --name auto-configured \
  --type compute-4x \
  --region us-west-1 \
  --image ubuntu-22.04 \
  --user-data init.sh

Metadata Service

Access instance metadata from within the instance:

# Get instance ID
curl http://169.254.169.254/latest/meta-data/instance-id

# Get instance type
curl http://169.254.169.254/latest/meta-data/instance-type

# Get public IP
curl http://169.254.169.254/latest/meta-data/public-ipv4

# Get user data
curl http://169.254.169.254/latest/user-data

Tags

Organize and filter instances with tags:

# Add tags
lambda tag add inst_abc123 \
  env=production \
  app=api \
  version=2.0

# List tags
lambda tag list inst_abc123

# Remove tag
lambda tag remove inst_abc123 env

# Filter by tags
lambda list instances --tag env=production,app=api

Networking

Public vs Private IPs

Public IP:

  • Accessible from internet
  • Static (doesn't change)
  • Used for external access
  • Can be released and reassigned

Private IP:

  • Used for instance-to-instance communication
  • Never exposed to internet
  • Free data transfer between instances
  • Assigned automatically
# Get network info
lambda network info inst_abc123

# Assign public IP
lambda network assign-ip inst_abc123

# Release public IP (makes instance private-only)
lambda network release-ip inst_abc123

DNS

Lambda provides automatic DNS for instances:

inst_abc123.lambda.io → 203.0.113.42
inst_abc123.internal → 10.0.1.5

Storage Management

Root Volume

Every instance has a root volume:

  • Contains OS and system files
  • Size determined by instance type
  • Encrypted with your keys
  • Persists when instance is stopped
  • Deleted when instance is destroyed

Attached Volumes

Add extra storage:

# Create volume
lambda create volume \
  --name app-data \
  --size 500GB \
  --region us-west-1

# Attach to instance
lambda attach volume vol_abc123 --instance inst_xyz789

# Inside instance, mount it
ssh lambda@instance-ip
sudo mkfs.ext4 /dev/vdb
sudo mount /dev/vdb /mnt/data

# Detach volume
lambda detach volume vol_abc123

Resize Root Volume

# Resize volume
lambda volume resize vol_abc123 --size 200GB

# Expand filesystem (inside instance)
ssh lambda@instance-ip
sudo resize2fs /dev/vda1

Backups & Snapshots

Manual Snapshots

Via Dashboard:

  1. Go to Dashboard → Instances
  2. Click on your instance
  3. Go to "Snapshots" tab
  4. Click "Create Snapshot"
  5. Enter name and description
  6. Click "Create"

To restore: Go to "Snapshots" section, select snapshot, click "Create Instance from Snapshot"

Via CLI:

# Create snapshot
lambda snapshot create inst_abc123 \
  --name "pre-deploy-$(date +%Y%m%d)" \
  --description "Backup before deployment"

# List snapshots
lambda snapshot list --instance inst_abc123

# Restore from snapshot
lambda create instance \
  --from-snapshot snap_abc123 \
  --name restored-instance

# Delete snapshot
lambda snapshot delete snap_abc123

Scheduled Snapshots

Via Dashboard:

  1. Go to your instance → "Snapshots" tab
  2. Click "Schedule Automatic Snapshots"
  3. Configure:
    • Frequency: Daily/Weekly/Monthly
    • Time: Select hour (UTC)
    • Retention: Number of snapshots to keep
  4. Click "Save Schedule"

Via CLI:

# Daily at 2 AM UTC, keep 7 days
lambda snapshot schedule inst_abc123 \
  --frequency daily \
  --time "02:00" \
  --retain 7

# Weekly on Sunday, keep 4 weeks
lambda snapshot schedule inst_abc123 \
  --frequency weekly \
  --day sunday \
  --retain 4

# View snapshot schedule
lambda snapshot schedule inst_abc123 --show

# Disable schedule
lambda snapshot schedule inst_abc123 --disable

Monitoring

Real-Time Metrics

Via Dashboard (Recommended):

  1. Go to Dashboard → Instances
  2. Click on your instance
  3. View the "Metrics" tab for:
    • CPU usage graphs
    • Memory utilization
    • Network traffic
    • Disk I/O
    • Custom time ranges

Via CLI:

# View live metrics
lambda metrics inst_abc123

# Specific metric
lambda metrics inst_abc123 --metric cpu
lambda metrics inst_abc123 --metric memory
lambda metrics inst_abc123 --metric network

# Time period
lambda metrics inst_abc123 --period 24h --metric cpu

Alerts

Via Dashboard:

  1. Go to your instance → "Alerts" tab
  2. Click "Create Alert"
  3. Configure:
    • Name: High CPU
    • Metric: CPU
    • Condition: > 80%
    • Duration: 5 minutes
    • Notification: Email/Webhook/Slack
  4. Click "Create Alert"

Via CLI:

# Create alert
lambda alert create inst_abc123 \
  --name "High CPU" \
  --condition "cpu > 80" \
  --duration "5m" \
  --notify email:ops@example.com

# List alerts
lambda alert list inst_abc123

# Delete alert
lambda alert delete alert_abc123

Health Checks

# Enable health checks
lambda health-check enable inst_abc123 \
  --type http \
  --path "/health" \
  --port 80 \
  --interval 30s

# View health status
lambda health-check status inst_abc123

Security

Firewall Rules

# Allow HTTP
lambda firewall allow inst_abc123 \
  --port 80 \
  --source 0.0.0.0/0

# Allow SSH from specific IP
lambda firewall allow inst_abc123 \
  --port 22 \
  --source 203.0.113.0/24

# List rules
lambda firewall list inst_abc123

# Remove rule
lambda firewall remove inst_abc123 --rule rule_abc123

SSH Key Management

# List keys on instance
lambda ssh-keys list --instance inst_abc123

# Add key to instance
lambda ssh-keys update inst_abc123 --add key_new123

# Remove key from instance
lambda ssh-keys update inst_abc123 --remove key_old123

Security Hardening

# Run security audit
lambda security audit inst_abc123

# Apply hardening
lambda security harden inst_abc123 \
  --disable-root \
  --force-key-auth \
  --enable-firewall \
  --auto-updates

Cost Optimization

Stop Unused Instances

# Stop instance (pay only for storage)
lambda stop inst_abc123

# Savings: ~90% (still pay for storage)

Right-Sizing

# Check utilization
lambda metrics inst_abc123 --period 7d

# If consistently < 50% CPU/memory, downsize
lambda resize inst_abc123 --type compute-2x

Use Spot Instances (Coming Soon)

For non-critical workloads, spot instances offer 60-80% discounts.


Automation

Using API

from lambda_sdk import Lambda

lambda_client = Lambda(api_key='λ_sk_...')

# Create instance
instance = lambda_client.instances.create(
    name='auto-instance',
    instance_type='compute-4x',
    region='us-west-1',
    image='ubuntu-22.04'
)

# Wait until ready
instance.wait_until_ready()

# Deploy application
instance.ssh_execute('git clone https://github.com/user/app')

# Create snapshot
snapshot = instance.create_snapshot(name='deployed')

Terraform

resource "lambda_instance" "web" {
  name          = "web-server"
  type          = "compute-4x"
  region        = "us-west-1"
  image         = "ubuntu-22.04"
  ssh_keys      = [lambda_ssh_key.deploy.id]

  tags = {
    Environment = "production"
    Application = "web"
  }
}

resource "lambda_firewall_rule" "http" {
  instance_id = lambda_instance.web.id
  port        = 80
  source      = "0.0.0.0/0"
  protocol    = "tcp"
}

Best Practices

1. Use Tags for Organization

lambda tag add inst_abc123 \
  env=production \
  app=api \
  team=backend \
  cost-center=engineering

2. Enable Automatic Backups

lambda snapshot schedule inst_abc123 \
  --frequency daily \
  --retain 7

3. Set Up Monitoring

lambda monitoring enable inst_abc123 \
  --alerts cpu,memory,disk \
  --notify email:team@example.com

4. Use Security Groups

Create reusable firewall presets:

lambda firewall-preset create web-server \
  --allow 80/tcp \
  --allow 443/tcp \
  --allow 22/tcp:203.0.113.0/24

5. Document Instance Purpose

lambda instance update inst_abc123 \
  --description "Production API server - handles user authentication"

Next Step

Secure your instances with our best practices guide.

Security Best Practices →


Think Lambda, Think Privacy