Blockchain networks enable businesses to maintain and secure records of all digital transactions across multiple parties without a centralized authority. This can benefit many organizations, but it can also be difficult to implement. Managed blockchain offerings have become a popular way for businesses to use blockchain technology without having to set up and manage their networks independently. AWS cloud-based businesses can use this Amazon Managed Blockchain tutorial to get started with blockchain.
Developers can use Amazon Managed Blockchain to build their own networks based on the open source frameworks Hyperledger Fabric and, eventually, Ethereum. With Hyperledger Fabric, companies can use Java, Go or Node.js to code a chaincode, or smart contract, that contains business logic and executes transactions. Members of a blockchain network communicate through peer nodes, which are instances that have been authorized to send and receive transactions.
In this Amazon Managed Blockchain tutorial, we'll go through the first steps to use the service. First, use the AWS Management Console to create a blockchain network and a member. Then, create and configure an EC2 instance to run the Hyperledger Fabric network. The EC2 instance will be in a VPC on a public subnet with an Elastic IP address. This instance will be the primary node that runs the blockchain network and that other peer nodes can connect to at a later time.
To run a blockchain network on AWS, make sure you install or update Docker, Docker Compose, the AWS Command Line Interface (CLI) and Go.
There are several Hyperledger Fabric demonstration networks developers can clone from GitHub and run as-is. These are great resources to learn how to build and customize your own networks. After getting the network running, use the AWS Management Console to add additional Member AWS accounts. Keep in mind that it is impossible to delete a managed blockchain network as long as there is a member of that network, even if it's one you don't control.
Once added, members can run one or more peer nodes. Each peer node has a complete copy of the ledger, as well as any chaincode on it. When a new transaction is submitted to the blockchain, the peer nodes will vote on the transaction to confirm it. If approved, that transaction will be added to the ledger and distributed to all the peer nodes on the network.
Watch the Amazon Managed Blockchain tutorial above to follow the rest of the required steps to create a blockchain network.
Transcript - Tune into this Amazon Managed Blockchain tutorial for beginners
Hello, today we're going to cover how to create an Amazon Managed Blockchain network. So to start off, I'm here in my AWS console under the Amazon Managed Blockchain page. And we're going to go ahead and create a network. So the two that are available in this service are Hyperledger Fabric and Ethereum. I'm going to go ahead and pick Hyperledger Fabric, because that's what's available right now. I'll call this Techsnips-Demo, and I'll go ahead and click Next.
The member name is the first member in the blockchain network. These are going to be distinct entities or companies or organizations. Let's go ahead and call this first one Member1. And next, we need a Fabric admin username and password. Make sure it's something you remember, otherwise you will have to redo this from scratch.
All right, and while this is being created, let's go ahead and start up an EC2 instance, which we’ll also need for this demo.
Okay, I'm here in my EC2 dashboard. Let's go ahead and launch the instance. And I'll go ahead and pick the AWS Linux 2 AMI. With free tier, I'm not doing anything heavy on this demo, so let's go ahead and configure this. Now, I've done this off screen, but if you want to look into this a little bit more there are several good TechSnips videos and courses on how to do this. I've gone ahead and created several different things for this, including a VPC with one public subnet. And I'll go ahead and click next.
I will select an existing security group, which I've also set up for this demo. And now that I'm okay with that, let's go ahead and launch this. I've gone ahead and set up a key pair for this as well, that I've downloaded off screen. One more thing I want to do here is I've also got an elastic IP address for this instance. So I'll go ahead and attach that now.
All right, my instance is initializing. Let's go back to the blockchain console. This is still provisioning. It is going to take a while, so let's just wait for this to wrap up.
All right, our network is now available. First thing I want to do is copy off the network ID here. We're going to need that in a later step, so don't lose that. Next, I want to make sure I go over here to members. Now we started off with one member, that's Member1. And let's go ahead and copy that member ID; we’ll need that later as well.
All right, going back to my network page. The next thing I want to do is create a VPC endpoint. This is going to be how we end up managing our blockchain network. So to confirm, I'm in my blockchain VPC, where all of my resources are going to go. I'm in my public subnet, and I'm using the security group. This is an open security group, but you can configure your own based on your own needs. Now while this is creating the endpoint, let's go ahead and go to our EC2 instance.
Okay, I'm here in my EC2 dashboard and let's go ahead and take our instance here and copy the public IP address. Now that that's copied, let's go to our terminal. Okay, I'm here in my WSL terminal. And just to confirm we have what we need, let's go ahead and look for our certificate file. Perfect, we've got it there. Now we can SSH into our instance.
Alright, perfect. I'm in my EC2 instance. And the next thing I want to do is just make sure that I have all the tools I need in order to run this. Now, if you'll take a look at the currently installed version of the AWS CLI. This is running at 1.16.102. We actually need to update this if we're going to work with the Managed Blockchain service. And to update this, we also need to install PIP and do a few other things. I've written a shell script to do this that I will put in the description for this. For now, I'll just run it and then start the video back up.
All right, it looks like it's finished. Let's go ahead and check if it was installed correctly. Now the few things that this was trying to do is update the AWS CLI version. Perfect. So that's running it to 263 now. We want to also check our Docker version, because this should have installed Docker as well.
Great and we want to be running at least 17.6.2. Let's check Docker compose next. Alright, and we're running at build 1.20.0. We want to make sure we're running at least 1.14.0. And last we want to make sure that we have Go installed. Okay, so we have to fix our Go installation. I'll do that off screen and then get back to you. All right, and our Go version is 1.10.3, we want to make sure that we're running at least 1.10.0.
Now that we have the prerequisites installed, we want to make sure that we can access our managed blockchain network. Let's go ahead and run the command aws managedblockchain get-member and we're going to pass in our network ID and member ID from earlier.
Okay, so after running the aws managed-blockchain command, I go ahead and I get this CaEndpoint here in the middle. This is our VPC endpoint. We wouldn't have gotten this if we didn't set that up in the earlier step. So I'm going to go ahead and copy that off for now. And to test it, we can run a curl against it like this. And we want to make sure that we throw in the CA info at the end of the URL as well as a -k flag, which will return this. Great that's how we know our endpoint is working.
Let's go get our fabric client. And since we have Go installed, let's go ahead and use go get to get it for us. What this is going to do is build our Hyperledger Fabric tools. Next, we want to download our Hyperledger Fabric samples. Again, everything in this is in a Git repository, you can get it from the Hyperledger project.
All right, so I went ahead and cleared the screen so that I can show you a little bit more about what's in the samples repository. So if we go ahead and list out what's in here, we see a few different network types including basic-network, first-network and off_chain_data. These are going to be different things that you can use to base your first network on. So, for example, if I changed the directory here into basic-network, you see we have a few different files here. A couple I want to point out to you are the docker-compose.yaml as well as the start and stop shell scripts [start.sh and stop.sh].
So let's go ahead and take a look at the Docker-compose file first. This is going to start up all of the containers on our Hyperledger network. It's a little bit like Kubernetes, where it basically tells the Docker-compose app that we installed earlier which containers to run, which properties to pass them, which volumes to mount, which ports to expose, etc. The next thing I want to show you is the start and stop shell scripts. Now you see this is really just running docker-compose with a few extra parameters, and stop is going to be doing the same thing to shut them down. This is how we start and stop our network when we need to do maintenance. It can also be built into a CI system.
So let's actually go ahead and run one of these. I'll go ahead and start my network here. So you see our network is up and running. If we do a Docker ps, we can see the different containers that are running and which ports they're running on.
All right, that's it for this demo. Thank you for watching.