An Introduction To The AWS Command Line Tool - Linux
An Introduction To The AWS Command Line Tool - Linux
search linux.com
Home Learn Linux Linux Tutorials An Introduction to the AWS Command Line
Tool
Amazon Web Services has an extremely functional and easy to use web console called
the AWS Management Console. It’s brilliant for performing complex tasks on your AWS infrastructure,
although as a Linux sysadmin, you may want something more "console" friendly.
In early September 2013, Amazon released version 1.0 of awscli, a powerful command line interface which
can be used to manage AWS services.
1 di 5 13/02/2014 13.50
An Introduction to the AWS Command Line Tool | Linux.com http://www.linux.com/learn/tutorials/761430-an-introduction-to-the-aws...
$ aws configure
Tweets
It’s up to you which region you’d like to use, although keep in mind that generally the closer the region to
your internet connection the less latency you will experience. JoR
Le q
The regions are: @re
kicks
ap-northeast-1 falta
ap-southeast-1 en #
ap-southeast-2 Show
eu-west-1
sa-east-1 telec
us-east-1 Com
us-west-1 cosa
us-west-2
Linu
telec
For now, choose table as the Default output format. table provides pretty output which is very easy to
read and understand, especially if you’re just getting started with AWS.
Jack
The json format is best suited to handling the output of awscli programmatically with tools like jq.
Libre
The text format works well with traditional Unix tools such as grep, sed and awk.
d
If you’re behind a proxy, awscli understands the HTTP_PROXY and HTTPS_PROXY environment variables. Compose new
First Steps
So moving on, let’s perform our first connection to AWS.
A table should be produced showing the Endpoint and RegionName fields of the AWS regions that
support Ec2.
The output from describe-availability-zones should be that of the AWS Availability Zones for our
configured region.
awscli understands that we may not just want to stick to a single region.
Latest Tutorials
$ aws ec2 describe-availability-zones --region us-west-2
An Introduction to
By passing the —region argument, we change the region that awscli queries from the default we have
Setting Up An AP
configured with the aws configure command.
Debian Wheezy
Provisioning an Ec2 Instance
Converting Files f
Let’s go ahead and start building our first Ec2 server using awscli. dos2unix
Ec2 servers allow the administrator to import a SSH key. As there is no physical console that we can attach Install Fedora on
to for Ec2, SSH is the only default option we have for accessing a server. With Grunt
The public SSH key is stored within AWS. You are free to allow AWS to generate the public and private keys How to Watch Fre
or generate the keys yourself.
2 di 5 13/02/2014 13.50
An Introduction to the AWS Command Line Tool | Linux.com http://www.linux.com/learn/tutorials/761430-an-introduction-to-the-aws...
The —public-key-material option takes the actual public key, not the path to the public key. Country
Let’s create a new Security Group and open up port 22/tcp to our workstation's external IP address.
Security Groups act as firewalls that we can configure to control inbound and outbound traffic to our
Ec2 instance.
$ curl ifconfig.me
198.51.100.100 Latest Software
Now we know the external IP address of our workstation, we can go ahead and create the Security Group Ubuntu Shows Of
We need to know the Amazon Machine Image (AMI) ID for the Linux Ec2 machine we are going to
provision. If you already have an image-id then you can skip the next command.
AMI IDs for images differ between regions. We can use describe-images to determine the AMI ID for
Amazon Linux AMI 2013.09.2 which was released on 2013-12-12.
The name for this AMI is amzn-ami-pv-2013.09.2.x86_64-ebs with the owner being amazon.
We’ve combined —owners and applied the name filter which produces some important details on the AMI.
What we’re interested in finding is the value for ImageId. If you are connected to the ap-southeast-2 region,
that value is ami-5ba83761.
run-instances creates 1 or more Ec2 instances and should output a lot of data.
InstanceId: This is the Ec2 instance id which we will use to reference this newly provisioned machine
with all future awscli commands.
3 di 5 13/02/2014 13.50
An Introduction to the AWS Command Line Tool | Linux.com http://www.linux.com/learn/tutorials/761430-an-introduction-to-the-aws...
InstanceType: The type of the instance represents the set combination of CPU, memory, storage and
networking capacity that this Ec2 instance has. t1.micro is the smallest instance type available and for
new AWS customers is within the AWS Free Usage Tier.
PublicDnsName: The DNS record that is automatically created by AWS when we provisioned a new
server. This DNS record resolves to the external IP address which is found under PublicIpAddress.
GroupId under SecurityGroups: the AWS Security Group that the Ec2 instance is associated with.
Within a few seconds, the Ec2 instance will be provisioned and you should be able to SSH as the
user ec2-user. From the output of describe-instances, the value of PublicDnsName is the external
hostname for the Ec2 instance which we can use for SSH. Once your SSH connection has been established,
you can use sudo to become root.
A useful awscli feature is get-console-output which allows us to view the Linux console of an instance
shortly after the instance boots. You will have to pipe the output of get-console-output into sed to correct
line feeds and carriage returns.
Rene Cunningham
Comments
Cool !!
4 di 5 13/02/2014 13.50
An Introduction to the AWS Command Line Tool | Linux.com http://www.linux.com/learn/tutorials/761430-an-introduction-to-the-aws...
really useful !!
Good blog! I have found here much useful information for yourself and would like to
thank you for done by work.
Name :
Email :
Comment :
Subscribe to Comments
5 di 5 13/02/2014 13.50