-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
63 lines (52 loc) · 1.17 KB
/
gulpfile.js
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
const { series, task } = require('gulp')
const shell = require('gulp-shell')
const minimist = require('minimist')
const knownOptions = {
string: 'env',
default: { env: process.env.ENV || 'dev' }
}
// get environment and set working directory
const options = minimist(process.argv.slice(2), knownOptions)
const env = options.env
process.chdir('./env/' + env)
const tfvarFilePath = env + '.tfvars'
task('terraform', series(
shell.task([
'terraform fmt',
'terraform workspace select ' + env,
'terraform validate',
'terraform apply -var-file="' + tfvarFilePath + '"'
]))
)
task('terraform-init', series(
shell.task([
'terraform init',
'terraform workspace new ' + env
]))
)
task('terraform-destroy', series(
shell.task([
'terraform destroy -var-file="' + tfvarFilePath + '"'
])
))
task('terraform-output', series(
shell.task([
'terraform output'
])
))
exports.build = task('infra',
series(
task('terraform')
))
exports.build = task('init',
series(
task('terraform-init')
))
exports.build = task('destroy',
series(
task('terraform-destroy')
))
exports.build = task('output',
series(
task('terraform-output')
))