1. Deploy Spring Boot in AWS
Option 1: AWS Elastic Beanstalk The easiest way → takes your jar/war and deploys it. 📌 Command:
eb init -p java-17 demo-app
eb create demo-env
eb deployOption 2: AWS ECS (Containers)
- Weave a Docker image.
- Upload to Amazon Elastic Container Registry (ECR):
aws ecr create-repository --repository-name demo-app
docker tag demo-app:latest <aws-account-id>.dkr.ecr.region.amazonaws.com/demo-app:latest
docker push <aws-account-id>.dkr.ecr.region.amazonaws.com/demo-app:latest- Run in ECS (Fargate).
Option 3: AWS EKS (Kubernetes)
- Spin up an EKS cluster.
- Deploy as a standard Kubernetes manifest (see DevOps block).
2. Deploy Spring Boot in GCP
Option 1: Google App Engine 📌 app.yaml:
runtime: java17
instance_class: F1Upload:
gcloud app deployOption 2: Google Cloud Run (Serverless Containers)
- Takes a Docker image.
- Scales from 0 to N (zero-cost, while there is no traffic).
gcloud run deploy demo-app --image gcr.io/PROJECT-ID/demo-app --platform managedOption 3: GKE (Google Kubernetes Engine)
- Deploy as a standard K8s + Helm.
3. Deploy Spring Boot in Azure
Option 1: Azure App Service
- Upload a jar/Docker image.
- Azure runs it.
Option 2: Azure AKS (Kubernetes)
- Equivalent to GKE/EKS.
- Helm charts work out of the box.
Option 3: Azure Functions (Serverless)
- If the application can be broken down into functions → Spring Cloud Function.
4. Kubernetes Helm Charts
📌 Helm = package manager for Kubernetes.
📄 Chart.yaml:
apiVersion: v2
name: demo-app
version: 0.1.0📄 values.yaml:
replicaCount: 2
image:
repository: demo-app
tag: latest
service:
type: LoadBalancer
port: 80📌 Installation: helm install demo ./charts/demo-app
5. Spring Cloud Config
📌 For centralized configuration (one configuration for multiple services).
Config Server 📄 Dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>📄 Launch:
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}📄 application.yml:
spring:
cloud:
config:
server:
git:
uri: https://github.com/my-org/config-repoClient 📄 Dependency:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>📄 bootstrap.yml:
spring:
application:
name: demo-app
cloud:
config:
uri: http://localhost:8888Now configurations are taken from the git repository of configs.
6. Serverless + Spring
📌 You can write lambdas using Spring Cloud Function.
Example AWS Lambda:
@Bean
public Function<String, String> uppercase() {
return value -> value.toUpperCase();
}📌 Deploy to AWS Lambda via the spring-cloud-function-adapter-aws adapter.
7. CI/CD in the Cloud
- AWS → CodePipeline / CodeBuild.
- GCP → Cloud Build.
- Azure → DevOps Pipelines.
- GitHub Actions can be used everywhere (the most popular option).
8. Best Practices
- ✅ For MVP → Heroku, App Engine, Cloud Run (fast and simple).
- ✅ For enterprise → Kubernetes (EKS/GKE/AKS) + Helm + Spring Cloud Config.
- ✅ Store secrets in Vault / Secret Manager / Kubernetes Secrets.
- ✅ Separate environments (dev/test/prod) and configurations.
- ✅ Use an observability stack (Prometheus + Grafana + Loki/ELK).
- ✅ Make blue-green or canary deploys → safe updates.