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
These official Terraform GitHub Actions allow you to run `terraform fmt`, `validate` and `plan` on your pull requests to help you review and validate Terraform changes.
3
-
4
-
*[Actions](#actions)
5
-
*[Fmt Action](#fmt-action)
6
-
*[Validate Action](#validate-action)
7
-
*[Plan Action](#plan-action)
8
-
*[Usage](#usage)
9
-
*[Recommended Workflow](#recommended-workflow)
10
-
*[Step 1 - Create the initial workflow](#step-1---create-the-initial-workflow)
11
-
*[Step 2 - Customize it for your use-case](#step-2---customize-it-for-your-use-case)
12
-
*[Compose Your Own Workflow](#compose-your-own-workflow)
13
-
*[Directories](#directories)
14
-
*[Workspaces](#workspaces)
2
+
These official Terraform GitHub Actions allow you to run `terraform fmt`, `validate`
3
+
and `plan` on your pull requests to help you review and validate Terraform changes.
15
4
16
5
## Actions
17
6
@@ -27,260 +16,5 @@ Runs `terraform validate` and comments back on error.
27
16
Runs `terraform plan` and comments back with the output.
28
17
<imgsrc="./assets/plan.png"alt="Terraform Plan Action"width="80%" />
29
18
30
-
## Usage
31
-
To add these actions to your pull requests, you can copy our [recommended workflow](#recommended-workflow) into your `.github/main.workflow` file or you can [write your own workflow](#compose-your-own-workflow).
32
-
33
-
### Recommended Workflow
34
-
This workflow will run `terraform fmt`, `init`, `validate` and `plan`. To use it:
35
-
36
-
#### Step 1 - Create the initial workflow
37
-
1. Open up your repository in GitHub and click on the **Actions** tab
# If you're using Terraform workspaces, set this to the workspace name.
88
-
TF_ACTION_WORKSPACE = "default"
89
-
}
90
-
}
91
-
```
92
-
</details>
93
-
94
-
#### Step 2 - Customize it for your use-case
95
-
1. If your Terraform is in a different directory that the root of your repo, replace all instances of
96
-
```
97
-
TF_ACTION_WORKING_DIR = "."
98
-
```
99
-
With your directory, relative to the root of the repo, ex.
100
-
```
101
-
TF_ACTION_WORKING_DIR = "./terraform"
102
-
```
103
-
If you have multiple directories of Terraform code see [Directories](#directories)
104
-
1. If your Terraform runs in a different [workspace](https://www.terraform.io/docs/state/workspaces.html) than `default`, also change the `TF_ACTION_WORKSPACE` environment variable in the `terraform-plan` action.
105
-
106
-
If you have multiple workspaces, see [Workspaces](#workspaces).
107
-
1. If you're using a Terraform provider that requires credentials to run `terraform plan` (like AWS or Google Cloud Platform) then you need to add those credentials as Secrets to the `terraform-plan` action. Secrets can only be added from the **Visual Editor** so click back to that tab.
108
-
1. Scroll down to the `terraform-plan` action and click **Edit**. This will open up the action editor on the right side where you'll be able to add your secrets, ex. `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. See your [Provider Documentation](https://www.terraform.io/docs/providers/) for how to use environment variables with your provider.
109
-
110
-
⚠️ WARNING ⚠️ These secrets could be exposed if the plan action is run on a malicious Terraform file. As a result, we recommend you do not use this action on public repos or repos where untrusted users can submit pull requests.
111
-
112
-
113
-
## Compose Your Own Workflow
114
-
If you'd like to compose your own workflow, you can use each action separately. Each action is documented:
115
-
* [fmt](fmt/)
116
-
* [init](init/)
117
-
* [validate](validate/)
118
-
* [plan](plan/)
119
-
120
-
## Directories
121
-
Currently, these actions only support running in a single directory. If you'd like to run them in multiple directories, you'll have to create separate workflows for each directory:
Currently, these actions only support running in a single [Terraform workspace](https://www.terraform.io/docs/state/workspaces.html).
225
-
226
-
NOTE: The only action workspaces affect is `plan`.
227
-
228
-
If you'd like to run in multiple workspaces, you need to create separate workflows for each workspace. Since the only action that uses workspaces is `plan`, you can share the rest of the `fmt`, `init` and `validate` actions between the two workflows:
To get started, check out our documentation: [https://www.terraform.io/docs/github-actions/getting-started/](https://www.terraform.io/docs/github-actions/getting-started/).
0 commit comments