Ethereum – Go-Ethereum and AWS – Part 1

September 13, 2018

Author: Michael Gord

Tutorial - MLG Blockchain

Often in a blockchain development cycle you will need to put your blockchain on the cloud to enable other nodes to attach to it for testing and development, or for other miners to mine for proof of work blockchain. The two most popular cloud providers for a blockchain solution are Amazon Web Services (AWS) and Microsoft Azure. Both have the option to start with a free trial and to only pay based on your usage.

This is a three part blockchain development tutorial series on Ethereum that will focus on how to launch your own Ethereum blockchain using Geth on an AWS server, then connect it to another node to start mining or interact with the same smart contracts. This first tutorial will explain how to first configure and connect to your Amazon Virtual Machine. The second section will explain how to install and configure your Ethereum blockchain using Geth on Ubuntu. The third section will walk through how to connect a second node to your cloud instance of Ethereum. We will follow-up with more tutorials that explain how to launch a blockchain instance on other cloud providers such as Azure and Digital Ocean.

If you would prefer to learn how to setup a private Ethereum blockchain locally you can check out our Ethereum development tutorial on how to setup an Ethereum blockchain using Geth in your terminal. You can also find other Ethereum blockchain tutorials at mlgblockchain.com/ethereum-tutorials.html.

Setup Amazon EC2 Instance

To begin you need to sign-up to AWS console and launch at least two EC2 Ubuntu 16.04 servers. You can launch your two EC2 Ubuntu Servers by going to the AWS website and then in the menu you go to the products tab, then to compute and then click on EC2. On the name page click on get started with Amazon EC2 and then register and verify an email. If you have already setup EC2 servers you can continue to the next section.

Once you have registered, sign into your Amazon console. In the navigation bar, hover over services and then click on EC2 which will bring you to the screen below. As you can see, this MLG Blockchain account is currently running 2 EC2 instances, with 2 volumes, 1 key pair and 3 security groups. Before you have any account activity your numbers should all be at 0. Look for the second section called “Create Instance” and click the button “Launch Instance”.Connect Ethereum on AWS

You can also click on the tab on the left called “Instances” which should bring you to the screen below that shows all the servers that are running on your account. From here you can click on the blue “Launch Instance” button on the top left, which will bring you to the same screen as clicking the button on the previous screen. This Instance menu shows you the name of each instance you are currently running, the unique identifier, the type, the zone the instance is running (you can run your cloud servers from anywhere), the state, whether it is working, any problems, and then a last field called public DNS which I have left out of this picture to avoid anyone trying to attach to either instance.

Connect Ethereum on AWS

After you click on “Launch Instance” it will bring you to the screen below, to choose a Amazon Machine Image (AMI). To follow along with this Ethereum tutorial click on the fourth option to setup a Ubuntu Server 16.04 LTS server, though you should be able to setup an Ethereum blockchain with Geth on any of the servers shown here.

Connect Ethereum on AWS

After you select your AMI you will need to select your instance type. We chose a medium server to have more memory and not crash during testing or development, but you can choose any size depending on your expected usage.

Connect Ethereum on AWS

You can continue past the next screen to configure your instance details as you don’t need to make any changes. The next step is to review all the details you submitted to ensure that they are all correct. You can either check the box to delete on termination or not. If it is checked it means that if you delete a EC2 instance, it will also delete the data on it. We recommend this option to avoid storing extra data in the cloud. Once you have completed all your configuration you need to add in tags, such as the name of the instance. You can name your instance whatever you want. As shown above, the first MLG node is called mlg-ethchain and the second is called mlg-node2.

Setup Security Groups

Setting up a security group on a Amazon EC2 instance is done to let the server know which ports to accept inbound or outbound data from. First you need to name your security group and include a description, or you can use an existing security group if you have already set one up. To follow along with the tutorial, we have shown which inbound ports we open. The first SSH type is the default one. The other two are to listen to the Geth network will will be setting up in the second part of this tutorial series. Afterwards, click on confirm and launch and then congratulations you have configured your first Instance on AWS!

Connect Ethereum on AWS

Setup Key Pair

As you launch your EC2 instance, you will see an alert show up to either select an existing key pair or to create a new key pair. Setting up your key pair is to enable you to securely SSH into your instance, while ensuring that others cannot. As shown in the image, your key pair consists of a public key which AWS stores and a private key which you store on your computer. Make sure that you have checked the box to acknowledge that you have access to the selected private key file and then click on choose a new key pair and then click on “Launch Instances”.

Connect Ethereum on AWS

Now that you have completed activating your cloud server and you have downloaded your key pair you should be shown a screen to confirm your Instance has been setup properly and an ID for your Instance. If you click on the ID it will bring you back to your instances section shown above and display your new instance loading. It might take a few minutes to complete loading, but be patient as you need it to complete for it to return the public IP that enables you to connect to your cloud instance. Once if is completed loading and it has returned your public IP you are able to SSH into your EC2 from your terminal, using the key pair that you just created.

SSH into your EC2 Instance

From your terminal, change directory to the folder that has the key pair you just downloaded and input the command below. This command should take some time to respond and when it does it will return your ECDSA key fingerprint and ask if you want to continue connecting. Type yes, then click enter, and your terminal will respond that you have permanently added your public IP to the list of known hosts, which will give you command line access to your machine. If it is configured properly, you should see a success message returned afterwards.

ssh -i .pem ubuntu@Connect Ethereum on AWS

From here you can see your working directory you can connect your Ethereum blockchain to. Below, you can see the contents of our Ubuntu server. We will explain how to install Geth and configure your blockchain in the next section of this tutorial.

Connect Ethereum on AWS


About MLG Blockchain

MLG Blockchain is a blockchain development and consulting firm based in Toronto that is focused on building next generation applications using blockchain and smart contract technology. View all our blockchain development tutorials at www.mlgblockchain.com/learn.html.