0
votes

Is there any way to validate that a proposed new security group is syntactically correct for terraform and aws? What happens is that I am asked to review security group adds and changes but I spend not much time working with terraform. I've learned the basics of what to see in main.tf output.tf and variable.tf for these sg modules. Once I approve the module change in github it gets committed and merged to the rest of the vpc repository. At some point a terrform plan will be run and that would show any errors. But what I'm wondering is if there's a program that would validate that the proposed security group code in main/variables are syntactically correct before I approve it.

1
may be this will help: terraform validateChandan Nayak

1 Answers

0
votes

terraform validate does what you need.

The terraform validate command is used to validate the syntax of the terraform files. Terraform performs a syntax check on all the terraform files in the directory, and will display an error if any of the files doesn't validate.

From the official docs.

An example validating the src directory:

terraform validate src

An example validating the src directory specifying a variable foo:

terraform validate -var 'foo=bar' src