Skip to content

Commit 0298e41

Browse files
committed
DevOps: Push DevOps-Project-19
* From Scratch to Production: Deploying EKS Clusters and Applications with CI/CD using Jenkins and Terraform Signed-off-by: NotHarshhaa <reddyharshhaa12@gmail.com>
1 parent d2dfd5f commit 0298e41

25 files changed

+1604
-0
lines changed

DevOps-Project-19/Jenkinsfile

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
pipeline{
2+
agent any
3+
environment {
4+
AWS_ACCESS_KEY_ID = credentials('AWS_ACCESS_KEY_ID')
5+
AWS_SECRET_ACCESS_KEY = credentials('AWS_SECRET_ACCESS_KEY')
6+
AWS_DEFAULT_REGION = "us-east-1"
7+
}
8+
stages {
9+
stage('Checkout SCM') {
10+
steps {
11+
script {
12+
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/vishal2505/terraform-eks-cicd.git']])
13+
}
14+
}
15+
}
16+
stage('Initializing Terraform'){
17+
steps {
18+
script {
19+
dir('tf-aws-eks'){
20+
sh 'terraform init'
21+
}
22+
}
23+
}
24+
}
25+
stage('Validating Terraform'){
26+
steps {
27+
script {
28+
dir('tf-aws-eks'){
29+
sh 'terraform validate'
30+
}
31+
}
32+
}
33+
}
34+
stage('Terraform Plan'){
35+
steps {
36+
script {
37+
dir('tf-aws-eks'){
38+
sh 'terraform plan -var-file=variables/dev.tfvars'
39+
}
40+
input(message: "Are you sure to proceed?", ok: "Proceed")
41+
}
42+
}
43+
}
44+
stage('Creating/Destroying EKS Cluster'){
45+
steps {
46+
script {
47+
dir('tf-aws-eks'){
48+
sh 'terraform $action -var-file=variables/dev.tfvars -auto-approve'
49+
}
50+
}
51+
}
52+
}
53+
stage('Deploying Nginx Application') {
54+
steps{
55+
script{
56+
dir('manifest') {
57+
sh 'aws eks update-kubeconfig --name my-eks-cluster'
58+
sh 'kubectl create namespace eks-nginx-app'
59+
sh 'kubectl apply -f deployment.yaml -n eks-nginx-app'
60+
sh 'kubectl apply -f service.yaml -n eks-nginx-app'
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)