The following tutorial will cover step by step process of how you can install Hyperledger Fabric on AWS.

Whether you are building an application of Hyperledger Fabric, training others to develop using Hyperledger Fabric, or even testing an application built on Hyperledger Fabric, hosting the application or running it on a cloud platform is always needed. Hosting an application is a critical part of the development environment.

When it gets to running or hosting a Hyperledger Fabric instance, the task can be very intimidating. For instance, knowing which image of Hyperledger Fabric to run or how to configure the network.

This is where cloud providers come to the rescue.

Blockchain as a Service providers such as AWS blockchain provide a template for users to host their Hyperledger Fabric application in a friendly way. In essence, the cloud provider will allow you to run a host and install all the required components of Hyperledger Fabric on it.

In the following sections, we will install a Hyperledger Fabric network on AWS EC2.

Amazon EC2 or Amazon Elastic Compute Cloud provides a simple and intuitive user interface for setting up a cloud environment. It provides great control over the cloud-based services and is popular among the Hyperledger Fabric developers as their choice of cloud platform.

Before starting, make sure you have an AWS account.

AWS offers free services for one year in which each user gets 750 hours of Linux and Windows t2.micro instances per month. Usually, the free tier of AWS is sufficient for a normal user running a Hyperledger Fabric network. In case you require more computing power than available in the free tier, you can choose from the various plans available here.

Enroll Now: Getting Started With Hyperledger Fabric Course

Setting Up the Environment

After logging in to your AWS account, select the AWS blockchain template EC2 console by choosing EC2 under Compute tab as displayed in the image.

setting up the environemnt

Image Source: aws.amazon.com

In the next step, AWS displays a list of Amazon Machine Images which allow you to run a specific host.

Select Ubuntu Server 18.04 LTS. 

After this, you have to select an instance. The smallest instance that will be able to support your Hyperledger Fabric Network easily is t2.small.

Other options do not require attention to detail and can be left as defaults. You can click next and accept the default options until you reach the security group page. Security group allows you to configure the traffic rules for your instance. You can either create a new group or select a group if you have created it before.

This is the last step before you can launch your EC2 instance. You can click on the Review button to make sure everything is correct and Launch the instance.

Selecting a Key Pair

A dialogue box will appear asking you to use an existing key pair or create a new one. You can create a new key pair and enter the same for the key pair. After then, you have to download the key pair and store it in a secured location.

selecting key pair

Image Source: aws.amazon.com

We will use this key for establishing an SSH connection to the host.

Amazon QLDB is another option for you to host your blockchain projects. Here’s a comprehensive guide to Amazon QLDB that you need to check out.

Installing Prerequisites

Hyperledger Fabric 2.0 components require certain software to run. For instance, if you want to develop the chaincode, you need to have GO language installed on your machine. Therefore, for Hyperledger Fabric, the following list of components needs to be installed.

  • Curl
  • Docker
  • Docker Compose
  • GO programming language
  • NodeJS
  • NPM
  • Python

You can use your public IP to access the instance and make sure that the connection is made. Mentioned below is the SSH command for connecting to the node. It requires your specific key and public IP.

ssh -i ubuntu@ <public_ip>   

Running this command will show a welcome to Ubuntu message on success.

Before moving forward with the installation of Hyperledger Fabric Network, make sure you have all the packages up to date. This is a good practice as older version of packages may hinder the installation or working of the Hyperledger Fabric network.

For this, you can run the following command:

 Sudo apt-get update 

For installing curl:

 sudo apt install curl 

To install docker and docker compose:

 sudo apt-get -y install docker-compose 

This command will download both the packages.

To check if the right version of docker has been installed on your instance, you can run the following commands

 docker -v
 docker-compose -v 

Note: exit the host and login again to check docker installation

Next is installing the GO programming language:

 wget https://golang.org/dl/go1.11.11.linux-amd64.tar.gz
 sudo tar -xvf go1.11.11.linux-amd64.tar.gz

The first command gets the compressed package and the second command extracts the files from that package.

This installs GO on your machine. However, you will be unable to use GO in your Hyperledger Fabric network unless you set the GOPATH environment variable which allows it to be used by every application on every login. For this, open the “. bashrc” file and add the following two lines at the end of that file:

 export GOPATH=$HOME/go
 export PATH=$PATH:$GOPATH/bin

Installing NodeJS and NPM needs to be done carefully as the latest version of NodeJS is not required but version 8.x should be installed.

For this, run the following commands:

 curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - 
 sudo apt install nodejs 

You can confirm the installed version of NodeJS and NPM by running:

 node -v
 npm -v

Last step before installing the Hyperledger Fabric network on AWS blockchain is installing Python. Ubuntu 18.02 comes with proper installation of python 2.7 so this is not required to be installed exclusively. You can check the installed version of Python with: python –version or python -V

Understand the differences between blockchain solution providers with AWS vs AZURE vs Oracle blockchain comparison guide now!

Installing Hyperledger Fabric Components

Now that you are familiar with AWS blockchain template for Hyperledger Fabric let’s move on to the next step. There are three components of Hyperledger Fabric in particular that we need to install:

  • The Hyperledger Fabric components we are going to install are
  • Hyperledger Fabric software docker images
  • Hyperledger Fabric binary tools

More information about Fabric components and installation can be found on the official documentation. You can also check out Hyperledger Fabric tutorial to understand the components.

To download the latest production release, run the following command:

 curl -sSL http://bit.ly/2ysbOFE | bash -s 

For installing a specific version of Hyperledger Fabric, the sample command is:

 curl -sSL http://bit.ly/2ysbOFE | bash -s -- 1.4.12 1.4.9 0.4.22 

There are three versions here

 <fabric_version> 
 <fabric-ca_version>  
 <thirdparty_version>

Note: if your curl command gives an error, one possible explanation can be that your curl command is not updated.

The aforementioned command executes a bash script and downloads all the Fabric files such as cryptogen, fabric-ca-client, fabric-ca-server, and more.

This command also downloads the fabric samples directory.

To confirm the successful installation of Fabric components, you can check the availability of fabric-samples directory and binary blockchain tools of Hyperledger Fabric present in the “bin” folder inside this directory.

Let’s Test It Out

The most appropriate test for confirming the installation of Hyperledger Fabric on your AWS EC2 instance is to run the basic scripts.

You can run the “Bring Your First Network” or BYFN script to create a simple Fabric network with these commands:

 cd fabric-samples/first-network 
 ./byfn.sh up 

On successful execution, a big START is displayed on the screen indicating that the network has started, followed by a big END confirming that all components have been installed. In between, this script tests out all the essential components of Hyperledger Fabric. This is how you install Hyperledger Fabric on AWS.

Conclusion

Now that you know how to install Hyperledger Fabric on AWS, you are ready to start working on your blockchain project. But before you can move forward, you need to have a good understanding of how Hyperledger Fabric works and how you can utilize the components more efficiently. Without this knowledge, you won’t be able to use this platform to develop your blockchain solutions. If you want to understand the underlying mechanism of Hyperledger Fabric, we recommend starting with our Hyperledger Fabric development course.