forked from ndiforfusi/eks-terraform-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
60 lines (53 loc) · 2.1 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pipeline {
agent { node { label 'terraform-node' } }
parameters {
choice(name: 'deploy_choice', choices:['apply','destroy'],description:'The deployment type')
}
environment {
EMAIL_TO = '[email protected]'
}
stages {
stage('1.Terraform init') {
steps {
echo 'terraform init phase'
sh 'terraform init'
}
}
stage('2.Terraform plan') {
steps {
echo 'terraform plan phase'
sh 'AWS_REGION=us-west-2 terraform plan'
}
}
stage('3.Manual Approval') {
input {
message "Should we proceed?"
ok "Yes, we should."
parameters{
choice (name: 'Manual_Approval', choices: ['Approve','Reject'], description: 'Approve or Reject the deployment')
}
}
steps {
echo "Deployment ${Manual_Approval}"
}
}
stage('4.Terraform Deploy') {
steps {
echo 'Terraform ${params.deploy_choice} phase'
sh "AWS_REGION=us-west-2 terraform ${params.deploy_choice} -target=module.vpc -target=module.eks --auto-approve"
sh("""scripts/update-kubeconfig.sh""")
sh("""scripts/observerbility-addon.sh""")
sh "AWS_REGION=us-west-2 terraform ${params.deploy_choice} --auto-approve"
}
}
stage ('5. Email Notification') {
steps {
mail bcc: '[email protected]', body: '''Terraform deployment is completed.
Let me know if the changes look okay.
Thanks,
Dominion System Technologies,
+1 (313) 413-1477''', cc: '[email protected]', from: '', replyTo: '', subject: 'Terraform Infra deployment completed!!!', to: '[email protected]'
}
}
}
}