top of page

How to deploy SpringBoot App on AWS EC2 instance and retrieve key/value pair from AWS Secret Manager

  • Writer: Subhasish Sahu
    Subhasish Sahu
  • Apr 21, 2020
  • 1 min read

Updated: May 25, 2020


Pre - requisite :


  1. AWS Account

  2. Java 1.8 and above

  3. Putty

  4. WinSCP

  5. IntelliJ Idea IDE


Logon to AWS site ( https://console.aws.amazon.com/ )


Select EC2 instance


ree

Click on Launch Instance



ree

ree

ree

ree

ree

ree

ree

ree

ree

ree

Download and keep it in a proper local folder



ree

ree

Your Instance is created

ree


Create Secret Manager in AWS


Select Secret Manager from Services in AWS



ree

Click on Store a New Secret


ree

ree

ree

ree

ree

ree

ree

ree


Connect to AWS Linux


Download Putty : https://www.putty.org/


Open PuttyGen from you taskbar and load the key pair name downloaded during creation of EC2 instance.



ree

ree

ree

ree

ree

Open Putty



ree

Enter your public DNS name in Host  Name(or IP Address) Text Box which you will get fro EC2 instance as below


ree


ree

After entering the Host name, we need to load the private ppk key



ree

ree

ree

ree

If you don't assign/allow SSH port in your EC2 instance ,you will get below error:


ree

For this click on security group as below in your EC2 instance newly created


ree

ree

ree

ree

Now load the saved aws session from putty and you will be able to login now.



ree

Login as ec2-user



ree

ree

ree

ree

After successfully updation, login as super user

ree

Install java 1.8


ree

After successfully updation, you will be able to see latest java version


ree

ree

Open any IDE and create a sample spring boot application .


Download sourcecode and build it


ree

ree

Region can be determined from AWS site


ree

ree

ree

To transfer the jar(application) we can use WINSCP


ree

ree

ree

ree

Give read and write option to the jar : chmod 777 *


ree

If you get bellow error:


ree

Then Attach an IAM role to the EC2 instance


ree

ree

ree

subhasishdemo is the IAM created

ree

Go back to EC2 Instance


ree

ree

Allow port in Security Group--> Inbound Rules



ree

Go back to putty  and run springboot application



ree

ree

URL :   <IPv4 Public IP>:<port>/<resourcepath>


Domain name can be formed using IPv4 Public IP mentioned in EC2 instance



ree

Once you hit the url, you will be able to see the key/value retrieved from Secret Manager.



ree


Comments


bottom of page