feat(terragrunt): add terragrunt plugin (#13261)

This commit is contained in:
Jim Weller authored and GitHub committed 2026-11-26 07:29:16 -08:00
1 parent 070831e592
commit abfce729ab
2 files changed
+80

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
# Terragrunt plugin
Terragrunt is a thin wrapper for opentofu/terraform that provides extra tools
and features to enhance the management of Infrastructure as Code (IaC) using
opentofu/terraform. This plugin adds completion for `terragrunt` command, as well
as aliases and a prompt function.
To use it, add `terragrunt` to the plugins array of your `~/.zshrc` file:
```shell
plugins=(... terragrunt)
```
## Requirements
- [Terragrunt](https://docs.terragrunt.com/) v0.77.22 or later
## Aliases
| Alias | Command |
| ------ | ----------------------------------------- |
| `tg` | `terragrunt` |
| `tga` | `terragrunt run -- apply` |
| `tgaa` | `terragrunt run -- apply -auto-approve` |
| `tgc` | `terragrunt run -- console` |
| `tgd` | `terragrunt run -- destroy` |
| `tgd!` | `terragrunt run -- destroy -auto-approve` |
| `tgi` | `terragrunt run -- init` |
| `tgo` | `terragrunt run -- output` |
| `tgp` | `terragrunt run -- plan` |
| `tgv` | `terragrunt run -- validate` |
| `tgs` | `terragrunt run -- state` |
| `tgsh` | `terragrunt run -- show` |
| `tgr` | `terragrunt run -- refresh` |
| `tgt` | `terragrunt run -- test` |
| `tgws` | `terragrunt run -- workspace` |
## Prompt function
- `terragrunt_version_prompt_info` shows the current version of the `terragrunt` command.
To use it, add it to a `PROMPT` or `RPROMPT` variable in your theme or `.zshrc` file.
```sh
RPROMPT='$(terragrunt_version_prompt_info)'
```
You can also specify the PREFIX and SUFFIX strings with the following variables.
```sh
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX="%{$fg[white]%}"
ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX="%{$reset_color%}"
```
+27
View File
@@ -0,0 +1,27 @@
# set up the terragrunt completion (compatible for zsh)
autoload -Uz bashcompinit && bashcompinit
complete -C terragrunt terragrunt
# terragrunt version prompt function
function terragrunt_version_prompt_info() {
# get the output of `terragrunt --version` in a single line, and get the third word after splitting by a space
local terragrunt_version=${${(s: :)$(terragrunt --version)}[3]}
# make sure to escape % signs in the version string to prevent command injection
echo "${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_PREFIX-[}${terragrunt_version:gs/%/%%}${ZSH_THEME_TERRAGRUNT_VERSION_PROMPT_SUFFIX-]}"
}
alias tg='terragrunt'
alias tga='terragrunt run -- apply'
alias tgaa='terragrunt run -- apply -auto-approve'
alias tgc='terragrunt run -- console'
alias tgd='terragrunt run -- destroy'
alias tgd!='terragrunt run -- destroy -auto-approve'
alias tgi='terragrunt run -- init'
alias tgo='terragrunt run -- output'
alias tgp='terragrunt run -- plan'
alias tgv='terragrunt run -- validate'
alias tgs='terragrunt run -- state'
alias tgsh='terragrunt run -- show'
alias tgr='terragrunt run -- refresh'
alias tgt='terragrunt run -- test'
alias tgws='terragrunt run -- workspace'