
aws-lightsail
aws-lightsail
Overview
Amazon Lightsail is a lightweight, cloud service that offers virtual private servers (VPSS) with simple networking and storage options.
The AWS CLI provides several commands to manage your Lightsail resources. The following are the most common operations:
List All Virtual Private Servers
aws lightsail get-instances
This command retrieves all VPSS instances available in your account.
List All Bundles (Instance Plans)
aws lightsail list-bundles
Shows the available bundle types, such as “nano_2_0”, “micro_4_1”, etc. These bundles specify CPU, RAM, storage, and network limits.
List All Blueprints (Instance Images)
aws lightsail list-blueprints
Displays all image templates you can use to create a new instance.
Create an Instance
aws lightsail create-instances --instance-names "my-vps" --availability-zone "us-east-1" --bundle-id "nano_2_0" --blueprint-id "basic_ubuntu_20_04"
*Note: --instance-names
can be multiple names separated by commas, e.g., “vps1,vps2”.
Get Instance State
aws lightsail get-instance-state --instance-name "my-vps"
This command returns the current status (e.g., running
, stopped
).
Stop a Specific Instance
aws lightsail stop-instance --instance-name "my-vps"
The instance will be halted, but its storage remains intact.
Delete an Instance
aws lightsail delete-instance --instance-name "my-vps"
This command removes the instance permanently. All data and snapshots are deleted.
Common Pitfalls
-
Missing Bundle ID: If you omit
--bundle-id
, the CLI will fail. The bundle ID must be a valid identifier like “nano_2_0”. -
Incorrect Availability Zone: Use the correct zone name, e.g., “us-east-1” or “eu-west-2”, otherwise the instance cannot be created.
-
Invalid Blueprint ID: Ensure that
--blueprint-id
matches a known blueprint. If you use an unknown id, the CLI returns error. -
Multiple Instance Names: Use comma-separated names for multiple instances; if you include spaces or special characters, the command fails.
Tips
-
**Run
aws lightsail list-bundles
before selecting a bundle to ensure you have the desired CPU/RAM. -
**Check
aws lightsail get-instance-state
after stopping an instance to confirm it is stopped. -
**Use
aws lightsail delete-instance
only when you are sure that no data will be lost.