Skip to content

Refactor to modular structure #69

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions .github/scripts/generate-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail

# Determine repo root path relative to this script
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"

# Path to terraform-docs config
TFDOCS_CONFIG="${REPO_ROOT}/.terraform-docs.yml"

# Check terraform-docs is installed
if ! command -v terraform-docs &> /dev/null; then
echo "❌ terraform-docs is not installed. Install it from https://terraform-docs.io/"
exit 1
fi

echo "📘 Generating module documentation using config at: $TFDOCS_CONFIG"
echo

# Loop through all submodules with a variables.tf file
find "${REPO_ROOT}/modules" -type f -name "variables.tf" | while read -r tf_file; do
MODULE_DIR="$(dirname "$tf_file")"
echo "📄 Updating docs for module: ${MODULE_DIR#$REPO_ROOT/}"

terraform-docs --config "$TFDOCS_CONFIG" "$MODULE_DIR" > "$MODULE_DIR/README.md"
done

echo
echo "✅ Documentation generated for all modules."
20 changes: 10 additions & 10 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
formatter: markdown

header-from: "docs/header.md"
footer-from: "docs/footer.md"

output:
file: README.md
mode: inject

sort:
enabled: true
by: name
output-file: README.md
output-mode: inject
sections:
show-header: true
show-inputs: true
show-outputs: true
show-providers: false
show-requirements: false
show-resources: false
show-data-sources: false
175 changes: 0 additions & 175 deletions .terraform.lock.hcl

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Pull requests are the best way to propose changes to the codebase. We actively w
This module uses [terraform-docs](https://terraform-docs.io/user-guide/introduction/) to generate documentation. To generate the documentation, run the following command from the root of the repository:

```bash
terraform-docs --config .terraform-docs.yml .
.github/scripts/generate-docs.sh
```

## Development Process
Expand Down
Loading