Skip to content
Merged
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
10 changes: 8 additions & 2 deletions terraform/run-init-on-aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def print_section(self, emoji: str, message: str):

def check_terraform_directory(self) -> bool:
"""Check that the opensearch_serverless and applications Terraform state directories exist."""
marker = "terragrunt.hcl" if self.tf_cmd == "terragrunt" else "main.tf"
for tf_dir in (self.tf_opensearch_dir, self.tf_applications_dir):
if not (tf_dir / "main.tf").exists():
print(f"Error: Terraform directory not found or missing main.tf: {tf_dir}")
if not (tf_dir / marker).exists():
print(f"Error: Terraform directory not found or missing {marker}: {tf_dir}")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general diagnostic messages should go to the standard error:

print(
    f"Error: Terraform directory not found or missing {marker}: {tf_dir}",
    file=sys.stderr
)

return False
return True

Expand Down Expand Up @@ -597,6 +598,11 @@ def main():
initializer.tf_cmd = "terragrunt"
if args.working_dir:
working_dir = args.working_dir.resolve()
elif args.terragrunt:
working_dir = Path.cwd()
else:
working_dir = None
if working_dir:
initializer.tf_opensearch_dir = working_dir / "opensearch_serverless"
initializer.tf_applications_dir = working_dir / "applications"
sys.exit(initializer.run())
Expand Down