Skip to main content
Kafka Setup with Script Code प्रकाशित: 03 जुलाई 2026 | श्रेणी: DevOps | लेखक: तकनीकी विशेषज्ञ 🌙 Dark Mode Apache Kafka एक शक्तिशाली डेटा स्ट्रीमिंग प्लेटफॉर्म है। यहाँ इसे स्क्रिप्ट कोड के ज़रिए सेटअप करने की पूरी गाइड दी गई है। Twitter LinkedIn WhatsApp चरण 1: सिस्टम जावा अपडेट काफ्का के लिए जावा आवश्यक है, इसे इंस्टॉल करने की स्क्रिप्ट नीचे दी गई है: Copy sudo apt update && sudo apt install default-jdk -y चरण 2: काफ्का डाउनलोड स्क्रिप्ट Copy wget https://apache.org tar -xzf kafka_2.13-3.5.0.tgz cd kafka_2.13-3.5.0 चरण 3: ज़ूकीपर और सर्वर स्टार्ट टर्मिनल 1 में ज़ूकीपर चलाएं: ...

How do you manage Terraform state across dev/stage/production?

 To manage Terraform state across dev, stage, and production, you must isolate each environment into its own independent state file. Sharing or mixing state files across environments can lead to catastrophic outages if a change intended for development accidentally targets production. [1, 2]

The industry standard for achieving this isolation relies on two distinct approaches, depending on the complexity of your infrastructure. [1, 2]

Option 1: File/Directory Separation (Recommended for Production)
The most robust, production-grade approach is to segregate environments using explicit file paths and distinct directories. This structure allows you to enforce strict boundary permissions, such as placing the production state file in an entirely different cloud account with restricted engineer access. [1, 2, 3, 4]
text
├── modules/
│   ├── vpc/
│   └── ec2/
└── environments/
    ├── dev/
    │   ├── main.tf
    │   ├── variables.tf
    │   └── backend.tf      # Unique state key: "dev/terraform.tfstate"
    ├── stage/
    │   ├── main.tf
    │   ├── variables.tf
    │   └── backend.tf      # Unique state key: "stage/terraform.tfstate"
    └── prod/
        ├── main.tf
        ├── variables.tf
        └── backend.tf      # Unique state key: "prod/terraform.tfstate"
How it works:
  • Reusable Modules: Base infrastructure components are written once in a shared modules/ folder.
  • Environment Root Directories: Each environment folder acts as a completely independent root module.
  • Dedicated Backend Files: Each environment defines its own unique remote backend key or bucket configuration. For example, the backend.tf file in prod/ will point to a strictly locked-down storage path.
  • Execution: To apply changes, engineers navigate directly into that folder (cd environments/dev && terraform apply). [1, 2, 3, 4, 5]

Option 2: Terraform Workspaces (Best for Identical, Simple Setups)
Terraform Workspaces allow you to use a single set of configuration files to manage multiple state files across different environments. When using a remote backend (like AWS S3), Terraform automatically segregates the state files into unique paths within the bucket under a terraform.tfstate.d/<workspace_name>/ prefix. [1, 2, 3]
text
# Single directory code structure
├── main.tf
├── variables.tf
├── outputs.tf
├── dev.tfvars
├── stage.tfvars
└── prod.tfvars
How it works:
  1. Create the environments:
    bash
    terraform workspace new dev
    terraform workspace new stage
    terraform workspace new prod
  2. Switch contexts before planning or applying:
    bash
    terraform workspace select dev
    terraform plan -var-file="dev.tfvars"
  3. Handle differences: In your code, interpolate variables using the current workspace name:
    hcl
    tags = { Environment = terraform.workspace }
    [1, 2, 3, 4]
Note: The primary downside to native workspaces is that code visibility suffers—you cannot easily look at the file tree to see what varies between environments, and it is easier to accidentally run a command in the wrong workspace context. [1]

Comparison Matrix
CriteriaDirectory Separation (Recommended)Terraform Workspaces
State File IsolationAbsolute (Can use different cloud accounts)Shared Backend (Isolated paths in one bucket)
Access ControlHighly secure (RBAC via separate buckets)Harder to split permissions by environment
Code DriftEnvironments can diverge purposefullyForces identical code across all stages
Best Used ForCritical production and enterprise infrastructureFast prototyping and ephemeral environments

Non-Negotiable Best Practices
Regardless of the architectural approach chosen, always enforce these security mechanisms for state management: [1]
  • Remote Storage: Never commit local terraform.tfstate files to version control. Utilize a trusted remote backend such as AWS S3, Google Cloud Storage, or HCP Terraform. [1, 2, 3]
  • State Locking: Ensure your chosen backend supports state locking (e.g., pairing AWS S3 with an Amazon DynamoDB locking table) to prevent race conditions when two pipelines or team members run a command simultaneously. [1, 2]
  • State Versioning: Turn on object versioning within your remote storage bucket so you can quickly roll back or recover an older state file if a deployment corrupts it. [1, 2]
If you are looking for an automated framework that implements directory separation natively without duplicating backend boilerplate code, check out Terragrunt. [1, 2]
Would you like help setting up a CI/CD pipeline to safely automate these checks, or would you like to see a complete code example of an S3 backend configuration with locking? [1, 2]

Comments

Popular posts from this blog

देवोप्स की पढ़ाई कैसे करें?

 DevOps (डेवऑप्स) एक ऐसा तरीका है जो सॉफ्टवेयर डेवलपमेंट (Dev) और IT ऑपरेशन्स (Ops) को एक साथ लाता है। इसका मुख्य लक्ष्य सॉफ्टवेयर बनाने, टेस्ट करने और डिलीवर करने की प्रक्रिया को तेज और अधिक विश्वसनीय बनाना है। DevOps की पढ़ाई के लिए आप नीचे दिए गए स्टेप्स को फॉलो कर सकते हैं: 1. मूलभूत अवधारणाओं को समझें सबसे पहले, आपको DevOps क्या है, यह क्यों महत्वपूर्ण है, और इसके मुख्य चरण (जैसे कंटीन्यूअस इंटीग्रेशन, कंटीन्यूअस डिलीवरी, मॉनिटरिंग) को समझना होगा। DevOps एजाइल मेथोडोलॉजी (Agile methodology) से बहुत प्रेरित है, इसलिए एजाइल के सिद्धांतों को समझना भी मददगार होगा। 2. आवश्यक स्किल्स और टूल्स सीखें DevOps इंजीनियर बनने के लिए कुछ प्रमुख स्किल्स और टूल्स में महारत हासिल करनी होगी:  * प्रोग्रामिंग स्किल्स (Programming Skills): कम से कम एक स्क्रिप्टिंग भाषा (जैसे Python, Bash, Ruby) का ज्ञान आवश्यक है, क्योंकि ऑटोमेशन में इनका उपयोग होता है। Java, JavaScript, या SQL का ज्ञान भी फायदेमंद हो सकता है।  * Linux/Unix: ऑपरेटिंग सिस्टम (OS) की गहरी समझ, खासकर Linux कमांड-लाइन और फाइ...

What modifications are required in Jenkins after changing the public IP address?

When you change the public IP address of a server running Jenkins , several modifications and checks are required to ensure Jenkins continues to function properly and remains accessible. Here’s a list of key updates you might need to make: 🔧 1. Update Jenkins URL Configuration: Why : Jenkins uses its root URL for things like generating links in email notifications, webhook callbacks, and UI redirects.

How to setup host based routing in eks with ingress controller ?

Of course. To set up host-based routing in EKS, you define an Ingress resource with multiple rules. Each rule specifies a hostname (e.g., app1.example.com) and maps it to a corresponding backend Service. The AWS Load Balancer Controller reads this resource and provisions an Application Load Balancer (ALB) to route traffic based on the Host header of incoming requests. Here’s a complete guide. Prerequisites A running Amazon EKS cluster. kubectl configured to connect to your cluster. The AWS Load Balancer Controller installed in your cluster. This is the standard Ingress controller for EKS. A registered domain name (e.g., your-domain.com) that you can manage. Step 1: Deploy Sample Applications First, let's deploy two different applications to route traffic to: a "coffee" app ☕ and a "tea" app 🍵. Each application will have a Deployment and a Service. Save the following YAML as apps.yaml: # apps.yaml # --- Coffee App --- apiVersion: apps/v1 kind: Deployment metadat...