Skip to content
Merged
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
15 changes: 15 additions & 0 deletions scripts/ensure-tf-boilerplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,18 @@ provider "aws" {
EOF
echo "Generated providers.tf (project=${REPO_NAME}, team=${TEAM})"
fi

# --- Generate .gitignore if missing ---
if [ ! -f "$TF_ROOT/.gitignore" ]; then
cat > "$TF_ROOT/.gitignore" <<'EOF'
# Terraform working files — never commit these
.terraform/
.terraform.lock.hcl
*.tfstate
*.tfstate.backup
*.tfplan
override.tf
override.tf.json
EOF
echo "Generated .gitignore"
fi
7 changes: 6 additions & 1 deletion scripts/expand-modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from registry import (
REGISTRY, PROJECT, DOMAIN,
BACKEND_TEMPLATE, PROVIDERS_TEMPLATE, OUTPUTS_TEMPLATE,
BACKEND_TEMPLATE, PROVIDERS_TEMPLATE, OUTPUTS_TEMPLATE, GITIGNORE_TEMPLATE,
)

GENERATED_MARKER = "# GENERATED FROM app.yaml — do not edit, changes will be overwritten"
Expand Down Expand Up @@ -678,6 +678,11 @@ def main():
os.path.join(tf_root, "outputs.tf"),
OUTPUTS_TEMPLATE.format(host=app_host),
)
# Ensure .gitignore exists so tfstate/working files never get committed
gitignore_path = os.path.join(tf_root, ".gitignore")
if not os.path.exists(gitignore_path):
with open(gitignore_path, "w") as f:
f.write(GITIGNORE_TEMPLATE)

# -- Write expanded module files --
for filename, content in file_contents.items():
Expand Down
11 changes: 11 additions & 0 deletions scripts/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@
}}
"""

GITIGNORE_TEMPLATE = """\
# Terraform working files — never commit these
.terraform/
.terraform.lock.hcl
*.tfstate
*.tfstate.backup
*.tfplan
override.tf
override.tf.json
"""

OUTPUTS_TEMPLATE = """\
# GENERATED FROM app.yaml — do not edit, changes will be overwritten
output "service_url" {{
Expand Down