You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
590 B
Bash
29 lines
590 B
Bash
#!/bin/bash
|
|
|
|
# Function to run terraform init and validate in a directory
|
|
run_terraform() {
|
|
local dir="$1"
|
|
echo "Running terraform init and validate in $dir"
|
|
cd "$dir" || exit
|
|
terraform init
|
|
terraform validate
|
|
cd - || exit
|
|
}
|
|
|
|
# Main script
|
|
main() {
|
|
# Get the current directory
|
|
current_dir=$(pwd)
|
|
|
|
# Find all subdirectories containing a main.tf file
|
|
subdirs=$(find "$current_dir" -type f -name "main.tf" -exec dirname {} \;)
|
|
|
|
# Run terraform init and validate in each subdirectory
|
|
for dir in $subdirs; do
|
|
run_terraform "$dir"
|
|
done
|
|
}
|
|
|
|
# Run the main script
|
|
main
|