You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terraform GitHub Actions allow you to execute Terraform commands within GitHub Actions.
3
+
Terragrunt GitHub Actions allow you to execute Terragrunt commands within GitHub Actions.
4
4
5
5
The output of the actions can be viewed from the Actions tab in the main repository view. If the actions are executed on a pull request event, a comment may be posted on the pull request.
6
6
7
-
Terraform GitHub Actions are a single GitHub Action that executes different Terraform subcommands depending on the content of the GitHub Actions YAML file.
7
+
Terragrunt GitHub Actions are a single GitHub Action that executes different Terragrunt subcommands depending on the content of the GitHub Actions YAML file.
8
8
9
9
## Success Criteria
10
10
11
11
An exit code of `0` is considered a successful execution.
12
12
13
13
## Usage
14
14
15
-
The most common workflow is to run `terraform fmt`, `terraform init`, `terraform validate`, `terraform plan`, and `terraform taint` on all of the Terraform files in the root of the repository when a pull request is opened or updated. A comment will be posted to the pull request depending on the output of the Terraform subcommand being executed. This workflow can be configured by adding the following content to the GitHub Actions workflow YAML file.
15
+
The most common workflow is to run `terragrunt fmt`, `terragrunt init`, `terragrunt validate`, `terragrunt plan`, and `terragrunt taint` on all of the Terragrunt files in the root of the repository when a pull request is opened or updated. A comment will be posted to the pull request depending on the output of the Terragrunt subcommand being executed. This workflow can be configured by adding the following content to the GitHub Actions workflow YAML file. Note that this action will use `terragrunt` binary to run all commands. In case of passing a `terraform` subcommand `terragrunt` will forward it to `terraform`.
This was a simplified example showing the basic features of these Terraform GitHub Actions. Please refer to the examples within the `examples` directory for other common workflows.
74
+
This was a simplified example showing the basic features of these Terragrunt GitHub Actions. Please refer to the examples within the `examples` directory for other common workflows.
70
75
71
76
## Inputs
72
77
73
78
Inputs configure Terraform GitHub Actions to perform different actions.
74
79
75
-
* `tf_actions_subcommand` - (Required) The Terraform subcommand to execute. Valid values are `fmt`, `init`, `validate`, `plan`, and `apply`.
76
-
* `tf_actions_version` - (Required) The Terraform version to install and execute. If set to `latest`, the latest stable version will be used.
77
-
* `tf_actions_cli_credentials_hostname` - (Optional) Hostname for the CLI credentials file. Defaults to `app.terraform.io`.
78
-
* `tf_actions_cli_credentials_token` - (Optional) Token for the CLI credentials file.
79
-
* `tf_actions_comment` - (Optional) Whether or not to comment on GitHub pull requests. Defaults to `true`.
80
-
* `tf_actions_working_dir` - (Optional) The working directory to change into before executing Terraform subcommands. Defaults to `.` which means use the root of the GitHub repository.
81
-
* `tf_actions_fmt_write` - (Optional) Whether or not to write `fmt` changes to source files. Defaults to `false`.
| tf_actions_subcommand | The Terraform/Terragrunt subcommand to execute. | `Yes` |
83
+
| tf_actions_version | The Terraform version to install and execute. If set to `latest`, the latest stable version will be used. | `Yes` |
84
+
| tg_actions_version | The Terragrunt version to install and execute. If set to `latest`, the latest stable version will be used. | `Yes` |
85
+
| tf_actions_cli_credentials_hostname | Hostname for the CLI credentials file. Defaults to `app.terraform.io`. | `No` |
86
+
| tf_actions_cli_credentials_token | Token for the CLI credentials file. | `No` |
87
+
| tf_actions_comment | Whether or not to comment on GitHub pull requests. Defaults to `true`. | `No` |
88
+
| tf_actions_working_dir | The working directory to change into before executing Terragrunt subcommands. Defaults to the root of the GitHub repository. | `No` |
89
+
| tf_actions_fmt_write | Whether or not to write `fmt` changes to source files. Defaults to `false`. | `No` |
82
90
83
91
## Outputs
84
92
85
93
Outputs are used to pass information to subsequent GitHub Actions steps.
86
94
87
-
* `tf_actions_output` - The Terraform outputs in (stringified) JSON format.
88
-
* `tf_actions_plan_has_changes` - `'true'` if the Terraform plan contained changes, otherwise `'false'`.
89
-
* `tf_actions_plan_output` - The Terraform plan output.
90
-
* `tf_actions_fmt_written` - Whether or not the Terraform formatting from `fmt` was written to source files.
Copy file name to clipboardExpand all lines: examples/arguments.md
+12-12
Original file line number
Diff line number
Diff line change
@@ -4,21 +4,21 @@ Arguments can be passed to each subcommand in two ways.
4
4
5
5
## Using Arguments
6
6
7
-
GitHub Actions supports an `args` attribute that will pass arguments to the Terraform subcommand. Using this `args` attribute will place the arguments at the end of the entire `terraform` command, even after all of the arguments defined in the source code. In this example, the argument `-var="env=dev"` will be appended to the `terraform init` command.
7
+
GitHub Actions supports an `args` attribute that will pass arguments to the Terragrunt subcommand. Using this `args` attribute will place the arguments at the end of the entire `terragrunt` command, even after all of the arguments defined in the source code. In this example, the argument `-var="env=dev"` will be appended to the `terragrunt init` command.
8
8
9
9
```yaml
10
-
name: 'Terraform GitHub Actions'
10
+
name: 'Terragrunt GitHub Actions'
11
11
on:
12
12
- pull_request
13
13
jobs:
14
-
terraform:
15
-
name: 'Terraform'
14
+
terragrunt:
15
+
name: 'Terragrunt'
16
16
runs-on: ubuntu-latest
17
17
steps:
18
18
- name: 'Checkout'
19
19
uses: actions/checkout@master
20
-
- name: 'Terraform Init'
21
-
uses: hashicorp/terraform-github-actions@master
20
+
- name: 'Terragrunt Init'
21
+
uses: hashicorp/terragrunt-github-actions@master
22
22
with:
23
23
tf_actions_version: 0.12.13
24
24
tf_actions_subcommand: 'init'
@@ -32,21 +32,21 @@ jobs:
32
32
33
33
## Using Environment Variables
34
34
35
-
Terraform supports environment variables named `TF_CLI_ARGS` and `TF_CLI_ARG_name` where `name` is the subcommand that is being executed. Using these environment variables will place the arguments after the subcommand but before any arguments defined in the source code. In this example, the argument `-var="env=dev"` will be appended to the `terraform init` command.
35
+
Terragrunt supports environment variables named `TF_CLI_ARGS` and `TF_CLI_ARG_name` where `name` is the subcommand that is being executed. Using these environment variables will place the arguments after the subcommand but before any arguments defined in the source code. In this example, the argument `-var="env=dev"` will be appended to the `terragrunt init` command.
Copy file name to clipboardExpand all lines: examples/backends.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
-
# Terraform Backends
1
+
# Terragrunt Backends
2
2
3
-
Terraform GitHub Actions supports initializing a `backend` block using the `-backend-config` option.
3
+
Terragrunt GitHub Actions supports initializing a `backend` block using the `-backend-config` option.
4
4
5
5
The example below shows how to pass the `token` and `organization` arguments to the `remote` backend block. The `token` argument is passed using GitHub Actions secrets while the organization is hardcoded.
The Terraform CLI credentials file is used to authenticate to Terraform Cloud/Enterprise. This is useful if the Terraform configuration contains many `terraform_remote_state` data sources that read from the same Terraform Cloud/Enterprise instance or if the configuration uses modules located in the Private Module Registry.
4
4
5
5
This example shows how to pass the hostname and token needed to create the CLI credentials file.
0 commit comments