Part 2 : DevOps — Automating Elastic Beanstalk environment creation using AWS Java SDK / CLI

In the previous blog, we saw how to deploy a stand-alone OpenAM instance in AWS using Elastic Beanstalk. In this blog, we are going to see on how to automate the entire infrastructure provisioning using AWS Java SDK as well as AWS CLI. This will be really useful when the infrastructure provisioning and deployment needs to be automated. These steps can be used to deploy any war file in tomcat.

Step 1 : Build the EBS Deployment package

Follow the same manual steps mentioned in previous blog. This can be easily automated using a build tool like Jenkins.

Step 2 : Upload the deployment package to AWS S3 bucket

Deployment package can be uploaded to s3 using below command. This can be automated using a shell script.

Step 3 : Create an environment in EBS to deploy OpenAM

This can be automated in multiple ways, either using AWS CLI commands or AWS SDK which is available in various programming languages like Java, Python etc.

Option 1 : AWS CLI

Let us first look at the AWS CLI commands to provision a Elastic Beanstalk environment and deploy OpenAM war. Below are the commands to automate all the manual steps mentioned in previous blog using AWS CLI. All these commands can be added as part of a shell script.

Option 2 : AWS Java SDK

Another option is to use AWS Java SDK to provision the same Elastic Beanstalk environment using infrastructure as code. Download / clone the GitHub project : and build the jar file using Maven from the root folder of this project. The command to build the jar file is :

This should generate aws-ebs-openam-1.0.0.jar in target folder. Copy that jar file to lib folder and run either bin/awsopenam.bat or bin/ depending on the OS. That should automatically provision the environment and deploy the OpenAM war file.

The entire logic to provision the environment and deploy war file is present in java class :

This is a very basic program to provision the Elastic Beanstalk environment. The configuration can be customized according to project needs. But, the jar file needs to be rebuilt using Maven “mvn clean package” and copied to lib folder.

Step 4 : Configure OpenAM instance

Follow the same manual steps mentioned in previous blog. This can be automated using OpenAM ssoadm command or AMSTER.

Thank you for reading this article. If you have any questions / suggestions, kindly leave a comment.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store