-
Notifications
You must be signed in to change notification settings - Fork 0
/
orb.yml
115 lines (109 loc) · 3.16 KB
/
orb.yml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
version: 2.1
description: Terraform Orb
# Orb Dependencies
#orbs:
# gcloud: circleci/gcp-cli@1.0.6
executors:
default:
docker:
- image: hashicorp/terraform:light
commands:
create-keyfile:
description: "Persists Google credentials as a file"
steps:
- run: |
echo "$<<parameters.var>>" > <<parameters.file>>
parameters:
file:
description: "File full path to persist the credentials"
type: string
default: ./secrets/service-account.json
var:
description: "Environment variable to retrieve the credentials from"
type: env_var_name
default: GOOGLE_CREDENTIALS
install:
description: "Installs terraform cli"
steps:
- run: |
wget "https://releases.hashicorp.com/terraform/<<parameters.version>>/terraform_<<parameters.version>>_linux_amd64.zip" && \
unzip terraform_*_linux_amd64.zip && \
sudo mv terraform /usr/local/bin/
rm terraform_*_linux_amd64.zip
parameters:
version:
description: "Version of terraform cli to be installed"
type: string
default: "0.12.24"
multi-project-terraform:
description: "Applies terraform command to multiple projects"
steps:
- run:
name: "multi project terraform <<parameters.command>>"
command: |
_pwd=$(pwd)
(
for project_path in <<parameters.path>>/*
do
echo "###############################################"
echo "###### project: $project_path"
echo "###############################################"
echo ""
cd "${_pwd}/${project_path}" || exit
terraform <<parameters.command>> || exit
done
)
parameters:
command:
description: "Terraform command to be executed on all projects"
type: string
path:
description: "path to the projects folder"
type: string
default: projects
jobs:
validate:
description: "Execute terraform validate"
executor: default
steps:
- checkout
- create-keyfile
- run:
name: Print Terraform version
command: |
terraform --version
- multi-project-terraform:
command: init
- multi-project-terraform:
command: validate
check:
description: "Execute terraform plan and fail if state changed"
executor: default
parameters:
cluster:
description: "The Kubernetes cluster name."
type: string
steps:
- checkout
- create-keyfile
- run:
name: Print Terraform version
command: |
terraform --version
- multi-project-terraform:
command: init
- multi-project-terraform:
command: plan -detailed-exitcode
example:
plan-apply:
description: |
"The simplest example of using this Orb. Checks out the code
performs a terraform validate and plan."
usage:
version: 2.1
orbs:
tf: titel-media/terraform@dev:testing-3
workflows:
main:
jobs:
- tf/validate