iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

Lightsail

Lightsail is AWSs simple VPS product: a fixed monthly price for a virtual machine that includes compute, storage, bandwidth, and a managed firewall. Use it for hobby projects, small marketing sites, staging boxes, and anything where EC2 + VPC + ALB + NAT is too much ceremony. It is the right pick when you would otherwise reach for DigitalOcean or Linode.

Create, configure, deploy, snapshot, and grow

EXAMPLE
# 1) Create an instance — Linux/Unix > Ubuntu LTS, smallest bundle
aws lightsail create-instances \
  --instance-names shop-web-1 \
  --availability-zone ap-southeast-2a \
  --blueprint-id ubuntu_24_04 \
  --bundle-id nano_3_0 \
  --user-data file://cloud-init.sh \
  --tags 'key=project,value=shop' 'key=env,value=prod'

# cloud-init.sh — runs on first boot
# #!/bin/bash
# apt-get update && apt-get -y install nginx certbot python3-certbot-nginx
# useradd -m -s /bin/bash shop
# echo 'shop ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/shop

# 2) Get the public IP and SSH details
aws lightsail get-instance --instance-name shop-web-1 \
  --query 'instance.{ip:publicIpAddress,user:username}'

# 3) Open ports via the simple firewall
aws lightsail put-instance-public-ports \
  --instance-name shop-web-1 \
  --port-infos \
    fromPort=22,toPort=22,protocol=tcp,cidrs=203.0.113.0/24 \
    fromPort=80,toPort=80,protocol=tcp \
    fromPort=443,toPort=443,protocol=tcp

# 4) Static IP — attach so reboots do not change it
aws lightsail allocate-static-ip --static-ip-name shop-web-1-ip
aws lightsail attach-static-ip --static-ip-name shop-web-1-ip --instance-name shop-web-1

# 5) Lightsail managed database (optional — saves the operational burden)
aws lightsail create-relational-database \
  --relational-database-name shop-db \
  --relational-database-blueprint-id postgres_16 \
  --relational-database-bundle-id micro_2_0 \
  --master-database-name shop --master-username dbadmin \
  --master-user-password "$(openssl rand -base64 24)" \
  --publicly-accessible no

# 6) Snapshot before risky changes; restore by creating an instance from snapshot
aws lightsail create-instance-snapshot \
  --instance-snapshot-name shop-web-1-$(date +%F) \
  --instance-name shop-web-1

# 7) Outgrow Lightsail? Export the snapshot to EC2 in two clicks
aws lightsail create-cloud-formation-stack \
  --instances 'sourceName=shop-web-1-2026-06-11,instanceType=t4g.small,availabilityZone=ap-southeast-2a,portInfoSource=INSTANCE,userData=#cloud-config'

# 8) Container service — Lightsail also runs containers behind HTTPS,
#    cheaper than ECS Fargate for tiny apps
aws lightsail create-container-service \
  --service-name shop-app --power nano --scale 1

aws lightsail create-container-service-deployment \
  --service-name shop-app \
  --containers '{"web":{"image":":shop-app.web.latest","ports":{"3000":"HTTP"}}}' \
  --public-endpoint '{"containerName":"web","containerPort":3000,"healthCheck":{"path":"/health"}}'

Why it matters

Lightsail is the right pick when the question is "how do I spend the least time on infrastructure?". When you outgrow it (more than one instance, load balancing, IAM-driven access, VPC peering), export the snapshot to EC2 — Amazon supports the migration explicitly, so the platform lock-in is light.

Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.

Example

Example
# Simple VPS pricing for small/predictable workloads.
Try it Yourself »

Discussion

Loading…