Set up a free server on AWS in 30 minutes

I should have learned about AWS a while ago, but I completely forgot it because of my poor memory.

I wanted to have my own Linux server on the internet, so I tried to use AWS, but I can hardly remember anything. I will write an article after reviewing from scratch to setting up a server.

Although AWS has a one-year free tier from user registration, a credit card number is required for user registration. This is done.

First of all

When you log in from the top site, the screen changes and you are taken to the "AWS Management Console". This is the entrance to another world. The initial equipment that you can get for free is quite luxurious, and if you have a small server, you can use it for free. Look for the menu in the management console and check "Billing", "VPC" and "EC2". These three are the main places of activity.

Billing

Where to know the billing status.

First of all, if you don't know this, you can't use it with confidence. The amount of "how much did it cost this month" is displayed here. If you are using it in the free tier, it should be displayed as $ 0.

VPC dashboard

"Creating a VPC" is like "securing a server room and improving the environment" in the real world.

Click VPC to enter the VPC Dashboard.

Creating a VPC

Clicking on the VPC link will take you to the screen for creating a VPC. There is a "default VPC" from the beginning, but you shouldn't turn it off. It will be more troublesome.

Create a new VPC. Press "Create VPC" to start creating. The IPv4 CIDR block is 10.0.0.0/16. You will be able to use the address 10.0.xx.xx. Since IPv6 is not used, select None for IPv6 CIDR block. I want to use the free tier, so I choose the default for "Tenancy". The name will be referred to later, so it's a good idea to give it a descriptive name.

In real terms, this means "taking a server room."

Create subnet

Click the "Subnet" link to move to the screen for creating a subnet. Press "Create Subnet" to start creating. Select the VPC you created earlier. Select the Availability Zone from the Tokyo region, such as ap-northeast-1a. Choosing an overseas one will only slow you down. The "IPv4 CIDR block" is 10.0.1.0/24. Now you can use the address 10.0.1.xx in the subnet.

This completes "Wiring the Ethernet in the server room".

Check the route table

Click the link "Route table" to move to the route table setting screen. When you created the VPC, the route table was also created as a set. There is also a route table for the default VPC from the beginning, but don't delete it either. If you click on the tab labeled "Root", the destination should be 10.0.0.0/16 and the target should be local. No change required. You can name it in the tab called "Tags", so it's best to do it.

This completes the "router installation".

Creating an internet gateway

Click the link "Internet Gateway" to move to the creation screen. It corresponds to connecting the router and the external net. You can create it by pressing "Create Internet Gateway". As usual, it's better to give it a name. Select "Attach to VPC" from "Action" to connect to the VPC you are currently creating.

Route table settings (2)

You can edit the route table by pressing the "Route" tab. Press Edit Route to add the route for the VPC you're currently creating. Associate 0.0.0.0/0 with ʻinternet gateway`. Now the inside of the VPC will be routed internally, and the rest will be sent to the Internet.

You can now connect to the Internet. Construction of the server room is complete.

EC2

"Starting EC2" is actually equivalent to "buying a computer, installing it in the server room, and starting it."

EC2 dashboard

Go to the "EC2 Dashboard". Click "Instance" and press "Create Instance" to display the screen for selecting an instance (corresponding to a virtual computer). ʻSelect Amazon Linux 2 AMI (HVM), SSD Volume Type`. Next, select the free tier t2-micro.

Select the VPC you just created for "Network" and the subnet you just created for "Subnet". "Auto-assign public IP" is disabled by default, but it is enabled. Select the next "Add Storage" to proceed, but no additional storage is required.

When you create and start it, the key pair creation dialog will appear, so create it and download it. This file is the RSA key and you will need it to log in to this computer.

When you display the screen that displays the list of instances, you can see the computer that has just started. The IPv4 public IP address is also displayed. The computer with this IP address is already on the Internet. You can connect with SSH etc.

Security group

The created EC2 instance can only be SSH as it is. This is because the security group is closing protocols / ports other than SSH. If you want to ping the server to check for it or use it as an http server, change the security group settings.

When I view the server instance from the EC2 dashboard instance, I see a "security group" in the detailed description. You can find out the ID of the security group by pressing the link of the applied security group. Change (add) the security group for this ID from the Security Groups screen in your VPC dashboard.

Purpose type protocol Port range Source
Allow SSH (default) SSH TCP 22 0.0.0.0/0
Ping All ICMP- IPv4 all Not applicable 0.0.0.0/0
Used as an http server (for development) Custom TCP rules TCP 8000 0.0.0.0/0
Use as an http server (deploy) HTTP TCP 80 0.0.0.0/0

Verification

Is there really a server on the Internet with just this? Check with TeraTerm.

Start TeraTerm, enter the IPv4 public IP address mentioned earlier in the connection destination, and connect with SSH2. The user name is ec2-uesr and you don't have to enter anything in the password field. Instead, select "Use RSA key" and select the file you downloaded earlier as your private key.

If you press "Connect", you can see that it is certainly connected.

TeraTerm


Last login: Fri Mar 20 15:18:50 2020

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
7 package(s) needed for security, out of 11 available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-10-0-1-156 ~]$

end

Recommended Posts

Set up a free server on AWS in 30 minutes
Set up a simple HTTPS server in Python 3
Set up a test SMTP server in Python.
Set up a UDP server in C language
Set up a simple SMTP server in Python
Set up a simple local server on your Mac
Set up a file server on Ubuntu 20.04 using Samba
[Part 1] Let's set up a Minecraft server on Linux
Set up a Samba server with Docker
Set up a mail server using Twisted
How to set up a jupyter notebook on ssh destination (AWS EC2)
Set up a local web server in 30 seconds using python 3's http.server
Set up a simple HTTPS server with asyncio
Set up a local server with Go-File upload-
Set up a local server with Go-File download-
How to set up a local development server
Set up a Python development environment on Marvericks
Set up a VPN server on AWS so that you can make a VPN connection from your Linux laptop
Set up a Minecraft resource (Spigot) server via docker (2)
Set up a Minecraft resource (Spigot) server via docker
[Vagrant] Set up a simple API server with python
Set up a file server using samba on ZeroPi of Friendly Arm [OS installation]
I want to set up a mock server for python-flask in seconds using swagger-codegen.
Set up a file server using samba on ZeroPi of Friendly Arm [Purchased Items]
Set up a file server using samba on ZeroPi of Friendly Arm [Personal import]
Set up Python 3.4 on Ubuntu
Set up Polyglot on Windows
Set up Nunjucks in Node.js
Set up a web server with CentOS7 + Anaconda + Django + Apache
Set up a Google Cloud service account key on heroku
Setting up a CentOS 7 server hosted on Alibaba Cloud ECS
[Introduction to AWS] A memorandum of building a web server on AWS
How to set up a simple SMTP server that can be tested locally in Python
Run a Linux server on GCP
Set up Python environment on CentOS
How to deploy a Django app on heroku in just 5 minutes
Set up Ubuntu as a Linux cheat sheet and https server
Run TensorFlow2 on a VPS server
Set up a node to do MNIST on ROS using Tensorflow
Set up a dummy SMTP server in Python and check the operation of sending from Action Mailer
Set up a yum repository server on CentOS7 system and refer to it locally and from other servers.
Send mail with mailx to a dummy SMTP server set up with python.
Set up a server that processes multiple connections at the same time
Build a Pypi cache server on QNAP
Run TensorFlow on a GPU instance on AWS
Build a simple WebDAV server on Linux
Build a Samba server on Arch Linux
Build a web server on your Chromebook
Run Jupyter notebook on a remote server
From nothing on Ubuntu 18.04 to setting up a Deep Learning environment in Tensor
The day when the flask server running on linux on AWS was semi-persistent (running in the background)
Launch a simple password-protected search service in 5 minutes
Periodically run a python program on AWS Lambda
Consider a cloud-native WebSocket application running on AWS
Build a WardPress environment on AWS with pulumi
Run the task in the background on the sshed server
Try Tensorflow with a GPU instance on AWS
Set up golang with goenv on GNU / Linux
A note on optimizing blackbox functions in Python
Build a Django environment with Vagrant in 5 minutes
Set a fixed IP in the Linux environment