{"id":84451,"date":"2025-08-01T15:42:23","date_gmt":"2025-08-01T10:12:23","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=84451"},"modified":"2025-09-02T04:31:34","modified_gmt":"2025-09-01T23:01:34","slug":"spring-boot-deployment-on-aws-using-ec2-and-rds","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/spring-boot-deployment-on-aws-using-ec2-and-rds\/","title":{"rendered":"Spring Boot Application Deployment on AWS Using EC2 and RDS"},"content":{"rendered":"\n<p>Deploying a Spring Boot application on AWS using EC2 and RDS helps you move from local testing to a real-world, scalable backend. When you connect your application with a managed MySQL database in RDS and run it on EC2, you bring flexibility and reliability to your project. This guide covers every essential step, from packaging your app to running it live in the cloud, making sure you understand both the technical actions and the reasons behind them.&nbsp;<\/p>\n\n\n\n<p>If you want a smooth transition to cloud deployment, this walkthrough gives you practical solutions for Spring Boot and AWS integration.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What You\u2019ll Learn<\/strong><\/h2>\n\n\n\n<ul>\n<li>How to set up a Spring Boot application for deployment.<br><\/li>\n\n\n\n<li>How to create and configure an Amazon RDS instance.<br><\/li>\n\n\n\n<li>How to launch and configure an EC2 instance.<br><\/li>\n\n\n\n<li>How to deploy your .jar file and connect it to the RDS database.<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h2>\n\n\n\n<p>Before we begin, ensure you have:<\/p>\n\n\n\n<ul>\n<li>An active <strong><a href=\"https:\/\/www.guvi.in\/blog\/guide-for-amazon-web-services\/\" target=\"_blank\" rel=\"noreferrer noopener\">AWS<\/a> Account<\/strong>.<br><\/li>\n\n\n\n<li>A working <strong>Spring Boot<\/strong> application with MySQL configuration.<br><\/li>\n\n\n\n<li><strong>AWS CLI<\/strong> installed (optional but useful).<br><\/li>\n\n\n\n<li>A <strong>.pem key pair<\/strong> to access EC2 via SSH.<br><\/li>\n\n\n\n<li>Maven is installed to build the .jar.<br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><strong>Spring Boot Application Deployment on AWS Using EC2 and RDS<\/strong><\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-1200x630.png\" alt=\"\" class=\"wp-image-86234\" srcset=\"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-1200x630.png 1200w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-300x157.png 300w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-768x403.png 768w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-1536x806.png 1536w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-2048x1075.png 2048w, https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/image-12-150x79.png 150w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Prepare Your Spring Boot App<\/strong><\/h3>\n\n\n\n<p><strong>1.1 Build Your Project<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>mvn clean install<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>This will generate a .jar file in the target\/ directory.<\/p>\n\n\n\n<p><strong>1.2 Configure <\/strong><strong>application.properties<\/strong><strong><br><\/strong> Update the following fields:<\/p>\n\n\n\n<p>properties<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>spring.datasource.url=jdbc:mysql:\/\/&lt;RDS-ENDPOINT&gt;:3306\/&lt;DATABASE&gt;<br>spring.datasource.username=&lt;USERNAME&gt;<br>spring.datasource.password=&lt;PASSWORD&gt;<br>spring.jpa.hibernate.ddl-auto=update<br><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Set Up Amazon RDS (MySQL)<\/strong><\/h3>\n\n\n\n<p><strong>2.1 Navigate to RDS Console \u2192 Databases \u2192 Create Database<\/strong><\/p>\n\n\n\n<ul>\n<li>Engine: <strong>MySQL<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Template: <strong>Free Tier<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Set <strong>username<\/strong> and <strong>password<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Enable <strong>public access<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Select or create a new <strong>VPC Security Group<\/strong><strong><br><\/strong><\/li>\n<\/ul>\n\n\n\n<p><strong>2.2 Modify the Security Group<\/strong><\/p>\n\n\n\n<ul>\n<li>Add an <strong>inbound rule<\/strong>:<br>\n<ul>\n<li>Type: MySQL\/Aurora<br><\/li>\n\n\n\n<li>Port: 3306<br><\/li>\n\n\n\n<li>Source: <strong>Your EC2 Security Group<\/strong> or <strong>Your IP<\/strong><strong><br><\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>2.3 Note Down RDS Endpoint<br><\/strong> You\u2019ll need this in your Spring Boot application.properties.<\/p>\n\n\n\n<p><strong>Launch your Java career with Spring Boot expertise! <\/strong>Join our top-rated <a href=\"https:\/\/www.guvi.in\/courses\/web-development\/spring-boot\/?utm_source=organic&amp;utm_medium=medium-blog&amp;utm_campaign=spring-boot-aws-ec2-rds-guide\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/www.guvi.in\/courses\/web-development\/spring-boot\/?utm_source=organic&amp;utm_medium=medium-blog&amp;utm_campaign=spring-boot-aws-ec2-rds-guide\" rel=\"noreferrer noopener\">Spring Boot certification course<\/a> online and start building real-world applications now.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 3: Launch EC2 Instance<\/strong><\/h3>\n\n\n\n<p><strong>3.1 Launch a New Instance<\/strong><\/p>\n\n\n\n<ul>\n<li>OS: <strong>Amazon Linux 2 AMI<\/strong><strong><br><\/strong><\/li>\n\n\n\n<li>Instance type: <strong>t2.micro<\/strong> (free tier)<br><\/li>\n\n\n\n<li>Add key pair for SSH access<br><\/li>\n\n\n\n<li>Add a <strong>new security group<\/strong>:<br>\n<ul>\n<li>SSH (Port 22) \u2013 from your IP<br><\/li>\n\n\n\n<li>Custom TCP (Port 8080) \u2013 from Anywhere (or your IP for security)<br><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>3.2 Connect via SSH<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>chmod 400 your-key.pem<br>ssh -i &#8220;your-key.pem&#8221; ec2-user@&lt;EC2-PUBLIC-IP&gt;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>3.3 Install Java<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>sudo yum update -y<br>sudo amazon-linux-extras enable corretto11<br>sudo yum install java-11-amazon-corretto -y<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Deploy Spring Boot App to EC2<\/strong><\/h3>\n\n\n\n<p><strong>4.1 Upload the JAR<\/strong><strong><br><\/strong> On your local terminal:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>scp -i &#8220;your-key.pem&#8221; target\/app.jar ec2-user@&lt;EC2-PUBLIC-IP&gt;:\/home\/ec2-user\/<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>4.2 Run the Application<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>java -jar app.jar<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Your app should now be accessible at:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><br>http:\/\/&lt;EC2-PUBLIC-IP&gt;:8080\/<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Connect EC2 to RDS<\/strong><\/h3>\n\n\n\n<p>Ensure:<\/p>\n\n\n\n<ul>\n<li>Your EC2 security group allows <strong>outbound access<\/strong>.<br><\/li>\n\n\n\n<li>Your RDS security group allows access from the EC2 security group.<br><\/li>\n<\/ul>\n\n\n\n<p>Once application.properties is set correctly with RDS endpoint, restart the app:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>java -jar app.jar<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Final Verification<\/strong><\/h2>\n\n\n\n<ul>\n<li>Visit your EC2 IP on port 8080.<br><\/li>\n\n\n\n<li>Test database-related functionality.<br><\/li>\n\n\n\n<li>Use tools like <strong>Postman<\/strong> or curl to verify endpoints.<br><\/li>\n\n\n\n<li>Use <strong>MySQL Workbench<\/strong> to connect to your RDS database for direct inspection.<br><br><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Setting up a Spring Boot application on AWS using EC2 and RDS lays the groundwork for a backend that can scale and adjust as your user base grows. The clear separation between your compute and database layers creates space for better security, easier maintenance, and a path toward high availability as your project develops.&nbsp;<\/p>\n\n\n\n<p>Testing each step along the way, from SSH access to endpoint verification, helps ensure that your application is both robust and ready to support new features. Once you experience a cloud-based deployment that connects cleanly with a managed database, you will start seeing new possibilities for improving performance and reliability in every update that follows.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deploying a Spring Boot application on AWS using EC2 and RDS helps you move from local testing to a real-world, scalable backend. When you connect your application with a managed MySQL database in RDS and run it on EC2, you bring flexibility and reliability to your project. This guide covers every essential step, from packaging [&hellip;]<\/p>\n","protected":false},"author":60,"featured_media":86236,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[744],"tags":[],"views":"2651","authorinfo":{"name":"Vaishali","url":"https:\/\/www.guvi.in\/blog\/author\/vaishali\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/Spring-Boot-Application-Deployment-1-300x116.png","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2025\/09\/Spring-Boot-Application-Deployment-1.png","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84451"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/60"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=84451"}],"version-history":[{"count":12,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84451\/revisions"}],"predecessor-version":[{"id":86238,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/84451\/revisions\/86238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/86236"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=84451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=84451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=84451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}