This is where it all starts!
In this post we will go through the very basics of launching an EC2 instance in Amazon Web Services (AWS). We will go over these following steps:
- Launching an instance (with private-public keys)
- Connecting to the server instance (with ssh)
Launching an instance
On the Dashboard, click the blue button “Launch Instance”. Notice the Note below the button, which says the instance will be launched in your default region, which is displayed on the upper right corner of the dashboard – Oregon (not included in the screenshot below)
Then, follow the steps that best matches your needs.
Step 1 – Let’s use the Amazon Linux AMI (which is Free tier eligible)
Step 2 – type – we will select the t2.micro Type.
Step 3 – instance details – we will use all the default configurations details.
Step 4 – storage – we will use the pre-configured Root storage.
Step 5 – tags – lets add a few –
- Key – Name, Value – Demo
- Key – Creator, Value – JohnD
Step 6 – security groups – for a start, let’s have one connection types – SSH which will be reachable only from our IP (Select ‘My IP’ in the ‘Source’ column). We will name this security group devops-notes-demo. Later on, we will play more with this section.
Step 7 – review your instance details, and click Launch when you are satisfied.
Creating a new key-pair
For security reasons, we want to use a private-public key connection, so ssh connection will be available only with the private key. From the dropdown list, select Create a new key pair, and give it a name:
After downloading the .pem file (which is the private key), launch the instance. Initializing it will take a few moments. You can view the progress in the Instances dashboard.
Once we have two greens (Instance State and Status Checks), we are ready to ssh to our instance.
Connecting to the server instance
When selecting our new server in the AWS Dashboard, we can see the Description tab. Let’s grab the Public DNS, and use that to connect to our server:
$ # ssh -i <private-key> <user>@<public-dns> $ ssh -i devops-notes-keypair.pem firstname.lastname@example.org The authenticity of host 'ec2-35-160-196-44.us-west-2.compute.amazonaws.com (126.96.36.199)' can't be established. RSA key fingerprint is 87:67:a7:38:1b:51:5c:b3:b6:e7:72:ab:6d:f7:96:4b. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'ec2-35-160-196-44.us-west-2.compute.amazonaws.com,188.8.131.52' (RSA) to the list of known hosts. __| __|_ ) _| ( / Amazon Linux AMI ___|\___|___| https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/ 3 package(s) needed for security, out of 10 available Run "sudo yum update" to apply all updates. [ec2-user@ip-172-31-40-124 ~]$
And that’s it! Well, for having a server in hand from AWS.
[TBD – link to git ] Browse code in github to see how to do all the above with aws-sdk and ruby