Java Spring Boot in the AWS Cloud: Understanding EC2 and RDS Deployments with Terraform. Part 1
This post is about how to deploy a Java application using RDS and EC2 :
We want to deploy a Spring Boot application, but we want to be able to replicate it for our customers in different environments in a repetitive way.

Architecture diagram
- AWS Region: AWS Region is a geographical area where AWS resources are hosted. Each region is made up of multiple availability zones.
- AWS Availability Zone: An Availability Zone is a physically separate data center with redundant power, networking, and cooling. AWS resources can be deployed across multiple availability zones for high availability and fault tolerance.
- AWS Internet Gateway: An Internet Gateway is a horizontally scalable, highly available VPC component that allows communication between instances in your VPC and the internet.
- AWS Route Table: A Route Table is a set of rules that determines where network traffic is directed in a VPC. It contains a set of routes and associated destination network prefixes.
- AWS Security Group: A Security Group acts as a virtual firewall for your instances to control inbound and outbound traffic. It operates at the instance level and can have rules that allow or deny traffic based on protocols, ports, and source/destination IP addresses.
- AWS EC2: Amazon Elastic Compute Cloud (EC2) is a web service that provides resizable compute capacity in the cloud. It allows you to provision virtual servers (instances) and run a wide range of applications.
- AWS RDS: Amazon Relational Database Service (RDS) is a managed database service that makes it easy to configure, manage, and scale a relational database in the cloud. It supports multiple database engines like MySQL, PostgreSQL, Oracle, etc.
- Spring Boot App: Spring Boot is a framework that simplifies the development of Java applications. It provides a set of tools and conventions to quickly build standalone, production-grade Spring-based applications.
How to connect each component.
1. Setup your AWS cliente credentials









2. Allow Terraform to read those credentials from your OS environment.
AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY


- Download AWS cli and install.
- Follow the rules from https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
- Setup AWS CLI using AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
- Check that everything is running properly with the command below.
- PowerShell : Execute aws sts get-caller-identity


