<img height="1" width="1" style="display:none;" alt="" src="https://px.ads.linkedin.com/collect/?pid=299788&amp;fmt=gif">

Practical Liferay Series: Liferay on AWS

Software Development, Software Solutions

By Robert Hall

This is the second in a series of discussions on Liferay deployment environments and other practical issues. In this discussion, we look at using Amazon Web Services for building Liferay environments.
Cloud services and solutions have been on the rise in recent years, with hosted commodity servers and administrative tools easing system administration for development, testing and production environments. One popular cloud environment and services platform is Amazon's AWS (Amazon Web Services) with its EC2 (Elastic Compute Cloud) servers and RDS (Relational Database Service) database servers.
AWS works well for setting up simple or complicated environments that are useful for development, integration, QA and production environments.
Through the AWS Management Console, AWS command line tools, Eclipse plugin or other means, it is easy to instantiate AWS resources such as a VPC (Virtual Private Cloud), EC2 instances, RDS databases, web servers, load balancers, etc. Furthermore, the creation of a group of these resources is easy to script using the Cloud Formation tools.


These are parts of a sample Cloud Formation template script for setting up a two-tier EC2 environment (one with Apache, one with a Liferay install) with an RDS MySQL database. These samples illustrate the JSON structure used for specifying EC2 entities.
Below is a JSON specification for creating a Linux EC2 instance with attached volume (ideal for locating the Liferay document library).
Resource definition for an EC2 instance:

&quot;Resources&quot; : {
&quot;Ec2Instance&quot; : {
"Type" : "AWS::EC2::Instance",
&quot;Properties&quot; : {
"AvailabilityZone" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "TestAz" ]},
&quot;SecurityGroups&quot; : [ { &quot;Ref&quot; : &quot;InstanceSecurityGroup&quot; } ],
&quot;KeyName&quot; : { &quot;Ref&quot; : &quot;KeyName&quot; },
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
&quot;Volumes&quot; : [
{ &quot;VolumeId&quot; : { &quot;Ref&quot; : &quot;NewVolume&quot; },
&quot;Device&quot; : &quot;/dev/sdk&quot;
&quot;InstanceSecurityGroup&quot; : {
"Type" : "AWS::EC2::SecurityGroup",
&quot;Properties&quot; : {
&quot;GroupDescription&quot; : &quot;Enable SSH access via port 22&quot;,
&quot;SecurityGroupIngress&quot; : [ {
&quot;IpProtocol&quot; : &quot;tcp&quot;,
&quot;FromPort&quot; : &quot;22&quot;,
&quot;ToPort&quot; : &quot;22&quot;,
&quot;CidrIp&quot; : &quot;;
} ]
&quot;NewVolume&quot; : {
"Type" : "AWS::EC2::Volume",
&quot;Properties&quot; : {
&quot;Size&quot; : &quot;100&quot;,
"AvailabilityZone" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "TestAz" ]}
These JSON examples are for gathering parameters for creating a MySQL database in RDS :
&quot;DBName&quot;: {
&quot;Default&quot;: &quot;MyDatabase&quot;,
&quot;Description&quot; : &quot;The database name&quot;,
&quot;Type&quot;: &quot;String&quot;,
&quot;MinLength&quot;: &quot;1&quot;,
&quot;MaxLength&quot;: &quot;64&quot;,
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
&quot;ConstraintDescription&quot; : &quot;must begin with a letter and contain only alphanumeric characters.&quot;
&quot;DBUsername&quot;: {
&quot;Default&quot;: &quot;admin&quot;,
&quot;NoEcho&quot;: &quot;true&quot;,
&quot;Description&quot; : &quot;The database admin account username&quot;,
&quot;Type&quot;: &quot;String&quot;,
&quot;MinLength&quot;: &quot;1&quot;,
&quot;MaxLength&quot;: &quot;16&quot;,
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
&quot;ConstraintDescription&quot; : &quot;must begin with a letter and contain only alphanumeric characters.&quot;
&quot;DBPassword&quot;: {
&quot;Default&quot;: &quot;adminpw&quot;,
&quot;NoEcho&quot;: &quot;true&quot;,
&quot;Description&quot; : &quot;The database admin account password&quot;,
&quot;Type&quot;: &quot;String&quot;,
&quot;MinLength&quot;: &quot;1&quot;,
&quot;MaxLength&quot;: &quot;41&quot;,
"AllowedPattern" : "[a-zA-Z0-9]*",
&quot;ConstraintDescription&quot; : &quot;must contain only alphanumeric characters.&quot;
&quot;DBClass&quot; : {
&quot;Default&quot; : &quot;db.m1.small&quot;,
&quot;Description&quot; : &quot;Database instance class&quot;,
&quot;Type&quot; : &quot;String&quot;,
&quot;AllowedValues&quot; : [ &quot;db.m1.small&quot;, &quot;db.m1.large&quot;, &quot;db.m1.xlarge&quot;, &quot;db.m2.xlarge&quot;, &quot;db.m2.2xlarge&quot;, &quot;db.m2.4xlarge&quot; ],
&quot;ConstraintDescription&quot; : &quot;must select a valid database instance type.&quot;
&quot;DBAllocatedStorage&quot; : {
&quot;Default&quot;: &quot;5&quot;,
&quot;Description&quot; : &quot;The size of the database (Gb)&quot;,
&quot;Type&quot;: &quot;Number&quot;,
&quot;MinValue&quot;: &quot;5&quot;,
&quot;MaxValue&quot;: &quot;1024&quot;,
&quot;ConstraintDescription&quot; : &quot;must be between 5 and 1024Gb.&quot;
The JSON resource specification to create the database:
&quot;Resources&quot; : {
&quot;MyDBSubnetGroup&quot; : {
"Type" : "AWS::RDS::DBSubnetGroup",
&quot;Properties&quot; : {
"DBSubnetGroupDescription" : "Subnets available for the RDS DB Instance",
&quot;SubnetIds&quot; : { &quot;Ref&quot; : &quot;Subnets&quot; }
&quot;MyDBSecurityGroup&quot; : {
"Type" : "AWS::RDS::DBSecurityGroup",
&quot;Properties&quot; : {
&quot;GroupDescription&quot; : &quot;Security group for RDS DB Instance&quot;,
&quot;EC2VpcId&quot; : { &quot;Ref&quot; : &quot;VpcId&quot; }
&quot;MyDB&quot; : {
"Type" : "AWS::RDS::DBInstance",
&quot;Properties&quot; : {
&quot;DBName&quot; : { &quot;Ref&quot; : &quot;DBName&quot; },
&quot;AllocatedStorage&quot; : { &quot;Ref&quot; : &quot;DBAllocatedStorage&quot; },
&quot;DBInstanceClass&quot; : { &quot;Ref&quot; : &quot;DBClass&quot; },
&quot;Engine&quot; : &quot;MySQL&quot;,
&quot;EngineVersion&quot; : &quot;5.5&quot;,
&quot;MasterUsername&quot; : { &quot;Ref&quot; : &quot;DBUsername&quot; } ,
&quot;MasterUserPassword&quot; : { &quot;Ref&quot; : &quot;DBPassword&quot; },
&quot;DBSubnetGroupName&quot; : { &quot;Ref&quot; : &quot;MyDBSubnetGroup&quot; },
&quot;DBSecurityGroups&quot; : [ { &quot;Ref&quot; : &quot;MyDBSecurityGroup&quot; } ]
&quot;Outputs&quot; : {
&quot;JDBCConnectionString&quot;: {
"Description" : "JDBC connection string for database",
"Value" : { "Fn::Join": [ "", [ "jdbc:mysql://",
{ &quot;Fn::GetAtt&quot;: [ &quot;MyDB&quot;, &quot;Endpoint.Address&quot; ] },
{ &quot;Fn::GetAtt&quot;: [ &quot;MyDB&quot;, &quot;Endpoint.Port&quot; ] },
{ &quot;Ref&quot;: &quot;DBName&quot; }]]}
Resource specifications such as these can be utilized to script the creation and configuration of any AWS resource and create simple to complex architectures. More examples are available on the Amazon AWS website, linked in the references below.


During the creation of an EC2 instance, you set the ssh keys for the instance so that you can ssh into Liferay or any other software on the EC2 instance, either directly if the EC2 instance has an Elastic IP address or via a Bastion (internet access) server. Access control and connectivity can be controlled via the security groups and network access control lists that are part of an AWS environment configuration.
Installing Liferay, whether as a bundle with Tomcat or Glassfish, or unbundled on an EC2 instance is no different from installing on a local Linux machine or VM.

Using S3

Amazon's S3 (Simple Storage Service) can be used with EC2 to store artifacts such as database dumps or tar files of a Liferay document library created by backup scripts. Additionally, a Liferay distribution tar file could be placed in an S3 bucket and pulled down and installed onto an EC2 instance via a script run as part of the Cloud Formation process.


Amazon's AWS services and tools provide a useful means for quickly setting up development, testing and production environments for deploying web applications such as Liferay without the investment of in-house servers and system administrators, facilitating rapid development and deployment.


Amazon AWS
Getting Started With EC2
EC2 Documentation
Cloud Formation User Guide
VPC Documentation
RDS Documentation

TAGS: Software Development, Software Solutions

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Subscribe to Our Newsletter

Recent Blog Posts