Reputation: 61
currently I am running below shell command
@if [ -x "$$(command -v terraform)" ]; then \
echo "==> Checking terraform formatting of files"; \
(terraform validate ./test && echo "Terraform format check passed successfully") \
|| (echo "validation failed" && exit 1); \
else \
echo "No terraform command found"; \
exit 1; \
fi
here I dont want to initialize the backend but it seems it does that and I also see error as
? on test/policy.tf line 320:
? 320: module "service_admin_policy" {
?
? This module is not yet installed. Run "terraform init" to install all
? modules required by this configuration.
terraform version = 1.1.6
using terraform validate I just want to check if the .tf files in a directory are just syntactically correct like braces missing and comma kind of stuff. any help on how I can ignore these errors.
Upvotes: 2
Views: 6243
Reputation: 10117
Validate works at the level of checking your code for soundness, including loading modules and ensuring that variables are correctly named.
If you only want basic syntax of a local file, consider using terraform fmt -write=false
. If the formatter is unable to parse the file, it will throw an error.
Upvotes: 6