Terraform - Validate your Terraform syntax is correct using the terraform validate command

by
Jeremy Canfield |
Updated: October 24 2023
| Terraform articles
Let's say output.tf has the following. Notice in this example that "values" is used instead of "value". The correct key is "value", not "values".
output "example" {
values = "hello world"
}
The terraform validate command can be used to know if you have any syntax errors.
]$ terraform validate
╷
│ Error: Missing required argument
│
│ on outputs.tf line 1, in output "example":
│ 1: output "example" {
│
│ The argument "value" is required, but no definition was found.
╵
╷
│ Error: Unsupported argument
│
│ on outputs.tf line 2, in output "example":
│ 2: values = "hello world"
│
│ An argument named "values" is not expected here. Did you mean "value"?
Did you find this article helpful?
If so, consider buying me a coffee over at