This is an AWS Marketplace only feature.

Overview

This document describes the procedures for setting up Kill Bill under AWS using the multi-tier option. This is one of two recommended alternatives for production use. The multi-tier option requires more setup than CloudFormation, but provides more control over the deployment. The procedures in this document are based on the options recommended by Kill Bill.

This configuration uses two or more EC2 instances and a separate database provided by the AWS Relational Database Service (RDS). It also includes an AWS Elastic Load Balancer (ELB) to correctly spread the traffic among the various nodes, and to route traffic to either the Kill Bill Server or Kaui based on the incoming port.

The diagram below shows the principal components of the multi-tier system: The ELB, the RDS, and two or more EC2 instances. Each EC2 is an instance of Ubuntu Linux, running both Kill Bill and Kaui within a tomcat server. Clients interact only with the ELB, which routes requests to the rest of the system.

multi tier ami deployment

These components will be installed in reverse order. First we setup the RDS databases. Next the EC2 instances are created. Finally, the ELB load balancer is installed to tie everything together.

The setup procedure includes eight steps:

Note
AWS user interfaces change frequently. You may see screens slightly different from those shown below.

Step 1: Login to AWS

To begin, log in to Amazon Web Services at https://aws.amazon.com. If you are new to AWS, you will be asked to create an account and provide billing information. You will need to sign in as a Root User. This should take you to the AWS Management Console, which provides links to all available services.

Check the upper right corner of your screen to be sure you are in the appropriate region. All resources you create will be placed in this region, and may not be accessible from other regions.

In addition, AWS places all resources within a Virtual Private Cloud (VPC). A default VPC will be created and used automatically in the following steps. However, if you have access to other VPCs, you will need to ensure that all Kill Bill resources are deployed in the same one.

Step 2: Setup the RDS

Once you are logged in, the first step is to setup the Relational Database System. This process begins with the RDS dashboard, which should be available from the Services menu. When the dashboard appears, select Databases from the left menu, and click the red button at the top right that reads Create Database:

multitier create database

2.1. Set the Configuration

You will be taken to the Create Database page. The first choice you will have is between Standard Create, which allows you to set a full range of configuration parameters, or Easy Create, which sets most of these parameters to defaults. Select Easy Create.

multitier standard or easy

The next section offers you a choice of several database types. Kill Bill can work with any database type that is mysql or postgres compatible. For robust production use, Amazon Aurora is probably a good choice. Here we will illustrate the simpler steps setting up a MariaDB database.

multitier database types

The next choice determines the instance size. We suggest the Production option as this will provide the most robust configuration.

multitier instance sizes

The last section asks you to:

  1. Specify a name for your database

  2. Give a username for the administrative account (we suggest that you do not use the default name)

  3. Provide a password for the administrative acount (we suggest you let AWS generate one for you)

multitier names and password

2.2. Create the Database Manager

When the password is setup and confirmed, click Create Database in the lower right corner. You will return to the main Databases screen, which should now look like this:

multitier database starting

This display shows that your database is starting. After a few minutes, the status will change to Available (You may need to reload the page to see this). You will also have a chance to see the password, in case it was autogenerated. Save this password, as you will need it later.

At this time you can click on the database name to get more information. You should see a panel named Connectivity and Security. The left side of this panel shows the full name of the endpoint, which you will need shortly, and the port number, which is normally 3306.

multitier connectivity and security

2.3. Setup the Security Rules

Lastly, on the Connectivity and Security panel, locate and click on the link for the default VPC security group. You will need to add an inbound security rule because the database by default does not allow external access. In the panel for this group, click on Inbound Rules and select Edit Inbound Rules. Next, click on Add rule. In the Type column select MYSQL/Aurora. The port will be set to 3306 automatically. In the Source column, click on the search icon and select 0.0.0.0/0. Finally, click on Save Rules in the bottom right. Your database is ready to go.

Note

The current security configuration allows open access to the database from any IP address, which can pose significant security risks. Exposing a database to the public internet without proper restrictions is generally not recommended as it may lead to potential vulnerabilities and make your data susceptible to attacks.

To ensure robust protection, it is essential to promptly update the database security settings after completing the Multi-Tier setup. We recommend restricting access so that only EC2 instances running Kill Bill and Kaui are permitted to connect to the database.

Step 3: Create the Databases

Kill Bill requires two databases, with the names killbill and kaui. We provide predefined schemas for these databases.

To create the databases, you will need to login to one of your instances as described above. Once you are logged in, you can use the mysql command to create the two databases killbill and kaui. The credentials required for this command are the same ones you set up for the database in step 2.1 above.

Note that the host <DB-Endpoint-Writer-Instance> should not include the port number and there is no space after -h and -u options.

The password will not be echoed when it is typed.

> mysql -h<DB-Endpoint-Writer-Instance> -u<DB-Username> -p
Enter Password:
mysql> create database killbill;
mysql> create database kaui;
mysql> exit

The next step is to install the schemas. These can be found at:

One easy way to do this is to return to your local computer (type exit) and download the schemas (give them distinct names), then use the sftp command to upload them to your EC2 instance home directory with the commands:

sftp -i PRIVATE_KEY.pem ubuntu@INSTANCE_IP
put killbill.ddl
put kaui.ddl
exit

Once the files are successfully uploaded, login again to your instance using the ssh command. You can now install the schemas:

> mysql -h<DB-Endpoint-Writer-Instance> -u<DB-Username> -p<DB-Password> < killbill.ddl

> mysql -h<DB-Endpoint-Writer-Instance> -u<DB-Username> -p<DB-Password> < kaui.ddl

To ensure that the databases are setup correctly, login to mysql again, then try the SHOW TABLES command:

> mysql -h<DB-Endpoint-Writer-Instance> -u<DB-Username> -p<DB-Password>

use killbill;
show tables;
use kaui;
show tables;
exit

Step 4: Edit the Configuration Script

To configure the EC2 instances and establish their connection to the databases, you’ll need to provide essential information. Fortunately, Kill Bill and Kaui are equipped to read environment variables, making the setup more straightforward. For your convenience, we have a concise configuration script available to streamline this process. Below is the template for the script:

#!/bin/bash

db_host="<DB endpoint writer instance>"
db_port="<DB port>"
db_user="<DB username>"
db_password="<DB passwordd>"
kb_admin_password="<Kaui admin login password>"

cat << EOF >> /etc/environment
KB_org_killbill_dao_url=jdbc:mysql://$db_host:$db_port/killbill
KB_org_killbill_dao_user=$db_user
KB_org_killbill_dao_password=$db_password

KB_org_killbill_billing_osgi_dao_url=jdbc:mysql://$db_host:$db_port/killbill
KB_org_killbill_billing_osgi_dao_user=$db_user
KB_org_killbill_billing_osgi_dao_password=$db_password

KB_ADMIN_PASSWORD=$kb_admin_password

KAUI_DB_ADAPTER=mysql2
KAUI_DB_URL=jdbc:mysql://$db_host:$db_port/kaui
KAUI_DB_USERNAME=$db_user
KAUI_DB_PASSWORD=$db_password
KAUI_KILLBILL_URL=http://127.0.0.1:8080
EOF

In the above script, replace the value of db_host with the full name of the DB writer endpoint obtained from the Connectivity and Security panel, as indicated earlier. Be sure to specify the appropriate database port number (3306 for MySQL or 5432 for PostgreSQL) by setting db_port. The kb_admin_password value will be utilized as the admin password for Kaui login.

Optionally, you may choose to customize other Kill Bill properties based on your specific needs. For more detailed information on available configuration options, please refer to the documentation provided at: https://docs.killbill.io/latest/userguide_configuration.html.

Note

The Kaui properties present in the provided template are required for proper functioning. Missing any of these properties may prevent the Kill Bill service from starting successfully. Ensure to set all the necessary properties correctly to ensure a smooth setup process.

Save this script to a file as it will be necessary during the launch of EC2 instances.

Step 5: Launch EC2 Instances

The next step is to launch the number of EC2 instances you want, all based on the Kill Bill single AMI.

5.1. Subscribe to the AMI

To start the installation process, point your browser to the Kill Bill AMI at AWS Marketplace .

You should see the following image at the top of your screen:

multitier subscribe

Click Continue to Subscribe. The next page will give the AWS Terms and Conditions:

Accept the terms if asked. You will then see a new message confirming that you have subscribed. Next, click Continue to Configuration.

5.2. Configure the Instances

The next page will give several configuration options:

multitier configure

Be sure to select the region you plan to operate in. Accept the other defaults. Then click Continue to Launch.

The next page will give you several options for the launch method. Choose Launch through EC2.

multitier launch

All other options will disappear. Click Launch.

The next page is headed Launch an Instance. There are several things you will need to do here.

First, at the top right, select the number of instances you will use. We recommend 2. You can add more later.

Next, scroll down to the middle of this page, to the box titled Key Pair (login) Here you are asked to choose or create a key pair.