How to export your Bahmni Vagrant/Image or VM directly to AWS

Sometimes, we need to make developments, customizations, and more in our local VMs and later on, we realize that the same developments would be great to have in the cloud as well. Therefore, this documentation will demonstrate how we can do such a task by using Bahmni Vagrant and AWS as cloud provider via its VM Import/Export feature.

Warning:

1. Using this feature will cost you money on AWS, therefore please make sure to check and terminate any resources that you don’t need anymore once you finish testing.

2. Cloud based systems are public, and hence at risk. Please ensure you setup firewalls, fail2ban, security groups/ACLs, private subnet, etc to keep your machine safe. Read more in the Bahmni Security Guide.

 

STEP 1: Exporting the VMs Image

Initially, we need to install Bahmni Vagrant for setting up Bahmni on our machine. For a detailed process on how to set it up, please follow this guide.

Once the Vagrant has been installed and Bahmni is up and running, you need to stop the VM in the Oracle VM VirtualBox Manager and export the VM as shown below:

Now we have an OVA file which is basically the image that can be used for exporting to the AWS.

note: You can execute the same task with your VMs that are running on a VMware® vSphere as well. What you need to know is that these VMs must be exported in one of the supported versions. For a list of supported versions, please follow this link.

 

STEP 2: Exporting it to AWS

As you will see in this documentation of the VM Import/Export, we need to have AWS Command Line Interface installed on our machine so that we can interact easier with AWS. For instructions on how to install it, please follow this link.

 

  • Create the trust-policy.json file (see an example below)

now execute

aws iam create-role --role-name vmimport --assume-role-policy-document "file://trust-policy.json"
  • Create the role-policy.json file (see an example below)

now execute

aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document "file://role-policy.json"

 

note: Ensure that the name of the S3 bucket must be the bucket you've created on AWS. If you cannot create the bucket or execute any command, please refer to the documentation above because most probably you have some permission settings that are different, or the AWS CLI isn't installed properly.

  • Now that the role is created on AWS, you can start uploading the OVA file to your newly created S3 bucket.

aws s3 cp .\<path to your file\Bahmni-93-asha-cli.ova s3://<name of the s3 bucket>
  • Once the file is uploaded you can check in your S3 bucket and find it there. The next step is to create the containers.json file which will serve us for creating an AWS AMI out of the newly uploaded OVA file.

now execute

aws ec2 import-image --description "<name of the AMI we want to have>" --disk-containers "file://containers.json"
  • Please wait a few minutes (maybe up to 15-20min, depending on the size of the image) and then go into the AMI menu under EC2 Dashboard on AWS and launch the EC2 Instance from this AMI (the one the previous step will create).

  • Please make sure to attach security groups with at least SSH (port 22), HTTP (port 80), and HTTPS (port 443) open, and other ports closed for security. The size of the instance you want to provision is up to you but a small image might not be enough (I’ve tested with t2.medium) for Bahmni itself.

 

 

 

The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)