Running Corda on AWS

November 19, 2020

The easy way with code examples

Photo by Caspar Camille Rubin on Unsplash

Hey there, if you’re reading this you’re probably looking to get Corda set up in a cloud provider. This is a short and sweet guide to help you do that without too much pain.

Step 1: Set up your network

In our setup, we have a simple network with four nodes running on two virtual machines. You can provision them in the same VPC if you want, but the main requirement, of course, is that the nodes must be able to reach each other.

A highly technical diagram of what we’re doing here

Start by opening the AWS management console and provisioning two nodes on your favorite Linux distribution. (In my case, I’ll pick the latest version of ubuntu). My recommendation for a Corda node is at least a t2.medium.

Ubuntu 20.04 is fine

If you’re looking to get a demo working, I’d recommend a simple security group that allows all traffic. Once you’ve allowed all traffic you can ensure the nodes can communicate with a simple ping command test.

a simple demo security group could look like this

Once you have tested the connection and you believe the nodes can communicate, you should be aware of the danger of allowing all traffic to the group. It is not safe to allow all inbound traffic on a production instance of pretty much anything.

For a guide on AWS Network configuration, I recommend the Amazon documentation.

One last thing to do before you go on to access the nodes is to modify your codebase.

I’ve set up a repository for this tutorial on GitHub. Download this repository and you’ll notice a VM1 folder and a VM2 folder. You’ll also see a commands.sh that contains code you can use when provisioning the actual machine. So two of our Corda nodes, the Notary and “Party A” will run on VM1. The other two of our Corda nodes, the “Party B” and “Party C” will run on VM2.

Both of those folders have similar contents, and you need to make sure that you add the public IP addresses of the Corda nodes to align with the VMs that they’re going to run on.

Take the IP address of the ec2 instance that will run VM1’s nodes, and then add its IP address to the p2pAddresssection of VM1/notary/node.conf.

For example, if the node’s IP address was 104.211.141.139 Then the resulting file would look like this:

p2pAddress="104.211.141.139:10002"
rpcSettings {    
    address="0.0.0.0:10003"    
    adminAddress="0.0.0.0:10043"
}

Heres’ a link to the node.conf file you can use so you know where to go.

Now add that same IP for the p2pAddress of theVM2 nodes. (Party B and Party C).

Once that bit of housekeeping is done, you’re ready to copy these folders onto the virtual machines.

Step 2: Run Corda

Once you’ve got ssh access, copy your folders onto the virtual machines. After a quick scp or rsync you should be all set. After copying over the folder, just run the commands.sh file I provided in the root of the repository. If all goes well, the virtual machines will be able to run docker without any issues.

Once you’re in, cd into the folders for each VM and run the following docker command with the right file:

docker-compose -f docker-compose-vm1.yaml up

Note: Docker may show an error about not having permissions to write to a database file, if you see that just make sure to change the permissions of the VM directory to make sure that both your user and the ‘docker’ user can write to them.

Step 3: Test your network

Now that you’ve got everything running on docker, it’s time to test your network and connectivity. We’re going to do this with the Corda Node Explorer. (download link here)

example of node explorer login

You’re going to want to log into the node explorer using a specific virtual machine’s IP address and the node port specified in the rpcSettings address of the node conf. (In this case, it’s 10006 for Party A).

The username and password are also specified in the node.conf, so we’ll use them here.

If all goes well and the nodes can communicate with each other, you’ll be able to see nodes from VM1 and VM2! Not bad!

A screenshot of the node explorer if everything went well

That about covers it! Once you’re in the node explorer, you’re able to interact with your network, create transactions, run vault queries, and more!

And just for convenience, the link to that github repo is here.

You can also find a video version of this tutorial on youtube here.

Happy Coding ~

Want to learn more about building awesome blockchain applications on Corda? Be sure to visit https://corda.net, check out our community page to learn how to connect with other Corda developers, and sign up for one of our newsletters for the latest updates.

— David Awad is a Developer Evangelist at R3, an enterprise blockchain software firm working with a global ecosystem of more than 350 participants across multiple industries from both the private and public sectors to develop on Corda, its open-source blockchain platform, and Corda Enterprise, a commercial version of Corda for enterprise usage.

Follow David on Twitter here.


Running Corda on AWS was originally published in Corda on Medium, where people are continuing the conversation by highlighting and responding to this story.

Share: