Subhasish Sahu
How to deploy SpringBoot App on AWS EC2 instance and retrieve key/value pair from AWS Secret Manager
Updated: May 25, 2020
Pre - requisite :
AWS Account
Java 1.8 and above
Putty
WinSCP
IntelliJ Idea IDE
Logon to AWS site ( https://console.aws.amazon.com/ )
Select EC2 instance

Click on Launch Instance










Download and keep it in a proper local folder


Your Instance is created

Create Secret Manager in AWS
Select Secret Manager from Services in AWS

Click on Store a New Secret








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.





Open Putty

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


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




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

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




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

Login as ec2-user




After successfully updation, login as super user

Install java 1.8

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


Open any IDE and create a sample spring boot application .
SourceCode : https://github.com/subhasish23sahu/springboot-aws-secret-manager-master
Download sourcecode and build it


Region can be determined from AWS site



To transfer the jar(application) we can use WINSCP




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

If you get bellow error:

Then Attach an IAM role to the EC2 instance



subhasishdemo is the IAM created

Go back to EC2 Instance


Allow port in Security Group--> Inbound Rules

Go back to putty and run springboot application


URL : <IPv4 Public IP>:<port>/<resourcepath>
Domain name can be formed using IPv4 Public IP mentioned in EC2 instance

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