Code Monkey home page Code Monkey logo

khandola_demo_svc's Introduction

Install MySQL + Workbench

Download and install putty

Download and install Git

Create EC2 instance

  • Create EC2 instance using AWS management console

Connect to EC2 instance

You have 2 ways to connect to the newly commissioned EC2 instance.

  1. If you have GIT Bash use the following command:

  2. If you would like to use Putty instead, make sure you convert .pem to .ppk using PuttyGen and follow instruction in the video to connect to running ec2 instance

Install Tomcat 9 on EC2 instance

Once you are connected to the EC2 instance you can use following commands to install Tomcat9 on the instance.

sudo yum install -y java-1.8.0-openjdk.x86_64

sudo groupadd --system tomcat

sudo useradd -d /usr/share/tomcat -r -s /bin/false -g tomcat tomcat

export TOMCAT_VER="9.0.39"

sudo wget https://archive.apache.org/dist/tomcat/tomcat-9/v${TOMCAT_VER}/bin/apache-tomcat-${TOMCAT_VER}.tar.gz

sudo tar xvf apache-tomcat-${TOMCAT_VER}.tar.gz -C /usr/share/

sudo ln -s /usr/share/apache-tomcat-${TOMCAT_VER}/ /usr/share/tomcat

sudo chown -R tomcat:tomcat /usr/share/tomcat

sudo chown -R tomcat:tomcat /usr/share/apache-tomcat-${TOMCAT_VER}/ 

sudo tee /etc/systemd/system/tomcat.service<<EOF
[Unit]
Description=Tomcat Server
After=syslog.target network.target

[Service]
Type=forking
User=tomcat
Group=tomcat

Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment='JAVA_OPTS=-Djava.awt.headless=true'
Environment=CATALINA_HOME=/usr/share/tomcat
Environment=CATALINA_BASE=/usr/share/tomcat
Environment=CATALINA_PID=/usr/share/tomcat/temp/tomcat.pid
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M'
ExecStart=/usr/share/tomcat/bin/catalina.sh start
ExecStop=/usr/share/tomcat/bin/catalina.sh stop

[Install]
WantedBy=multi-user.target
EOF


sudo systemctl enable tomcat

Update to $TOMCAT_HOME/conf/context.xml

<Resource name="jdbc/khandola" 
			  auth="Container" 
			  type="javax.sql.DataSource"
              maxTotal="100" 
			  maxIdle="30" 
			  maxWaitMillis="10000"
              username="khandolauser" 
			  password="s3cr3t2021" 
			  driverClassName="com.mysql.cj.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/khandola_db" />

Setup Aurora Serverless

Connect to Aurora from Local

Create Schema

create database khandola_db; -- Creates the new database;
create user 'khandolauser'@'%' identified by 's3cr3t2021'; -- Creates the user
grant all on khandola_db.* to 'khandolauser'@'%'; -- Gives all privileges to the new user on the newly created database

Create Table

CREATE TABLE `khandola_db`.`employee` (
`id` INT NOT NULL,
`name` VARCHAR(255) NULL,
`role` VARCHAR(255) NULL,
PRIMARY KEY (`id`));

Insert record in the table

  • INSERT INTO khandola_db.employee (id, name, role) VALUES ('1', 'Samir', 'Architect');

List all employees if application created anything

  • select * from employee;

Create new employee

  • curl -v -X POST -H 'Content-type:application/json' -d '{"name": "Samir Shaik", "role": "Technical Architect"}' localhost:8080/khandola-demo-svc/employees

List all employees

  • curl -v localhost:8080/employees | json_pp

List employee with id=1

  • curl -v -X DELETE localhost:8080/employees/1

Update employee with id=1

  • curl -v -X PUT -H 'Content-type:application/json' -d '{"name": "Samir Hymed Shaik", "role": "Technical Architect"}' localhost:8080/employees/1

Start application

  • mvn clean spring-boot:run

khandola_demo_svc's People

Contributors

samirshaik avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.