-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathterragrunt.ts
624 lines (616 loc) · 17.9 KB
/
terragrunt.ts
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
// If you edit terraform commands or options, please copy our changes on to the terraform spec
// ARGUMENTS json-out etc
const workspaceList: Fig.Generator = {
script: ["terragrunt", "workspace", "list"],
postProcess: function (out) {
return out.split("\n").map((workspace) => {
return {
name: workspace.replace("* ", "").trim(),
icon: "https://terragrunt.gruntwork.io/assets/img/favicon/favicon.ico",
description: "Workspace",
};
});
},
};
const addressList: Fig.Generator = {
script: ["terragrunt", "state", "list"],
postProcess: function (out) {
if (out.includes("No state file was found!") || out.includes("Error")) {
return [];
}
return out.split("\n").map((addresses) => {
return {
name: addresses.replace("* ", "").trim(),
icon: "https://terragrunt.gruntwork.io/assets/img/favicon/favicon.ico",
description: "Address",
};
});
},
};
const generalSubCommandOptions: Fig.Option[] = [
{
name: "-lock",
requiresSeparator: true,
description:
"Lock the state file when locking is supported. Defaults to true",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-force",
requiresSeparator: true,
description:
"Delete the workspace even if its state is not empty. Defaults to false",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-lock-timeout",
requiresSeparator: true,
description: "Duration to retry a state lock. Default 0s",
args: {
name: "seconds",
},
},
{
name: "-input",
requiresSeparator: true,
description: "Ask for input for variables if not directly set",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-no-color",
description: "Disables output with coloring",
},
];
const globalOptions: Fig.Option[] = [
{
name: ["-h", "--help"],
description:
"Show this help output, or the help for a specified subcommand",
},
{
name: ["-v", "--version"],
description: "Show the current Terragrunt version",
},
{
name: "--terragrunt-config",
description:
"Path to the Terragrunt config file. Default is terragrunt.hcl",
args: {
template: ["filepaths"],
},
},
{
name: "--terragrunt-tfpath",
description: "Path to the Terraform binary. Default is terraform (on PATH)",
args: {
template: ["filepaths"],
},
},
{
name: "--terragrunt-no-auto-init",
description:
"Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually",
},
{
name: "--terragrunt-no-auto-retry",
description:
"Don't automatically re-run command in case of transient errors",
},
{
name: "--terragrunt-non-interactive",
description: "Assume 'yes' for all prompts",
},
{
name: "--terragrunt-working-dir",
description:
"The path to the Terraform templates. Default is current directory",
args: {
template: ["folders"],
},
},
{
name: "--terragrunt-download-dir",
description:
"The path where to download Terraform code. Default is .terragrunt-cache in the working directory",
args: {
template: ["folders"],
},
},
{
name: "--terragrunt-source",
description:
"Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder",
args: {
template: ["folders"],
},
},
{
name: "--terragrunt-source-map",
description:
"Replaces any source URL (including the source URL of a config pulled in with dependency blocks) that has root source with dest",
},
{
name: "--terragrunt-source-update",
description:
"Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it",
},
{
name: "--terragrunt-ignore-dependency-errors",
description:
"*-all commands continue processing components even if a dependency fails",
},
{
name: "--terragrunt-iam-role",
description:
"Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable",
args: {
name: "IAM role ARN",
},
},
{
name: "--terragrunt-iam-assume-role-duration",
description:
"Session duration for IAM Assume Role session. Can also be set via the TERRAGRUNT_IAM_ASSUME_ROLE_DURATION environment variable",
args: {
name: "Duration",
},
},
{
name: "--terragrunt-iam-assume-role-session-name",
description:
"Name for the IAM Assummed Role session. Can also be set via TERRAGRUNT_IAM_ASSUME_ROLE_SESSION_NAME environment variable",
args: {
name: "Session name",
},
},
{
name: "--terragrunt-exclude-dir",
description:
"Unix-style glob of directories to exclude when running *-all commands",
args: {
template: ["folders"],
},
},
{
name: "--terragrunt-include-dir",
description:
"Unix-style glob of directories to include when running *-all commands",
args: {
template: ["folders"],
},
},
{
name: "--terragrunt-strict-include",
description:
"Only modules under the directories passed in with –terragrunt-include-dir will be included. All dependencies of the included directories will be excluded if they are not in the included directories. If no –terragrunt-include-dir flags are included, terragrunt will not include any modules during the execution of the commands",
},
{
name: "--terragrunt-strict-validate",
description:
"Sets strict mode for the validate-inputs command. By default, strict mode is off. When this flag is passed, strict mode is turned on. When strict mode is turned off, the validate-inputs command will only return an error if required inputs are missing from all input sources (env vars, var files, etc). When strict mode is turned on, an error will be returned if required inputs are missing OR if unused variables are passed to Terragrunt",
},
{
name: "--terragrunt-ignore-dependency-order",
description: "*-all commands will be run disregarding the dependencies",
},
{
name: "--terragrunt-ignore-external-dependencies",
description:
"*-all commands will not attempt to include external dependencies",
},
{
name: "--terragrunt-include-external-dependencies",
description: "*-all commands will include external dependencies",
},
{
name: "--terragrunt-parallelism",
description: "*-all commands parallelism set to at most N modules",
args: {
name: "N",
description: "Number of modules",
},
},
{
name: "--terragrunt-debug",
description:
"Write terragrunt-debug.tfvars to working folder to help root-cause issues",
},
{
name: "--terragrunt-log-level",
description:
"Sets the logging level for Terragrunt. Supported levels: panic, fatal, error, warn (default), info, debug, trace",
},
{
name: "--terragrunt-check",
description: "Enable check mode in the hclfmt command",
},
{
name: "--terragrunt-hclfmt-file",
description:
"The path to a single hcl file that the hclfmt command should run on",
args: {
name: "hcl file",
template: ["filepaths"],
},
},
{
name: "--terragrunt-override-attr",
description:
"A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times",
args: {},
},
{
name: "--terragrunt-json-out",
description:
"The file path that terragrunt should use when rendering the terragrunt.hcl config as json. Only used in the render-json command. Defaults to terragrunt_rendered.json",
args: {
template: ["filepaths"],
},
},
{
name: "--terragrunt-modules-that-include",
description:
"When passed in, run-all will only run the command against Terragrunt modules that include the specified file",
args: {
template: ["filepaths"],
},
},
];
const terraformCommands: Fig.Subcommand[] = [
{
name: "init",
description: "Prepare your working directory for other commands",
options: [
{
name: "-upgrade",
description:
"Opt to upgrade modules and plugins as part of their respective installation steps",
},
...generalSubCommandOptions,
...globalOptions,
],
},
{
name: "validate",
description: "Check whether the configuration is valid",
options: [...globalOptions],
},
{
name: "plan",
description: "Show changes required by the current configuration",
options: [
{
name: "-compact-warnings",
description:
"If Terraform produces any warnings that are not accompanied by errors, show them in a more compact form that includes only the summary messages",
},
{
name: "-destroy",
description:
"If set, generates a plan to destroy all the known resources",
},
{
name: "-detailed-exitcode",
description: "Return a detailed exit code when the command exits",
},
{
name: "-out",
requiresSeparator: true,
description: "The path to save the generated execution plan",
},
{
name: "-parallelism",
description:
"Limit the number of concurrent operation as Terraform walks the graph. Defaults to 10",
args: {
name: "number",
},
},
{
name: "-refresh",
requiresSeparator: true,
description: "Update the state prior to checking for differences",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-state",
requiresSeparator: true,
description:
"Path to the state file. Defaults to 'terraform.tfstate'. Ignored when remote state is used",
args: {
template: "filepaths",
},
},
{
name: "-target",
displayName: "-target=resource",
description:
"A Resource Address to target. This flag can be used multiple times",
isRepeatable: true,
},
{
name: "-var",
insertValue: "-var {cursor}",
description:
"Set a variable in the Terraform configuration. This flag can be set multiple times",
isRepeatable: true,
args: {
name: "foo=bar",
},
},
{
name: "-var-file",
requiresSeparator: true,
description:
"Set variables in the Terraform configuration from a variable file",
args: {
template: "filepaths",
},
},
...generalSubCommandOptions,
...globalOptions,
],
},
{
name: "apply",
description: "Create or update infrastructure",
options: [...globalOptions],
},
{
name: "destroy",
description: "Destroy previously-created infrastructure",
options: [...globalOptions],
},
];
const terraformOtherCommands: Fig.Subcommand[] = [
{
name: "console",
description: "Try Terraform expressions at an interactive command prompt",
options: [...globalOptions],
},
{
name: "fmt",
description: "Reformat your configuration in the standard style",
options: [...globalOptions],
},
{
name: "force-unlock",
description: "Release a stuck lock on the current workspace",
options: [...globalOptions],
},
{
name: "get",
description: "Install or upgrade remote Terraform modules",
options: [
{
name: "-update",
description:
"If specified, modules that are already downloaded will be checked for updates and the updates will be downloaded if present",
},
...globalOptions,
],
},
{
name: "graph",
description: "Generate a Graphviz graph of the steps in an operation",
options: [...globalOptions],
},
{
name: "import",
description: "Associate existing infrastructure with a Terraform resource",
options: [...globalOptions],
},
{
name: "login",
description: "Obtain and save credentials for a remote hos",
options: [...globalOptions],
},
{
name: "logout",
description: "Remove locally-stored credentials for a remote host",
options: [...globalOptions],
},
{
name: "output",
description: "Show output values from your root module",
options: [...globalOptions],
},
{
name: "providers",
description: "Show the providers required for this configuration",
options: [...globalOptions],
},
{
name: "refresh",
description: "Update the state to match remote systems",
options: [...globalOptions],
},
{
name: "show",
description: "Show the current state or a saved plan",
options: [...globalOptions],
},
{
name: "state",
description: "Advanced state management",
},
{
name: "taint",
description: "Mark a resource instance as not fully functional",
options: [
{
name: "-allow-missing",
description:
"If specified, the command will succeed (exit code 0) even if the resource is missing. The command might still return an error for other situations, such as if there is a problem reading or writing the state",
},
{
name: "-lock",
requiresSeparator: true,
description:
"Disables Terraform's default behavior of attempting to take a read/write lock on the state for the duration of the operation if set to false. Defaults to true",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-lock-timeout",
requiresSeparator: true,
description:
"Unless locking is disabled with -lock=false, instructs Terraform to retry acquiring a lock for a period of time before returning an error. The duration syntax is a number followed by a time unit letter, such as 3s for three seconds",
args: {
name: "seconds",
},
},
{
name: "-ignore-remote-version",
description:
"When using the enhanced remote backend with Terraform Cloud, continue even if remote and local Terraform versions differ. This may result in an unusable Terraform Cloud workspace, and should be used with extreme caution",
args: {
name: "seconds",
},
},
...globalOptions,
],
args: {
generators: addressList,
name: "address",
},
},
{
name: "untaint",
description: "Remove the 'tainted' state from a resource instance",
options: [...globalOptions],
},
{
name: "workspace",
description: "Workspace management",
options: [...globalOptions],
subcommands: [
{
name: "new",
insertValue: "new '{cursor}'",
description: "Create a new workspace",
args: {
name: "workspace name",
},
options: [
{
name: "-lock",
description:
"Lock the state file when locking is supported. Defaults to true",
args: {
name: "true or false",
suggestions: ["true", "false"],
},
},
{
name: "-lock-timeout",
description: "Duration to retry a stae lock. Default 0s",
args: {
name: "seconds",
},
},
{
name: "-state",
requiresSeparator: true,
description:
"Path to an existing state file to initialize the state of this environment",
args: {
name: "path",
template: "filepaths",
},
},
...globalOptions,
],
},
{
name: "show",
description: "Display the current workspace",
options: [...globalOptions],
},
{
name: "list",
description: "List the workspace",
options: [...globalOptions],
},
{
name: "delete",
description: "Delete the specified workspace",
args: {
generators: workspaceList,
name: "workspace name",
},
options: [...generalSubCommandOptions],
},
{
name: "select",
description: "Change the current working workspace",
args: {
generators: workspaceList,
},
},
],
},
];
const terragruntCommands: Fig.Subcommand[] = [
{
name: "run-all",
description:
"Run a terraform command against a 'stack' by running the specified command in each subfolder. E.g., to run 'terragrunt apply' in each subfolder, use 'terragrunt run-all apply'",
},
{
name: "terragrunt-info",
description: "Emits limited terragrunt state on stdout and exits",
},
{
name: "validate-inputs",
description:
"Checks if the terragrunt configured inputs align with the terraform defined variables",
},
{
name: "graph-dependencies",
description: "Prints the terragrunt dependency graph to stdout",
},
{
name: "hclfmt",
description:
"Recursively find hcl files and rewrite them into a canonical format",
},
{
name: "aws-provider-patch",
description:
"Overwrite settings on nested AWS providers to work around a Terraform bug (issue #13018)",
},
{
name: "render-json",
description:
"Render the final terragrunt config, with all variables, includes, and functions resolved, as json. This is useful for enforcing policies using static analysis tools like Open Policy Agent, or for debugging your terragrunt config",
},
];
const completionSpec: Fig.Spec = {
name: "terragrunt",
description: "Terragrunt CLI",
options: globalOptions,
parserDirectives: {
flagsArePosixNoncompliant: true,
},
subcommands: [
...terraformCommands,
...terraformOtherCommands,
...terragruntCommands,
],
};
export default completionSpec;