-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
67 lines (47 loc) · 1.59 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
61
62
63
64
65
66
67
pipeline {
agent any
parameters {
choice(name: 'aws_region',
choices: ['eu-west-1', 'eu-west-2', 'eu-central-1', 'us-east-1'],
description: 'Where would you like to deploy your VPC?.. Examples eu-west-1, eu-west-2')
}
environment {
AWS_DEFAULT_REGION = "${params.aws_region}"
AWS_ACCESS_KEY_ID = "${JKS_AWS_ACCESS_KEY}"
AWS_SECRET_ACCESS_KEY = "${JKS_AWS_SECRET_ACCESS}"
TF_HOME = tool('terraform-0.12.12')
TF_IN_AUTOMATION = "true"
PATH = "$TF_HOME:$PATH"
}
stages {
stage('params') {
steps {
echo "You Selected: ${params.aws_region}"
}
}
stage ('Checkout Repo') {
steps {
git branch: 'master',
credentialsId: 'e9ec2f9d-fa29-456d-b4e8-1f4001b4d4a2',
url: 'https://github.com/jagho-jcs/aws-devops-sample-terraform-module-project.git'
}
}
stage ('Set Terraform Path') {
steps {
// Output Terraform Version
sh "terraform -version"
}
}
stage ('Provision VPC') {
steps {
dir ('example')
{
sh "terraform init"
sh "terraform get"
sh 'terraform apply -var="region=${aws_region}" \
-var-file=jcs_example_vpc_london.tfvars -auto-approve'
}
}
}
}
}