Terraform
Cloud, DevOps & Cloud Solutions

Hybris on AWS Using Terraform

Terraform :-
Terraform enables you to safely and predictably create, change, and improve
infrastructure. It is an open source tool that codifies APIs into declarative
configuration files that can be shared amongst team members, treated as code, edited,
reviewed, and versioned.

Hybris Installation:-

Installation of Hybris totally require two files:-

1.Installation.sh
2.awsdeploy.tf

Installation Shell script:-

1.Create user and give all the permissions required using following commands:-
sudo useradd hybrisadmin
chown -R root:root hybris
2.Install all the dependencies required for hybris installation
yum install java -y
yum install git -y
yum install wget -y
3.Upload the Hybris Installation zip file into the AWS S3 Bucket and pull it using wget
command on to the linux machine and unzip it.
wget https://s3-ap-southeast-1.amazonaws.com/hybrisinstallation/HYBRISCOMM6500P_3-
80003045.ZIP
unzip HYBRISCOMM6500P_3-80003045.ZIP -d HYBRISCOMM6500P_3-80003045
4.Setup the Ant Environment which is used for building the projects in hybris.
. ./setantenv.sh
ant clean all
cd ~
chown -R root:root hybrisfolder/HYBRISCOMM6500P_3-80003045
ant deploy
5.Start the hybris server using the shell script in the platform folder of hybris.
cd hybrisfolder/HYBRISCOMM6500P_3-80003045/hybris/bin/platform
./hybrisserver.sh
Installation.sh:-
#!/bin/bash
cd ~
sudo su
sudo su
cd /opt
mkdir hybris
sudo useradd hybrisadmin
chown -R root:root hybris
yum update -y
yum install java -y
yum install git -y
yum install wget -y
mkdir hybrisfolder
cd hybrisfolder
wget https://s3-ap-southeast-1.amazonaws.com/hybrisinstallation/HYBRISCOMM6500P_3-
80003045.ZIP
unzip HYBRISCOMM6500P_3-80003045.ZIP -d HYBRISCOMM6500P_3-80003045
cd HYBRISCOMM6500P_3-80003045/hybris/bin/platform
. ./setantenv.sh
ant clean all
cd ~
chown -R root:root hybrisfolder/HYBRISCOMM6500P_3-80003045
ant deploy
cd hybrisfolder/HYBRISCOMM6500P_3-80003045/hybris/bin/platform
./hybrisserver.sh

Terraform Template:-

1.All the documents required for aws in terraform are available at:-
https://www.terraform.io/docs/providers/aws/
2.At AWS Account, Copy all the required credentials like access_key,secret_key
at IAM Console which will be used in the template.
3.Shell script and terraform file should be in the same folder.
4.Pass the shell script using the user_data parameter in EC2 Instance.

awsdeploy.tf:-

provider “aws” {
access_key = “AKIAJKNGJXEUHG2A4X7Q”
secret_key = “cHTvQ+8DuCrTlIZ/rkOAMo7HJEic8xrkYGbzhdpS”
region = “us-east-1”
}
resource “aws_instance” “example1″ {
count=”2”
ami = “ami-467ca739”
instance_type = “t2.micro”
key_name = “myhybirskey”
tags {
Name = “terraform-instance”}
user_data = “${file(“installation.sh”)}”
}

resource “aws_elb” “web” {
name = “terraform-example-elb”
instances = [“${aws_instance.example1.*.id}”]
availability_zones = [“us-east-1a”]
listener {
instance_port = 80
instance_protocol = “http”
lb_port = 80
lb_protocol = “http”
}
}

 

Terraform file Execution:-
1.The terraform init command should be run by any member of your team on any Terraform
configuration as a first step. It is safe to execute multiple times and performs all the
setup actions required for a Terraform environment, including initializing the backend.
2.The terraform plan command is used to create an execution plan. Terraform performs a
refresh, unless explicitly disabled, and then determines what actions are necessary to
achieve the desired state specified in the configuration files.
3.The terraform apply command is used to apply the changes required to reach the desired
state of the configuration, or the pre-determined set of actions generated by a
terraform plan execution plan.

About The Author

Leave a Reply

*