Skip to content

Commit 774c63e

Browse files
authored
fix: Pass args and env vars to terraform validate (antonbabenko#125)
1 parent 994653c commit 774c63e

File tree

4 files changed

+669
-566
lines changed

4 files changed

+669
-566
lines changed

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ if they are present in `README.md`.
108108
```yaml
109109
hooks:
110110
- id: terraform_tflint
111-
args: ['args=--deep']
111+
args: ['--args=--deep']
112112
```
113113

114114
In order to pass multiple args, try the following:
115115
```yaml
116116
- id: terraform_tflint
117117
args:
118-
- 'args=--deep'
119-
- 'args=--enable-rule=terraform_documented_variables'
118+
- '--args=--deep'
119+
- '--args=--enable-rule=terraform_documented_variables'
120120
```
121121

122122
## Notes about terraform_tfsec hooks
@@ -132,6 +132,41 @@ if they are present in `README.md`.
132132
}
133133
```
134134

135+
## Notes about terraform_validate hooks
136+
137+
1. `terraform_validate` supports custom arguments so you can pass supported no-color or json flags.
138+
139+
1. Example:
140+
```yaml
141+
hooks:
142+
- id: terraform_validate
143+
args: ['--args=-json']
144+
```
145+
146+
In order to pass multiple args, try the following:
147+
```yaml
148+
- id: terraform_validate
149+
args:
150+
- '--args=-json'
151+
- '--args=-no-color'
152+
```
153+
1. `terraform_validate` also supports custom environment variables passed to the pre-commit runtime
154+
155+
1. Example:
156+
```yaml
157+
hooks:
158+
- id: terraform_validate
159+
args: ['--envs=AWS_DEFAULT_REGION="us-west-2"']
160+
```
161+
162+
In order to pass multiple args, try the following:
163+
```yaml
164+
- id: terraform_validate
165+
args:
166+
- '--envs=AWS_DEFAULT_REGION="us-west-2"'
167+
- '--envs=AWS_ACCESS_KEY_ID="anaccesskey"'
168+
- '--envs=AWS_SECRET_ACCESS_KEY="asecretkey"'
169+
```
135170

136171
## Notes for developers
137172

0 commit comments

Comments
 (0)