From 17ad1eaa682aff6e96ee3cc28b6d0da1f6c4a302 Mon Sep 17 00:00:00 2001 From: Akanksha Trehun Date: Mon, 9 Feb 2026 16:43:58 +0530 Subject: [PATCH] feat: Add Terraform initialization and teardown scripts - Add scripts/init.sh for automated Terraform setup - Add scripts/teardown.sh for automated resource cleanup - Make both scripts executable - Update README with usage instructions Both scripts use `set -e` for error handling and provide clear feedback during execution. Closes #21 Co-Authored-By: Claude Sonnet 4.5 --- README.md | 31 +++++++++++++++++++++++++++++++ scripts/init.sh | 13 +++++++++++++ scripts/teardown.sh | 7 +++++++ 3 files changed, 51 insertions(+) create mode 100755 scripts/init.sh create mode 100755 scripts/teardown.sh diff --git a/README.md b/README.md index 9455f37..c453606 100644 --- a/README.md +++ b/README.md @@ -212,9 +212,40 @@ MicroForge/ │ ├── notification-service/# Node.js service │ └── docker-compose.yml # Local development setup ├── manifests/kubernetes/ # K8s deployment manifests +├── scripts/ # Automation scripts +│ ├── init.sh # Terraform initialization script +│ ├── teardown.sh # Terraform cleanup script +│ └── k8s-setup.sh # Kubernetes setup script └── README.md # Project documentation ``` +--- + +## 📜 **Terraform Automation Scripts** + +The project includes convenient scripts for Terraform infrastructure management: + +### **Initialization Script** (`scripts/init.sh`) +Automates the complete Terraform setup process: +```bash +./scripts/init.sh +``` +**What it does:** +- Initializes Terraform with `terraform init -input=false` +- Validates configuration with `terraform validate` +- Formats code recursively with `terraform fmt -recursive` + +### **Teardown Script** (`scripts/teardown.sh`) +Cleans up all Terraform-managed resources: +```bash +./scripts/teardown.sh +``` +**What it does:** +- Destroys all Terraform-managed infrastructure with `terraform destroy --auto-approve` +- Automatically confirms destruction (non-interactive mode) + +> **Note**: Both scripts use `set -e` for error handling, meaning they will exit immediately if any command fails. + ### **Environment Setup** ```bash # Prerequisites diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100755 index 0000000..d7e0ca2 --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +echo "Initializing Terraform..." +terraform init -input=false + +echo "Validating configuration..." +terraform validate + +echo "Formatting code..." +terraform fmt -recursive + +echo "Initialization complete." diff --git a/scripts/teardown.sh b/scripts/teardown.sh new file mode 100755 index 0000000..9ac8987 --- /dev/null +++ b/scripts/teardown.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e + +echo "Destroying Terraform-managed resources..." +terraform destroy --auto-approve + +echo "Teardown complete."