Docs‎ > ‎

AWS Elastic Beanstalk

Preparing the war file

The first step is to get a copy of the Live API Creator software.You'll need to contact your CA Sales team. You will get a package containing a war file, such as APICreator.war.

For proper deployment to Amazon Elastic Beanstalk, you will need to customize the war file to include a file that will tell Elastic Beanstalk to install JDBC drivers for all the database types you plan to access. You will need to add at least the MySQL/MariaDB driver.

The file (.ebextensions/JDBCDrivers.config)should looks like this:  You will need to make sure you source your own files from a stable source location.

files: 
  "/usr/share/tomcat8/lib/mariadb-java-client-1.2.2.jar": 
     mode: "000755"
     owner: tomcat
     group: tomcat
     source: http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/1.2.2/mariadb-java-client-1.2.2.jar

  "/usr/share/tomcat8/lib/postgresql-9.4-1206-jdbc42.jar": 
     mode: "000755"
     owner: tomcat
     group: tomcat
     source: http://central.maven.org/maven2/org/postgresql/postgresql/9.4-1206-jdbc42/postgresql-9.4-1206-jdbc42.jar

etc...


If you need to configure your JVM options (optional) - you can create a file JVMoptions.config with these values.

# Set the JVM options for e.g. heap size

option_settings:
- namespace: "aws:elasticbeanstalk:container:tomcat:jvmoptions"
  option_name: Xmx
  value: 1024m

- namespace: "aws:elasticbeanstalk:container:tomcat:jvmoptions"
  option_name: Xms
  value: 256m

- namespace: "aws:elasticbeanstalk:container:tomcat:jvmoptions"
  option_name: verbose
  value: gc

The file format is YAML, and is documented in the Amazon docs.

To add these to a War file:

jar uf <war file> .ebextensions/JDBCDrivers.config

jar uf <war file> .ebextensions/JVMoptions.config


Creating a New Instance

This process should take 2-3 minutes to configure, followed by a 15-minute wait for the service to come up.  It will create a new RDS instance (refer here for instructions on using an existing RDS instance).

1 - You will use the war file that you customized in the step above.

2 - Log into your Amazon Console (often at https://console.aws.amazon.com but that may vary)

3 - Find Deployment & Management and Select the Elastic Beanstalk page 

4 - Click Create New Application 


5 - Enter an application name, e.g. "Acme's API", and click Next


6 - On the New Environment page, click Create web server




8 - In the Environment Type page, select Predefined configuration: Tomcat and select the Environment type v2.0.4 (a prior release). Click Next



9 - In the Application Version page, select Upload your customized Live API Creator WAR file, then click Next


10 - In the Environment Information page, enter an Environment name and an Environment URL, which will be the default address for your API service (you can always alias it later). Click Next.



11 - In the Additional Resources page, check Create an RDS DB Instance with this environment. This will create a new MySQL RDS instance to store API Server repository metadata. Click Next.

12 - In the Configuration Details page, select the desired options. CA Live API Creator can comfortably run in a micro instance, but it will take full advantage of any additional CPUs you allocate. Any memory in excess of 4GB will not be used, however. Click Next.


13 - If, in step 8, you selected Environment Type: Load balancing, auto scaling, you will now have an option called Application health check URL. The correct value is 

/rest/abl/admin/v2/@heartbeat

14 - In the Environment Tags page, you can tag your new service if desired. Click Next.


15 - In the RDS Configuration page, configure your MySQL database instance. A micro instances should be fine for most applications. Write down your user ID and password in case you need it later. Click Next.


16 - In the Review page, make sure all settings are as desired and click Launch.

The creation of the service can take up to 20 minutes, mostly because of the creation of the new RDS instance.


After a while, the Health icon should turn green -- congratulations, you now have your own  API Creator service. You should be able to click on its URL.



At this point, Elastic Beanstalk will have created one (or more) EC2 instance(s), an RDS instance, a load balancer, an elastic IP address, and a security group. You can modify any of these, but if you make changes to the EC2 instance(s), keep in mind that these changes may be lost if you use auto-scaling.


[OPTIONAL] Using an existing RDS MySQL database

The instructions above include the creation of a new MySQL RDS instance. A micro instance is very cheap, but perhaps you already have an existing RDS instance that you'd like to use, rather than creating a new one. Here's how to do that.

Open a Remote Connection for your IP 

If you want to use MySQL Workbench or any tool on your local desktop - you will need to add your IP address to the security group of the RDS MySQL instance (shown below).



1 - You can skip steps 11 and 14

2 - Once the service is created, it will not start successfully because it doesn't have access to an admin database -- this is normal.

3 - Connect to your MySQL RDS instance and create a new database (call it anything you want)

4 - Also create a MySQL user who has full access to that new database

5 - You will need to make sure that your API service is authorized to connect to that RDS instance -- the RDS instance's security group should include the newly created security group for the API service.  See the MySQL section of this page.

6 - Open the Configuration page for your new application

7 - Click the gear icon next to Software Configuration

8 - In the Environment Properties section, you'll need to define 5 new environment properties:

 RDS_HOSTNAME The hostname of your RDS server
 RDS_PORT The port used to access your RDS server, normally 3306
 RDS_DB_NAME The name of the database you created
 RDS_USERNAME The name of the MySQL user you created
 RDS_PASSWORD The password of the MySQL user you created

Once you click Save, you may have to restart the application for these changes to take effect. If things are configured properly, the application should come online after 2-3 minutes.
If it does not, you'll need to look at the log files to determine what the problem is.