Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding terraform_validate.sh #43

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions terraform_validate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# Check if Terraform is installed
if ! command -v terraform &> /dev/null
then
echo "Terraform is not installed. PLease install it!"
exit 1
fi

# Check the syntax of Terraform files
terraform fmt -check
if [ $? -ne 0 ]; then
echo "Terraform files are not correctly formatted!"
exit 1
else
echo "Terraform files are correctly formatted!"
fi

# Run terraform validate to check the .tf files in the current directory
terraform validate
if [ $? -eq 0 ]; then
echo "Terraform files are valid!"
else
echo "Terraform files contain syntax errors!"
exit 1
fi