This folder contains a Terraform-based blueprint that provisions the AWS infrastructure required to run the Employee Management System in a production setting. It focuses on providing a secure, scalable foundation that aligns with the code in this repository (React frontend, Spring Boot backend, MySQL persistence, and containerized workloads).
flowchart LR
subgraph VPC [VPC]
subgraph PrivateSubnets [Private Subnets]
EKS[EKS Managed Node Group]
RDS[(Amazon RDS MySQL)]
end
subgraph PublicSubnets [Public Subnets]
NAT[NAT Gateway]
end
end
ECR[(Amazon ECR Repos)]
Secrets[(AWS Secrets Manager)]
ECR -->|Push Docker images| EKS
Secrets -->|Mount via Kubernetes Secret| EKS
EKS -->|JDBC traffic 3306| RDS
VPC & networking
Compute platform
Data layer
Container registry
The stack intentionally keeps MongoDB/DocumentDB optional because the current Spring Boot code does not persist to Mongo. Add a DocumentDB module only if you introduce Mongo-backed repositories.
aws/terraform/example.tfvars
(create this file) or create your own terraform.tfvars
in aws/terraform/
.db_password
. Example:
project_name = "employee-management"
environment = "prod"
aws_region = "us-east-1"
db_password = "changeMeSuperSecure123!"
single_nat_gateway = false # optional, enable one NAT per AZ for higher availability
cd aws/terraform
terraform init
terraform plan
terraform apply
terraform output
terraform output eks_update_kubeconfig_command
aws eks update-kubeconfig --region <region> --name <cluster_name>
# Backend
docker build -t $(terraform output -raw backend_ecr_repository):<tag> ../../backend
docker push $(terraform output -raw backend_ecr_repository):<tag>
# Frontend (serves the React production build)
docker build -t $(terraform output -raw frontend_ecr_repository):<tag> ../../frontend
docker push $(terraform output -raw frontend_ecr_repository):<tag>
# Fetch the secret from Secrets Manager
aws secretsmanager get-secret-value \
--secret-id $(terraform output -raw mysql_secret_name) \
--query 'SecretString' --output text > mysql-creds.json
kubectl create secret generic mysql-credentials \
--from-file=mysql-creds.json=mysql-creds.json \
--namespace default
rm mysql-creds.json
Update kubernetes/backend-deployment.yaml
to mount these credentials as environment variables (e.g., via envFrom.secretRef
).
SPRING_DATASOURCE_URL
, SPRING_DATASOURCE_USERNAME
, and SPRING_DATASOURCE_PASSWORD
using the secret created above.kubectl apply -f ../../kubernetes
db_backup_retention
days (default 14). Adjust the variable as needed.db_maintenance_window
. Terraform keeps the setting consistent across terraform runs.db_multi_az
defaults to true
to give automatic failover. Disable only for dev/test environments.aws/terraform/secrets.tf
writes credentials to Secrets Manager. Rotate the password by updating db_password
and reapplying Terraform.eks_node_desired
, eks_node_min
, and eks_node_max
in terraform.tfvars
to scale compute capacity.db_allocated_storage
and db_max_allocated_storage
to grow storage limits.single_nat_gateway
to false
to provision one NAT gateway per AZ for higher availability.Terraform enables deletion protection on the database. To tear everything down:
db_deletion_protection = false
in terraform.tfvars
and run terraform apply
.terraform destroy
when you are ready to delete the stack.Variable | Purpose | Default |
---|---|---|
project_name |
Prefix for resource names and tags | employee-management |
environment |
Environment identifier appended to names | prod |
aws_region |
Deployment region | us-east-1 |
availability_zone_count |
Number of AZs to target | 3 |
db_password |
Required MySQL admin password | none |
db_multi_az |
Enable Multi-AZ for RDS | true |
single_nat_gateway |
Use one NAT gateway across AZs | true |
ecr_image_retain_count |
Number of Docker images to retain | 10 |
See aws/terraform/variables.tf
for the full list and documentation.
aws secretsmanager rotate-secret
or Terraform updates).The provided Terraform modules have been tested for syntactic correctness, but always review plan outputs and adjust to your organization’s requirements before deploying to a live AWS account.
[!TIP] This one-click deployment will allow you to experiment with the Employee Management System in a production-like environment. Feel free to set up and deploy your own instance of the full stack application using this guide. However, for any serious usage, ensure you understand the security and cost implications of running resources in AWS.