AWS Elastic Beanstalk
Provision an AWS Elastic Beanstalk environment via the AWS Management Console and deploy an OntoPop API application to it.
Please note that the OntoPop backend open-source software project, which includes the event-driven data pipelines and APIs, is undergoing extensive redesign and refactoring as part of OntoPop Community 3.x in order to improve performance, security, extensibility and maintainability. As a result, the documentation on this page will be significantly updated. Please refer to the OntoPop Roadmap for further information.
AWS Elastic Beanstalk is an AWS cloud computing platform service that enables developers and platform engineers to deploy and scale web applications and services developed in industry-standard languages including Java, Python, Go, Ruby and Node.js. This page provides instructions on how to provision AWS Elastic Beanstalk environments and then deploy the OntoPop API Spring Boot applications to them.
For further information regarding AWS Elastic Beanstalk, please visit https://aws.amazon.com/elasticbeanstalk.
It is recommended that you configure and integrate the steps described in this page into a CI/CD pipeline in order to automate the build, testing and deployment stages.
OntoPop provides AWS API Spring Boot application deployments that wrap around each of the API collections described in the logical system architecture. These AWS Spring Boot applications are provided out-of-the-box to enable quick and easy deployment to AWS Beanstalk environments. Assuming that you have followed the instructions detailed in Build from Source, the AWS Spring Boot applications for each of the API collections may be found in the
$ONTOPOP_BASE/ontopop-apps/ontopop-apps-aws Maven module, which itself contains the following child modules pertinent to the OntoPop APIs:
ontopop-aws-beanstalk-app-api-ontology-management- AWS Spring Boot application deployment wrapper for the Management API endpoints.
ontopop-aws-beanstalk-app-api-ontology-triplestore- AWS Spring Boot application deployment wrapper for the Triplestore API endpoints.
ontopop-aws-beanstalk-app-api-ontology-graph- AWS Spring Boot application deployment wrapper for the Graph API endpoints.
ontopop-aws-beanstalk-app-api-ontology-search- AWS Spring Boot application deployment wrapper for the Search API endpoints.
Build from Source
In order to compile and build the OntoPop AWS API Spring Boot applications in preparation for deployment to AWS Beanstalk environments, please follow the instructions detailed in Build from Source.
If you have not already done so when deploying the OntoPop AWS Lambda instances as described in AWS Lambda, please install the AWS CLI as follows:
The instructions below are for Ubuntu 20.04. Installation instructions for other Linux distributions and other operating systems such as Windows may be found at https://aws.amazon.com/cli.
# Install the required dependencies $ sudo apt-get update $ sudo apt-get install glibc groff less # Install the AWS CLI from a ZIP file $ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" $ unzip awscliv2.zip $ sudo ./aws/install
Assuming that the AWS CLI has installed successfully, we can configure it with the Access Key ID and Secret Access Token of an IAM user with privileges to programmatically manage AWS Elastic Beanstalk environments (such as an IAM user provisioned with the
AdministratorAccess-AWSElasticBeanstalk AWS managed policy, or similar custom policy) as follows:
# Configure the AWS CLI $ aws configure AWS Access Key ID [None]: AKIA123456789 AWS Secret Access Key [None]: abcdefg987654321hijklmnop Default region name [None]: eu-west-2 Default output format [None]: json
We shall use the Elastic Beanstalk Command Line Interface (EB CLI) to deploy the OntoPop Java artifacts (i.e. OntoPop's AWS API Spring Boot applications packaged as JAR files) that were created in the Build from Source stage above to AWS Beanstalk environments. To install the EB CLI, please follow the instructions below:
The instructions below are for Ubuntu 20.04. Installation instructions for other Linux distributions and other operating systems such as Windows may be found at https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html.
# Install the required dependencies sudo apt install python3-pip sudo pip3 install virtualenv # Clone the EB CLI GitHub repository git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git # Install the EB CLI using Python python ./aws-elastic-beanstalk-cli-setup/scripts/ebcli_installer.py echo 'export PATH="/home/$USER/.ebcli-virtual-env/executables:$PATH"' >> ~/.bash_profile && source ~/.bash_profile
We shall use the AWS Management Console to provision AWS Elastic Beanstalk environments. To do so, navigate to the AWS Elastic Beanstalk service via the AWS Management Console, select "Create a new environment" and follow the instructions below:
- Environment Tier - select web server environment.
- Application Name - enter a custom application name, for example
- Environment Name - enter a custom environment name, for example
ontopop-management-api-envand, if required, edit the custom subdomain at which this API will be made available to server HTTP requests.
- Platform - select Java and Corretto 11 running on 64bit Amazon Linux 2 as the managed platform runtime environment.
Once configured, select "Create environment" to create the new AWS Elastic Beanstalk environment. It may take AWS between 3 - 5 minutes to provision the new managed environment. Once provisioned, head back to the AWS Elastic Beanstalk service via the AWS Management Console and make a note of its URL from the list of environments listed (for example
In the following instructions we use the
ontopop-aws-beanstalk-app-api-ontology-management child Maven module as an example with which to demonstrate how to deploy an API Spring Boot application to an AWS Elastic Beanstalk managed environment. However these instructions can be equally applied to deploy any and all of the AWS API Spring Boot applications listed above.
- First we need to set
AWS_SECRET_ACCESS_KEYenvironment variables with values associated with the access key of an IAM user who has been provisioned with AWS Secrets Manager read and write privileges. To do this, open the AWS Elastic Beanstalk environment via the AWS Management Console, select Configuration and then select the "Edit" button alongside the "Software" category section. Scroll down to the "Environment properties" section and add the
AWS_SECRET_ACCESS_KEYenvironment variables respectively, as illustrated in the following screenshot:
- Now we are ready to deploy the Java Spring application code to the relevant AWS Elastic Beanstalk environment. Assuming that you have followed the instructions detailed in the Setup section above, navigate to
$ONTOPOP_BASE/ontopop-apps/ontopop-apps-aws/ontopop-aws-beanstalk-app-api-ontology-management(in our example) and execute the following commands via your command line:
# Navigate to the relevant project folder $ cd $ONTOPOP_BASE/ontopop-apps/ontopop-apps-aws/ontopop-aws-beanstalk-app-api-ontology-management # Select the relevant Beanstalk environment to deploy to $ eb init # Define the path to the JAR artifact to upload and deploy $ vi .elasticbeanstalk/config.yaml deploy: artifact: target/ontopop-aws-beanstalk-app-api-ontology-management-eb.jar # Deploy the JAR artifact to the Beanstalk environment $ eb deploy # Check the status of the Beanstalk environment $ eb status
The OntoPop API collection is now publicly available to serve HTTP requests at the URL noted above, for example
ontopop-management-api.eu-west-2.elasticbeanstalk.com. If you have configured a load balancer when you provisioned the Elastic Beanstalk instance, then you will be able to consume the API endpoints via the load balancer URL instead.
To configure a custom domain, please configure AWS API Gateway accordingly as detailed at https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html.