When I’m writing this tutorial I’m using macOS Sierra but everything should work correctly also on previous versions of macOS like El Capitan, Yosemite, Mavericks and so on.

This tutorial describes how to use the console to manage your cloud. I think it’s clearer and easier way than their website interface.

Let’s start. I assume that you’ve heard something about Amazon’s cloud. If not let me introduce you in the first chapter, everyone else can go directly to next chapters.

[toc]

What is Amazon’s Cloud?

We call it AWS, it’s shortcut from Amazon Web Services. At the beginning of Amazon there was just an online shop like thousand others. However, they grew up to spectacular size acting in many countries in the world. Working in this scale (from our – IT side of course) requires a lot of servers working together. Amazon engineers had to develop something that allows them to manage their server farms which are located around the world. Everything that they involved had to be easy, cheap and scalable. They did it and we are looking at it when we are using AWS.

Pre-requirements

  1. An account on Amazon.
  2. A user with access key ID and secret access key (instruction bellow).
  3. Installed brew.

Create access key ID and secret access key

I hope that you don’t need details how to create an account on Amazon website, so let’s go directly to creating a user with programmatic access.

  1. Login to your account on aws.amazon.com.
  2. On dashboard choose “IAM” in section “Security, Identity & Compliance”.
  3. Look at the left sidebar, there you have option “Users”, follow it.
  4. Click blue button “Add user”.
  5. Fill in the form, remember to mark options Programmatic access.
  6. Now you have to assign the user to some group or attach to it some polices. Other words, you are defining what user can do on Amazon Cloud. At this moment you can just add created user to the group ec2_admin which allows you to do most everything.
  7. Go to next step (review) and again click blue button, this time called “Create user”.
  8. You should see a table with created user, there are columns Access key ID and Secret access key.
  9. Copy your keys or download CSV file which contains that data.

Install pip

Amazon provides two powerful tools which you can use to manage your cloud directly from command line. A both of them are written in python and pip is nothing more than packet manager for python which allows us to install these tools.

Probably you should have installed it, you can check it using a command line, just type:

pip --version

If get something like bellow then you can go to next step, if not, stay a little bit longer in this chapter.

pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)

Ok, you don’t see anything that could look like message above. We know that you haven’t pip, so let’s install it! Don’t close the command line and type that line:

brew install python

brew with python will try to install pip as a default packets manager after it, try again run the command:

pip --version

Install aws

Everything that you have to do is to type that four words in your terminal. It will install this tool to use only by your user on your mac, so you don’t need to grant root permissions using sudo.

pip install awscli --user

If everything has gone ok then you could have run that command to see the version which you installed.

~/Library/Python/2.7/bin/aws --version

Install eb

The command to install tool to manage Elastic Beanstalk is also really easy:

~/Library/Python/2.7/bin/aws --version

And again, let’s check the version.

~/Library/Python/2.7/bin/eb --version

Create the first project on Amazon behind load balancer

First, what you need to do is to create an empty folder and go there, you can do that:

mkdir amazon_project && cd amazon_project

After that, you have to type only one command

~/Library/Python/2.7/bin/eb init

You can see some easy form, which asks you a few question to prepare everything.

Select a default region

Amazon has datacenter around the world, so choose the prime where you want to work. Definitely, servers at the US are cheaper than others, so for the test, you can choose Oregon.

3) us-west-2 : US West (Oregon)

Access key

Because you run first time that command you have to fill in next questions using yours Access key ID and Secret access key which you created few steps earlier.

You have not yet set up your credentials or your credentials are incorrect
You must provide your credentials.

As a first step you have to provide your Access key ID and after that Secret access key.

Application name

You are creating your first project on Elastic Beanstalk you have to figure out some names, it could be hello world.

Oh no, “Elastic Beanstalk could not find any platforms”

You’ve just typed the name of your new application, and see you it as an error like in header? Don’t worry, you have to come back to Amazon website, to section “IAM”, then to “Users” find your new created user and click blue button “Add permissions”. There click on “Attach existing policies directly” and in search form paste it: AWSElasticBeanstalkFullAccess. You should find out one result, check it and click blue button “Next: Review” and then another blue button “Add permissions”.

What exactly did you do? You give your user privileges to manage service Elastic Beanstalk. So, go on!

Type again that commend:

~/Library/Python/2.7/bin/eb init

Choose region like previously and type a name your new application.

Select a platform.

Amazon has predefined few systems, some specialized and two general (docker, Multi-container Docker). We can start with docker, so type a number which is on the left of the docker name.

Select a platform version.

Don’t ask, just choose the first option. On the first place there is always the newest version of the platform, you don’t need an older version, right?

Do you want to set up SSH for your instances?

Yes! Unless you don’t want to have access to your new instance from your command line, then ignore, but I don’t recommend it.

Select a keypair.

Security is so important on Amazon, so you need to create some keys which will be used to get connected to your instance. Chose options [ Create new KeyPair ].

Type a keypair name.

Click enter, at this moment, the default name will be enough.

Enter passphrase

If stronger password then it will be harder to crack it, so don’t save your keyboard.

Enter same passphrase again:

Repeat your password, please.

Enter passphrase:

And again repeat your password.

You are ready

It’s everything. Your Amazon account has been set up the same as your first application on Elastic Beanstalk. In some next post, I will describe how you can use it. Stay tuned!


Avaiable datacenters (regions)

IdCodeRegionCity
1us-east-1US EastN. Virginia
2us-west-1US WestN. California
3us-west-2US WestOregon
4eu-west-1EUIreland/Dublin
5eu-central-1EUFrankfurt
6ap-south-1Asia PacificMumbai
7ap-southeast-1Asia PacificSingapore
8ap-southeast-2Asia PacificSydney
9ap-northeast-1Asia PacificTokyo
10ap-northeast-2Asia PacificSeoul
11sa-east-1South AmericaSao Paulo
12cn-north-1ChinaBeijing
13us-east-2US EastOhio
14ca-central-1CanadaCentral
15eu-west-2EULondon