Employee-Management-Fullstack-App

AWS Production Deployment

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).

What Gets Provisioned

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.

Prerequisites

Quick Start

  1. Set Terraform variables
    • Copy aws/terraform/example.tfvars (create this file) or create your own terraform.tfvars in aws/terraform/.
    • At minimum provide a strong 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
      
  2. Deploy the infrastructure
    cd aws/terraform
    terraform init
    terraform plan
    terraform apply
    
  3. Grab the connection details
    terraform output
    terraform output eks_update_kubeconfig_command
    
  4. Configure kubectl
    aws eks update-kubeconfig --region <region> --name <cluster_name>
    
  5. Build & push container images
    # 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>
    
  6. Create Kubernetes secrets for database connectivity
    # 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).

  7. Update Kubernetes manifests
    • Set the backend deployment image to the pushed ECR tag (port 8080).
    • Set the frontend deployment image to the pushed ECR tag (port 80) or deploy the static build via another mechanism.
    • Inject SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME, and SPRING_DATASOURCE_PASSWORD using the secret created above.
    • Apply manifests:
      kubectl apply -f ../../kubernetes
      

Managing the Database

Scaling & Resilience

Clean Up

Terraform enables deletion protection on the database. To tear everything down:

  1. Set db_deletion_protection = false in terraform.tfvars and run terraform apply.
  2. Run terraform destroy when you are ready to delete the stack.
  3. Manually remove any remaining ECR images or S3 assets if you created additional resources.

Variables Recap

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.

Security Notes

Extending the Stack


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.