5 minutes
AWS Lightsail
Lightsail setup…
So, Lightsail? There are numerous other cloud providers (Digital Ocean, Vultr, OVH), why would I want to use Lightsail? Well, Lightsail is pretty cool since it has the benefits of a VPS, but the reliablity of AWS. When I say benefits of a VPS, what the hell does that mean?
What is Amazon Lightsail?
Amazon Lightsail is the easiest way to get started with AWS, providing everything you need to get your project running in the cloud. Lightsail provides developers compute, storage, and networking capacity and capabilities to deploy and manage websites, web applications, and databases in the cloud. Lightsail includes everything you need to launch your project quickly – a virtual machine, a managed database, SSD-based storage, data transfer, DNS management, and a static IP – for a low, predictable monthly price. You can also scale out your application or website over time and improve its availability and redundancy by adding other Lightsail resources, like load balancers, attached block storage and managed databases.
What can I do with Lightsail?
You can create preconfigured virtual private servers (instances) that include everything to easily deploy and manage your application, or create databases for which the security and health of the underlying infrastructure and operating system is managed by Lightsail. Lightsail is best suited to projects that require a few dozen instances or less, and developers who prefer a simple management interface. Common use cases for Lightsail include running websites, web applications, business software, blogs, e-commerce sites, and more. As your project grows, you can use load balancers and attached block storage with your instance to increase redundancy and uptime and access dozens of other AWS services to add new capabilities.
Ok, so now that we know what lightsail is, why did I personally pick it? Well, I work at Amazon and why pay a competitor for something that I
Once you pick what location, os/app, and size (I personally use the $5/mo 1vpu, 1gb memory, 40gb ssd, 2tb traffic), download your pem file and then start it. This is for Linux.
cd to the directory you downloaded the pem to, then copy it to your home/ssh folder.
➜ Downloads ls | grep pem
LightsailDefaultKey-ap-southeast-1.pem
➜ Downloads mv LightsailDefaultKey-ap-southeast-1.pem ~/.ssh
➜ Downloads cd ~/.ssh
➜ .ssh ls
config id_ed25519 id_ed25519.pub known_hosts LightsailDefaultKey-ap-southeast-1.pem
Great, now we see the pem file in the .ssh folder. how what the hell do we do? We will need to change the security on the file and then edit our config file so to make it easier to ssh to our instance.
➜ .ssh chmod 600 LightsailDefaultKey-ap-southeast-1.pem
Now you will want to go into the editor of your choice (nano/vim) and setup the ssh config file. Your variables will be as such, hostname being the ip address of your instance, the user being ec2-user
if you have Amazon Linux or ubuntu
if you have Ubuntu.
Host = aws
Hostname = ip-from-lightsail
User =
IdentityFile = ~/.ssh/LightsailDefaultKey-ap-southeast-1.pem
After you have that populated, go ahead and save the file and then test by sshing to that alias. You should see a warning such as this, go ahead and type yes
then hit enter.
➜ .ssh ssh aws
The authenticity of host 'hostname (ip.address)' can't be established.
ECDSA key fingerprint is SHA256:Fh4ECJ9cx30yjpu2CKOM73Agr20ZsYri5ALs7SIehqg.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
And you’re in!
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1021-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Fri Jul 12 10:27:18 UTC 2020
System load: 0.0 Processes: 84
Usage of /: 2.6% of 38.71GB Users logged in: 0
Memory usage: 14% IP address for eth0: 172.26.5.220
Swap usage: 0%
ubuntu@ip-172-26-5-220:~$
Now you are up and running!
But wait there is more… if you are a little more advanced and want API/CLI controls, continue below.
First, install awscli (youll need python-pip3 installed).
➜ .ssh pip3 install awscli --user
Collecting awscli
Downloading awscli-1.18.99-py2.py3-none-any.whl (3.2 MB)
|████████████████████████████████| 3.2 MB 979 kB/s
Collecting colorama<0.4.4,>=0.2.5; python_version != "3.4"
Downloading colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Collecting s3transfer<0.4.0,>=0.3.0
Downloading s3transfer-0.3.3-py2.py3-none-any.whl (69 kB)
|████████████████████████████████| 69 kB 9.9 MB/s
Collecting botocore==1.17.22
Downloading botocore-1.17.22-py2.py3-none-any.whl (6.3 MB)
|████████████████████████████████| 6.3 MB 18.0 MB/s
Collecting docutils<0.16,>=0.10
Downloading docutils-0.15.2-py3-none-any.whl (547 kB)
|████████████████████████████████| 547 kB 24.4 MB/s
Requirement already satisfied: PyYAML<5.4,>=3.10; python_version != "3.4" in /usr/lib/python3/dist-packages (from awscli) (5.3.1)
Collecting rsa<=4.5.0,>=3.1.2; python_version != "3.4"
Downloading rsa-4.5-py2.py3-none-any.whl (36 kB)
Requirement already satisfied: urllib3<1.26,>=1.20; python_version != "3.4" in /usr/lib/python3/dist-packages (from botocore==1.17.22->awscli) (1.25.8)
Collecting jmespath<1.0.0,>=0.7.1
Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/lib/python3/dist-packages (from botocore==1.17.22->awscli) (2.7.3)
Requirement already satisfied: pyasn1>=0.1.3 in /usr/lib/python3/dist-packages (from rsa<=4.5.0,>=3.1.2; python_version != "3.4"->awscli) (0.4.2)
Installing collected packages: colorama, docutils, jmespath, botocore, s3transfer, rsa, awscli
Successfully installed awscli-1.18.99 botocore-1.17.22 colorama-0.4.3 docutils-0.15.2 jmespath-0.10.0 rsa-4.5 s3transfer-0.3.3
➜ .ssh
After it is installed, give it a test, type aws
➜ .ssh aws
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: command
Great! Now lets setup api keys- https://console.aws.amazon.com -> IAM -> Users -> Access Keys -> Generate (unless you already have them)
AFter you have your API key, aws configure
➜ .ssh aws configure
AWS Access Key ID [None]: abc123
AWS Secret Access Key [None]: zyx987
Default region name [None]:
Default output format [None]:
Then give it a test:
➜ .ssh aws lightsail get-instance --instance-name Ubuntu-1
{
"instance": {
"name": "Ubuntu-1",
"arn": "arn:aws:lightsail:ap-southeast-1:12345",
"supportCode": "123456",
"createdAt": 123456,
"location": {
"availabilityZone": "ap-southeast-1a",
"regionName": "ap-southeast-1"
},
"resourceType": "Instance",
"tags": [],
"blueprintId": "ubuntu_18_04",
"blueprintName": "Ubuntu",
"bundleId": "micro_2_0",
"isStaticIp": true,
"privateIpAddress": "172.26.5.220",
"publicIpAddress": "99.99.99.260",
.....and on it goes....
Great success! This is an extremely powerful tool. More information can be found on the AWS site - https://docs.aws.amazon.com/cli/latest/reference/lightsail/index.html
947 Words
2020-07-12 01:20 +0000