Skip to content

Instantly share code, notes, and snippets.

@artem-hatchenko
Created February 7, 2023 15:35
Show Gist options
  • Save artem-hatchenko/87686f44ec4ef480f5c81566fe7eda3c to your computer and use it in GitHub Desktop.
Save artem-hatchenko/87686f44ec4ef480f5c81566fe7eda3c to your computer and use it in GitHub Desktop.
# Block for the modules
check_modules() {
# Run the "tflint" command and write the result to the $MODULES_OUTPUT file
cd $TF_DIR/$MODULE_DIR/$1
echo -e "\nMODULE: $1" | tee -a $MODULES_OUTPUT
if grep -qP '^module' *.tf
then echo "Found module call. Running terraform init..."
terraform init &>/dev/null
$TFLIT --config $MODULES_CONF_FILE | tee -a $MODULES_OUTPUT
rm -rf .terraform*
else
$TFLIT --config $MODULES_CONF_FILE | tee -a $MODULES_OUTPUT
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment