File tree Expand file tree Collapse file tree 5 files changed +128
-1
lines changed
microservices/HelloService/terraform Expand file tree Collapse file tree 5 files changed +128
-1
lines changed Original file line number Diff line number Diff line change 1010 pull_request :
1111 branches : [ main ]
1212 paths :
13- - ' HelloService/**'
13+ - ' microservices/ HelloService/**'
1414jobs :
1515 build :
1616 defaults :
5959 docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
6060 docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
6161 echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
62+ terraform :
63+ needs : build
64+ name : Terraform Deployment
65+ runs-on : [ ubuntu-latest ]
66+ defaults :
67+ run :
68+ working-directory : ./microservices/HelloService/terraform
69+ strategy :
70+ max-parallel : 1
71+ env :
72+ aws_secret_access_key : ${{ secrets.AWS_ACCESS_KEY_ID }}
73+ aws_access_key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
74+ steps :
75+ - uses : actions/checkout@v3
76+ - name : Configure AWS credentials
77+ uses : aws-actions/configure-aws-credentials@v1
78+ with :
79+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
80+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
81+ aws-region : us-east-1
82+ - uses : hashicorp/setup-terraform@v1
83+ with :
84+ terraform_wrapper : false
85+ - name : Terraform Init
86+ id : init
87+ run : |
88+ rm -rf .terraform
89+ terraform init
90+ - name : Terraform Plan
91+ id : plan
92+ run : |
93+ terraform plan
94+ - name : Terraform apply
95+ if : github.ref == 'refs/heads/main'
96+ id : apply
97+ run : |
98+ terraform apply --auto-approve=true
6299
63100
64101
Original file line number Diff line number Diff line change 1+ data "aws_eks_cluster" "cluster" {
2+ name = " eks-1" # Change this to your EKS cluster name
3+ }
4+
5+ data "aws_eks_cluster_auth" "cluster" {
6+ name = data. aws_eks_cluster . cluster . name
7+ }
Original file line number Diff line number Diff line change 1+ resource "helm_release" "myapp" {
2+ name = " hello-svc"
3+ repository = " https://devops4solutions.github.io/springboot-helm-chart/" # Using the published Helm repo
4+ chart = " springboot"
5+ namespace = " app1" # Change as per your setup
6+ version = " 0.1.5" # Use the correct version from index.yaml
7+ create_namespace = " true"
8+ values = [
9+ file (" ${ path . module } /values_hello.yaml" ) # Optional: Use custom values file
10+ ]
11+ }
Original file line number Diff line number Diff line change 1+ provider "aws" {
2+ region = " us-east-1"
3+
4+ }
5+
6+ provider "helm" {
7+ kubernetes {
8+ host = data. aws_eks_cluster . cluster . endpoint
9+ token = data. aws_eks_cluster_auth . cluster . token
10+ cluster_ca_certificate = base64decode (data. aws_eks_cluster . cluster . certificate_authority [0 ]. data )
11+ }
12+ }
13+
14+
15+
16+ terraform {
17+ required_providers {
18+ helm = {
19+ source = " hashicorp/helm"
20+ version = " 2.17.0"
21+ }
22+ kubectl = {
23+ source = " bnu0/kubectl"
24+ version = " 0.27.0"
25+ }
26+ }
27+
28+ backend "s3" {
29+ region = " us-east-1"
30+ bucket = " devops4solutions-terraform"
31+ key = " eks/helloservice.tfstate"
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ replicaCount : 1
2+ image :
3+ repository : public.ecr.aws/w0f5g4k6/hello-svc
4+ pullPolicy : IfNotPresent
5+ service :
6+ type : ClusterIP
7+ port : 80
8+ name : hello
9+ ingress :
10+ enabled : true
11+ className : " alb"
12+ annotations :
13+ alb.ingress.kubernetes.io/scheme : internet-facing
14+ alb.ingress.kubernetes.io/target-type : ip
15+ alb.ingress.kubernetes.io/healthcheck-path : /hello
16+ alb.ingress.kubernetes.io/group.name : myapp
17+ hosts :
18+ - host : hello.com
19+ paths :
20+ - path : /hello
21+ pathType : Prefix
22+ livenessProbe :
23+ httpGet :
24+ path : /hello
25+ port : http
26+ readinessProbe :
27+ httpGet :
28+ path : /hello
29+ port : http
30+ serviceAccount :
31+ create : true
32+ automount : true
33+ annotations : {}
34+ name : " "
35+ autoscaling :
36+ enabled : false
37+ minReplicas : 1
38+ maxReplicas : 100
39+ targetCPUUtilizationPercentage : 80
You can’t perform that action at this time.
0 commit comments