File tree Expand file tree Collapse file tree 9 files changed +125
-79
lines changed
sentinel-policies-scripts Expand file tree Collapse file tree 9 files changed +125
-79
lines changed Original file line number Diff line number Diff line change 26
26
.vscode /
27
27
28
28
# Ignore Any Generated JSON Files
29
+ operations /automation-script /apply.json
30
+ operations /automation-script /configversion.json
31
+ operations /automation-script /run.template.json
29
32
operations /automation-script /run.json
30
- operations /automation-script /variables.json
33
+ operations /automation-script /variable.template.json
34
+ operations /automation-script /variable.json
35
+ operations /automation-script /workspace.template.json
31
36
operations /automation-script /workspace.json
32
- operations /sentinel-policies-scripts /create-policy.json
37
+ operations /sentinel-policies-scripts /create-policy.template.json
38
+ operations /sentinel-policies-scripts /create-policy.json
39
+ operations /variable-scripts /variable.template.json
40
+ operations /variable-scripts /variable.json
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 109
109
echo " Tarring configuration directory."
110
110
tar -czf ${config_dir} .tar.gz -C ${config_dir} --exclude .git .
111
111
112
+ # Write out workspace.template.json
113
+ cat > workspace.template.json << EOF
114
+ {
115
+ "data":
116
+ {
117
+ "attributes": {
118
+ "name":"placeholder",
119
+ "terraform-version": "0.11.14"
120
+ },
121
+ "type":"workspaces"
122
+ }
123
+ }
124
+ EOF
125
+
126
+ # Write out configversion.json
127
+ cat > configversion.json << EOF
128
+ {
129
+ "data": {
130
+ "type": "configuration-versions",
131
+ "attributes": {
132
+ "auto-queue-runs": false
133
+ }
134
+ }
135
+ }
136
+ EOF
137
+
138
+ # Write out variable.template.json
139
+ cat > variable.template.json << EOF
140
+ {
141
+ "data": {
142
+ "type":"vars",
143
+ "attributes": {
144
+ "key":"my-key",
145
+ "value":"my-value",
146
+ "category":"my-category",
147
+ "hcl":my-hcl,
148
+ "sensitive":my-sensitive
149
+ }
150
+ },
151
+ "filter": {
152
+ "organization": {
153
+ "username":"my-organization"
154
+ },
155
+ "workspace": {
156
+ "name":"my-workspace"
157
+ }
158
+ }
159
+ }
160
+ EOF
161
+
162
+ # Write out run.template.json
163
+ cat > run.template.json << EOF
164
+ {
165
+ "data": {
166
+ "attributes": {
167
+ "is-destroy":false
168
+ },
169
+ "type":"runs",
170
+ "relationships": {
171
+ "workspace": {
172
+ "data": {
173
+ "type": "workspaces",
174
+ "id": "workspace_id"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ }
180
+ EOF
181
+
182
+ # Write out apply.json
183
+ cat > apply.json << EOF
184
+ {"comment": "apply via API"}
185
+ EOF
186
+
112
187
# Set name of workspace in workspace.json
113
188
sed " s/placeholder/${workspace} /" < workspace.template.json > workspace.json
114
189
@@ -358,4 +433,14 @@ if [[ "$applied" == "true" ]]; then
358
433
359
434
fi
360
435
436
+ # Remove json files
437
+ rm apply.json
438
+ rm configversion.json
439
+ rm run.template.json
440
+ rm run.json
441
+ rm variable.template.json
442
+ rm variable.json
443
+ rm workspace.template.json
444
+ rm workspace.json
445
+
361
446
echo " Finished"
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 59
59
# Count the policies
60
60
declare -i count=0
61
61
62
+ # Write out create-policy.template.json
63
+ cat > create-policy.template.json << EOF
64
+ {
65
+ "data": {
66
+ "attributes": {
67
+ "enforce": [
68
+ {
69
+ "path": "file-name",
70
+ "mode": "advisory"
71
+ }
72
+ ],
73
+ "name": "policy-name",
74
+ "description": "A Sentinel policy: policy-name"
75
+ },
76
+ "relationships": {
77
+ "policy-sets": {
78
+ "data": [
79
+ { "id": "policy-set-id", "type": "policy-sets" }
80
+ ]
81
+ }
82
+ },
83
+ "type": "policies"
84
+ }
85
+ }
86
+ EOF
87
+
62
88
# for loop to process all files with *.sentinel extension
63
89
for f in * .sentinel; do
64
90
echo " file is: $f "
@@ -81,4 +107,8 @@ for f in *.sentinel; do
81
107
82
108
done
83
109
110
+ # Remove create-policy.template.json and create-policy.json
111
+ rm create-policy.template.json
112
+ rm create-policy.json
113
+
84
114
echo " Found $count Sentinel policies"
You can’t perform that action at this time.
0 commit comments