AWS Lightsail Provider

Deploy preview environments to AWS Lightsail instances via SSH.

How it works

Prerequisites

  1. An AWS account.
  2. An IAM user or role with Lightsail permissions.
  3. An SSH key pair for instance access.

Step 1 — Create IAM credentials

Create an IAM user (or use an existing role) with the following permissions:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "lightsail:CreateInstances",
        "lightsail:DeleteInstance",
        "lightsail:GetInstance",
        "lightsail:GetInstances",
        "lightsail:TagResource"
      ],
      "Resource": "*"
    }
  ]
}
  1. Go to IAM → Users → Create user → Attach policies directly (paste the JSON above as an inline policy).
  2. Create an Access Key for the user.
  3. Store the credentials:
Secret Value
AWS_ACCESS_KEY_ID Access key ID
AWS_SECRET_ACCESS_KEY Secret access key

Step 2 — Create an SSH key pair

ssh-keygen -t ed25519 -C "previewops-lightsail" -f ~/.ssh/previewops-lightsail

Store the private key content as AWS_SSH_PRIVATE_KEY in Previewops secrets:

cat ~/.ssh/previewops-lightsail

Note: The SSH key must match a key pair registered in your Lightsail account. The provider uses your account's default key pair by default — download its private key from the Lightsail console under Account → SSH keys. If you generated a new key pair, import the public key there first under Custom keys → Upload new.

Step 3 — Configure the repo

All providerConfig fields are optional:

provider: aws-lightsail
providerConfig:
  region: us-east-1          # optional (default: us-east-1)
  bundleId: nano_2_0         # optional (default: nano_2_0) — instance size
                             # see: aws lightsail get-bundles
  blueprintId: ubuntu_22_04  # optional (default: ubuntu_22_04) — OS image
                             # see: aws lightsail get-blueprints

Step 4 — Verify

Comment /validate-previewops on any open PR. The bot calls GetInstances against the Lightsail API (which requires valid credentials) and reports the result.

Notes

Troubleshooting

Error Fix
SSH authentication failure / connection refused Ensure AWS_SSH_PRIVATE_KEY matches the key pair registered in Lightsail for this account
AccessDeniedException IAM policy is missing Lightsail permissions
SSH connection refused Instance hasn't finished booting; the provider waits 3 min automatically
Instance never reaches running Check the AWS Lightsail console for quota limits or region availability