Skip to content

Using AWS for Infrastructure

Links:

Terminology

  • IaC: Infrastructure as Code

What is AWS?

Amazon Web Services (AWS) is a public cloud infrastructre provider. Among others (Google Cloud Platform, Azure), these cloud providers enable developers to set up servers that they can use to run their software without having to purchase and set up everything themselves.

One of their most popular services is the Elastic Compute Cloud (EC2), which can be used to establish servers however one desires. However, there are many, many other services offered by AWS. Regardless of the service, one of the key features is elasticity; that is, the ability to scale up or down your instances depending on the workload of you require.

While using cloud providers like AWS to host your infrastructure is in fashion these days, there is an ever-present debate about just how much money is saved in the long run, and whether setting up in-house servers still has advantages. For an interesting discussion see Use One Big Server.

Deploy a Virtual Server

After signing into the AWS console, head over to EC2.

  1. On the left-hand panel select Network & Security > Key Pairs, then in the top-right select Create key pair
    • Creating a key pair will enable you to access you server via SSH
    • After creating the pair a private key file will be downloaded with extension .pem, move that file to you ~/.ssh folder and revoke read and write permissions from the group and other levels.
  2. On the left-hand panel select Instances > Instances, then in the top-right select Launch instances.
    • Add a Name
    • Select your server Image (e.g. Ubuntu)
    • Select your instance type (e.g. t2.micro)
    • Select your key pair
    • Create a security group with SSH traffic permitted. A security group is a firewall that restricts inbound and outbound connections to your server. In production, take care to put more restrictions on your network traffic.
    • Launch your instance.
  3. In the Instances view, once your instance state is Running, select the checkbox next to the instance and the select Connect in the top-right.
    • In the SSH client tab, you can find instructions for tunneling into your instance through SSH, the command should be something like
    sh
    ssh -i <pem_file> ubuntu@<instance_uri>
    ssh -i <pem_file> ubuntu@<instance_uri>

Cleaning the Virtual Server

Unless you clean up the server, it will remain running and cost you money. To clean up your instance, on the left-hand panel go to Instances, select the checkbox beside you instance, in the top-right select Instance state > Terminate instance.

Deploy a Kubernetes Cluster (needs clean up)

To deploy a Kubernetes Cluster, you can use the Elastic Kubernetes Service (EKS).

  1. Set up the role for the Kubernetes control plane
    1. Go to IAM and create a new role, make it an AWS Service and select EKS as the Use Case and EKS - Cluster
    2. Go to IAM and create a new role, make it an AWS Service and select EC2 as the Use Case and EKS - Cluster. Attach the policies you need

Rancher is like EKS but isn't owned and operated by AWS, consder taking the time to learn Rancher too as it's a great tool to ochestrate Kubernetes clusters. 2. Go to EKS. Select Add cluster > Create 3. Once the cluster is active, go to the Compute tab and click Add node group.

- Give it a name
- Make is Amazon Linux 2
- Instance type t3.small
- This process creates the worker nodes (e.g. virtual servers) that actually run your containers.

Deploy Apps into a Kubernetes Cluster

.. skipped this section