FANDOM


This page describe how to use the Amazon Web Services virtual servers (EC2) conveniently from the command line interface.

Configure Command Line Interface (CLI) Edit

Launch instance Edit

Following the instructions of amazon's page.

sudo pip install awscli
Test the installation with
aws test
Beware that aws command autocompletion is not available by default. One has to add
complete -C '/usr/local/bin/aws_completer' aws
to the .bashrc file to enable autocompletion.

Then, follow the first step of this page to set up your credentials.

Request a spot instance (here). Check the state of your request with

aws ec2 describe-spot-instance-requests

Once it displays the message : "Your Spot request is fulfilled." you can connect to it with the InstanceId.

Follow this page from step 2.

Connect to an instance Edit

Now that you have set up everything and retrieve the instance ip you can connect to it with a key pair, created with the following command.

 
aws ec2 create-key-pair --key-name your_key_name --query 'KeyMaterial' --output text > your_key_name.pem

Set the right access: chmod 400 your_key_name.pem

Connect with:
 ssh -i your_key_name.pem ubuntu@your_instance_ip

The "Permission denied (publickey)." problem Edit

If you get this message when connecting to your instance, it means you have to:

  • check you have the right access to your key: chmod 400 your_key_name.pem

Terminate instance Edit

To kill an instance after usage (from there)
aws ec2 terminate-instances --instance-ids "your_instance_id"

Get your instance id with, for instance

aws ec2 describe-instances |grep InstanceId|sed 's/ *"InstanceId": "\(.*\)",/\1/'


==

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.