Showing posts with label DevOps. Show all posts
Showing posts with label DevOps. Show all posts

Sunday, 8 November 2026

From DevOps to AIOps: CI/CD, Observability, Autoscaling, and AI Model Operations

Standard



A pager goes off at 2 a.m. Five hundred alerts say the same outage in five hundred dialects. A human is supposed to be the correlation engine. That is the old DevOps night shift. AIOps is the bet that a model can do the first pass: group the noise, name the likely cause, and sometimes fix it before a human opens a laptop (Gartner, 2025; TechTarget, 2024).

DevOps and AIOps are not rivals. DevOps is how you build and ship. AIOps is how you keep a noisy, multi-cloud estate from drowning the people who ship. One is a culture plus a pipeline. The other is event intelligence on top of telemetry. Teams that skip DevOps and buy an "AIOps platform" get a dashboard on a mess. Teams that stop at DevOps get fast deploys and a pager that never sleeps (Kim et al., 2016; Forsgren et al., 2018).

This post is a long walk through both: what they are, who does what, the tools and cloud services that actually matter now, CI/CD, monitoring and observability, visualization, autoscaling, training and deploying AI models, and the concrete path from a DevOps team to an AIOps practice. It also draws a hard line around MLOps. Training a model is not the same job as using a model to run operations.

Key Abbreviations in This Post

  • DevOps: Shared ownership of build, test, release, and run. Culture first, toolchain second.
  • AIOps (Artificial Intelligence for IT Operations): Machine learning on events and telemetry to cut noise, find cause, and trigger action. Gartner now files much of this as Event Intelligence Solutions.
  • MLOps: The DevOps-shaped practice for training, registering, deploying, and watching machine learning models. Related, not a synonym.
  • CI/CD (Continuous Integration / Continuous Delivery or Deployment): Every commit is tested. Every good build can go to production, often through GitOps.
  • IaC (Infrastructure as Code): Terraform, Pulumi, Bicep, CloudFormation. The cluster is a file in Git.
  • SRE (Site Reliability Engineering): Google's reliability craft: SLIs, SLOs, error budgets, toil reduction.
  • OTel (OpenTelemetry): The open standard for metrics, logs, traces, and now more signals. The pipe almost everyone should use.
  • MELT: Metrics, Events, Logs, Traces. The raw food of observability and AIOps.
  • MTTR (Mean Time to Restore / Repair): How long you stay broken. AIOps is sold on shrinking this.
  • HPA / VPA / KEDA: Kubernetes scalers. CPU/memory, vertical size, and event-driven (queues, custom metrics).
  • GitOps: Desired state lives in Git. Argo CD or Flux makes the cluster match.
  • SLO / SLI: Service level objective and indicator. The contract, not the raw CPU graph.

The One-Minute Version

  • DevOps: make change cheap and safe. CI/CD, IaC, containers, shared on-call.
  • AIOps: make operations cheap and safe at alert volume humans cannot read. Correlate, predict, remediate.
  • They meet on telemetry: if OpenTelemetry is missing, neither story works.
  • CI/CD that matters now: GitHub Actions or GitLab CI for build, Argo CD or Flux for deploy, plus a real security scan in the pipe.
  • Observe, then visualize: Prometheus + Grafana (or a vendor suite) on an OTel collector. Dashboards are not the product. Questions are.
  • Scale on the signal that hurts: HPA for CPU, KEDA for queues, Karpenter or a cloud node pool for GPUs.
  • Models have two lives: you train and serve them (MLOps). You also use models to run the shop (AIOps). Do not mix the labels.
  • The shift: instrument, one pipe, correlate, suggest, then auto-fix with a human brake.
From DevOps delivery loop to AIOps event intelligence on telemetry

What DevOps Actually Is

DevOps is not a job title that magically appears when you install Jenkins. It is a working agreement: the people who write the service also ship it and feel the production pain (Kim et al., 2016). The Phoenix Project and the later DevOps Handbook gave the industry a story. Accelerate gave it numbers: elite teams deploy more often, recover faster, and have lower change-fail rates when they combine automation with generative culture (Forsgren et al., 2018).

The technical skeleton is familiar in 2026:

  • Version control as the source of truth (Git).
  • CI on every change: unit tests, lint, SAST, image build, SBOM.
  • CD through environments: staging, canary or blue/green, production.
  • IaC so a region can be rebuilt from a repo.
  • Containers and Kubernetes (or a serverless stand-in) so "it works on my machine" dies.
  • You build it, you run it, with SRE-style SLOs if the org is large enough (Beyer et al., 2016).

Platform engineering is the current refinement. Instead of every squad inventing a pipeline, a platform team offers a paved road: a golden path template, a shared cluster, a catalog. DevOps did not end. It got a product manager (CNCF, 2024).

Problem: developers throw a build over the wall. Ops refuses Friday deploys.
Cause: incentives are split. Dev is scored on features. Ops is scored on uptime.
Effect: tickets, war rooms, and a six-month release train. DevOps collapses the wall. The same team owns the pipeline and the pager.

DevOps infinite loop from plan and code through deploy, operate, and monitor

DevOps tasks and responsibilities

A working DevOps or platform squad typically owns:

  • Pipeline design: what runs on pull request, what is required to merge, what promotes a build.
  • Environment truth: Terraform/Pulumi modules, secrets via Vault or a cloud secret store plus External Secrets.
  • Release mechanics: GitOps apps, rollout strategy, feature flags (LaunchDarkly, Unleash, Flagsmith, or cloud equivalents).
  • Runtime: Kubernetes, service mesh or Gateway API, ingress, certificates, network policy.
  • Quality gates: tests, image scan (Trivy, Grype), policy-as-code (OPA, Kyverno).
  • Basic observability: emit metrics and logs, a default Grafana folder, an on-call rotation, a runbook.
  • Cost and capacity: requests/limits, reserved instances, a first-pass FinOps tag.
  • Security in the path: identity (IRSA, Workload Identity), least privilege, signed images (cosign).

What they are not automatically: the team that trains foundation models, the SOC, or the people who invent a correlation algorithm. Those sit next door.

What AIOps Actually Is

Gartner coined AIOps years ago. By 2025 they were telling buyers to look past the slogan and buy Event Intelligence: ingest alerts from many tools, correlate and enrich them, find patterns, and drive remediation (Gartner, 2025). That is the useful definition. A product that only draws a prettier graph is observability. A product that turns 400 duplicate CPU alarms and a trace spike into one incident with a suggested rollback is AIOps.

The loop is:

  1. Ingest metrics, logs, traces, events, tickets, topology, change records.
  2. Normalize so a CloudWatch alarm and a Prometheus alert can share a language.
  3. Correlate by time, service, and dependency map.
  4. Enrich with owner, SLO, recent deploy, customer impact.
  5. Decide with rules plus models: suppress, page, or act.
  6. Act by opening a ticket, paging the right squad, restarting a pod, or rolling back via GitOps.
  7. Learn from the human who said "wrong root cause" so the next cluster is better.

Vendors in this neighborhood include Dynatrace, Datadog, Splunk, New Relic, BigPanda, Moogsoft-class tools, ServiceNow Event Management, Elastic, and the AI add-ons now bolted onto every observability suite (Network World, 2025). Open source stacks do a thinner version: Alertmanager inhibit rules, Grafana IRM, and homegrown correlation. The science is the same. The difference is how much topology and history you feed the model.

Problem: a Kubernetes node dies. Every pod on it pages a different team.
Cause: each monitor is local. None of them knows the shared cause.
Effect: six bridges and one still-broken node. AIOps should emit one incident: "node X, drain and replace, these five services degraded, last change was a Karpenter template at 01:12."

AIOps turning noisy alerts into correlated incidents and remediation

AIOps tasks and responsibilities

  • Signal hygiene: kill duplicate monitors before you train anything. Garbage in, confident garbage out.
  • Topology: keep a living map of services, queues, databases, and third-party APIs.
  • Baselines: what "normal" looks like per weekday, per region, per release.
  • Incident object: one ticket, many raw events. Link to the deploy SHA.
  • Runbook automation: restart, scale, fail over, roll back, with an approval step until trust is earned.
  • Feedback: operators mark true/false so models do not freeze in 2024's traffic shape.
  • Guardrails: an AI that can restart prod without a recorded reason is an outage generator.
DevOps and AIOps responsibilities sharing Kubernetes, cloud, and telemetry

How They Differ, and How They Fit

Three labels people smash together Question DevOps AIOps MLOps Job Ship software safely Run the estate smarter Ship models safely Unit of work Commit / release Event / incident Dataset / model version Core tools CI, GitOps, IaC Correlation, IRM MLflow, KServe Success metric Lead time, CFR MTTR, noise cut Quality, drift, latency AI role Optional copilot The product The artifact How they stack DevOps builds the highway (pipeline, cluster, telemetry). MLOps drives model trucks on that highway. AIOps is the traffic brain: it watches the highway and reroutes. You can do DevOps without AIOps. You cannot do AIOps without DevOps data.

Apples and oranges, as the usual explainer says, and still the same fruit bowl (TechTarget, 2024). DevOps shrinks the cost of a change. AIOps shrinks the cost of a signal. You need both once the estate is larger than one team can hold in their head.

CI/CD: What Matters Now

The CI/CD market is no longer "Jenkins versus the world." Jenkins still runs in banks that will not move. Greenfield teams in 2026 usually pick:

  • GitHub Actions: closest to the repo most people already use. Matrix builds, OIDC to cloud, a huge action ecosystem. Watch minute cost and reusable workflows so every squad does not fork a broken YAML.
  • GitLab CI: pipeline and repo and registry and security in one product. Strong if you want fewer vendors.
  • Azure DevOps: still the default in Microsoft-heavy enterprises, Boards plus Pipelines plus Artifacts.
  • CircleCI, Buildkite, Tekton: when you want dedicated runners, or Kubernetes-native pipelines as CRDs.
  • Jenkins / Jenkins X: keep it if the plugin city is already paid for. Do not start there without a reason.

CI is the easy half. CD is where teams stall. The pattern that won is GitOps:

  • Argo CD or Flux watches Git and reconciles the cluster.
  • Argo Rollouts or Flagger does canary and blue/green, often gated on an SLO or a Grafana alert.
  • Helm or Kustomize packages the app. Helm is the common language. Kustomize is the overlay.

A modern pipeline is not "build then kubectl apply." It is:

  1. Test and scan on the pull request.
  2. Build a signed OCI image and an SBOM.
  3. Push to a registry (ECR, ACR, GAR, Harbor, GHCR).
  4. Open a Git commit that bumps the tag in the env repo.
  5. GitOps syncs. Rollout watches error rate. Fail and the canary dies.
  6. Change event is written so AIOps can later say "this incident started six minutes after that SHA."

That last line is the DevOps-to-AIOps joint. If deploys are invisible, your correlation engine has no cause except "the moon."

CI/CD pipeline from Git commit through tests, image build, GitOps, and production

CI/CD and automation tools, grouped by job

  • Build: GitHub Actions, GitLab CI, Azure Pipelines, CircleCI, Buildkite, Tekton, Jenkins.
  • Deliver: Argo CD, Flux, Spinnaker (legacy), Octopus, cloud-native CodePipeline / Cloud Deploy / DevOps release.
  • Progressive delivery: Argo Rollouts, Flagger, LaunchDarkly-style flags.
  • IaC: Terraform, OpenTofu, Pulumi, Bicep, CloudFormation, Crossplane if you want Kubernetes as the control plane.
  • Config / desired state: Ansible (still fine for metal and VMs), Helm, Kustomize.
  • Policy: OPA/Gatekeeper, Kyverno, HashiCorp Sentinel.
  • Secrets: Vault, cloud secret managers, SOPS, External Secrets Operator.
  • AI-in-the-pipeline: copilot review, test generation, flaky-test clustering. Useful. Not AIOps. Do not rename your Actions file and call the program done.

Monitoring, Observability, and Visualization

Monitoring asks "is it up?" Observability asks "why is it weird?" You need both. A green dashboard with no traces is a lie factory. A trace lake with no SLO is a hobby (Google SRE, 2016; Gartner, 2026).

The contract that matters now is OpenTelemetry. Instrument once. Export to whoever you pay this year. Gartner's observability definition now includes applications, infrastructure, and AI agents, with native OTel support as a must (Gartner, 2026). If your vendor still wants a proprietary agent as the only path, price the lock-in out loud.

The signals

  • Metrics: cheap, numeric, good for SLOs and HPA. Prometheus, VictoriaMetrics, Mimir, cloud-native CloudWatch / Azure Monitor / Cloud Monitoring.
  • Logs: expensive, high cardinality, still where the exception lives. Loki, Elasticsearch/OpenSearch, cloud log sinks.
  • Traces: the request's path across 14 microservices. Tempo, Jaeger, Zipkin, vendor APM.
  • Events / changes: deploys, scaling, feature flags, node death. The forgotten fourth signal. AIOps starves without it.
  • Profiles and GPU telemetry: continuous profiling, DCGM for NVIDIA. Required once you serve models.

The open stack versus the paid suite

Open, common, and good enough for many teams: OpenTelemetry Collector, Prometheus, Grafana, Loki, Tempo (the LGTM stack), Alertmanager, maybe Grafana IRM. Add OpenCost or Kubecost for money. This is the default I would start on a greenfield cluster.

Paid suites that collapse the last mile: Datadog, Dynatrace, New Relic, Splunk Observability, Elastic Observability, Azure Monitor + App Insights, AWS X-Ray + CloudWatch, Google Cloud Operations. You pay to skip glue work and to get a stronger service map. Several of them now sell the AIOps layer as an add-on: anomaly detection, watchdogs, Davis, Watchdog, whatever the brand is this quarter (Network World, 2025).

Visualization that is not wallpaper

Grafana is the lingua franca. A useful board is built around a question:

  • Are we burning the SLO?
  • What changed in the last deploy?
  • Which dependency is slow?
  • Are we about to scale, or already late?
  • For a model service: queue depth, TTFT, tokens per second, GPU memory, KV-cache hit rate.

Pretty red/green tiles with no unit and no owner are how on-call goes blind. One service, one SLO row, one drill-down to traces. Then let AIOps use the same queries as features, not a second copy of the truth.

Observability pillars metrics, logs, and traces feeding a Grafana-style dashboard

Autoscaling and Scalability

Scaling is where DevOps automation and AIOps prediction shake hands. Classic DevOps writes an HPA: if CPU is above 70 percent, add pods. That is a thermostat. AIOps-shaped scaling asks a better question: will the queue explode in twelve minutes, and do we need a GPU node, not just another replica?

  • Kubernetes HPA: CPU, memory, or custom metrics. Still the first tool. Fine for stateless HTTP.
  • VPA: right-size the pod. Dangerous if you let it evict blindly. Use as a recommender first.
  • KEDA: scale on Kafka lag, SQS depth, Prometheus queries, cron, or "requests waiting" on a model server. CNCF graduated. This is the workhorse for event-driven and inference queues (AWS, 2024).
  • Cluster / node autoscaling: Cluster Autoscaler, Karpenter on AWS, GKE node auto-provisioning, AKS node pools. This is how GPUs appear when a training job or a vLLM replica asks.
  • Cloud VM scale groups: ASG, VMSS, MIGs. Still real for the non-Kubernetes half of the company.
  • Serverless: Lambda, Cloud Functions, Azure Functions, Cloud Run. The platform scales. You still observe cold starts and concurrency caps.
  • Predictive / schedule-based: known peaks (9 a.m. login storm) should be a cron, not a surprise. Predictive AWS/Azure policies help. A model that scales on last month's Black Friday without a dry run will scale the wrong region.

Problem: a flash sale hits. HPA waits for CPU. CPU is fine because the app is blocked on checkout queue.
Cause: you scaled on the wrong signal.
Effect: latency dies, replicas stay at two. KEDA on queue depth, plus a load-test in CI, is the DevOps fix. Predicting the sale from marketing calendar plus last year's curve is the AIOps upgrade. Do the first before you buy the second.

Autoscaling from a few pods to many using HPA, KEDA, and node provisioners

Cloud Services: The Same Jobs, Three Catalogs

Pick a cloud for data gravity and people, not for a logo on a slide. The jobs stay the same.

Same job, three product names Job AWS Azure GCP CI/CD CodePipeline, CodeBuild Azure DevOps, GitHub Cloud Build, Cloud Deploy Kubernetes EKS + Karpenter AKS GKE (Autopilot/NAP) Observe CloudWatch, X-Ray, AMP Monitor, App Insights Cloud Operations, Trace IaC CloudFormation, CDK Bicep, ARM Deployment Manager Train / tune SageMaker Azure Machine Learning Vertex AI Hosted models Bedrock Azure OpenAI Gemini on Vertex Serverless Lambda, ECS/Fargate Functions, ACA Cloud Run, Functions Portable core most teams should still own: Terraform, OTel, GitHub/GitLab, Argo CD, Prometheus or a vendor that speaks OTLP. Use the cloud AI studio when you want less GPU plumbing, not less discipline.
AWS, Azure, and GCP mapped across CI/CD, Kubernetes, monitoring, and AI training

Multi-cloud as a religion is expensive. Multi-cloud as "we can leave" is a Terraform module and OTel. AIOps products that only understand one vendor's events will lie about the other 40 percent of your estate. That is a buying criterion, not a footnote.

Deploying and Training AI Models (MLOps, Not a Rebrand)

Hidden Technical Debt in Machine Learning Systems is still the paper to hand a VP who thinks a Jupyter notebook is a product (Sculley et al., 2015). Models rot. Data shifts. A 2 percent accuracy drop can be a silent outage because no HTTP code turns red.

The path that matches a DevOps shop:

  1. Data: versioned datasets, not a shared drive. DVC, a lakehouse table, or the cloud feature store (SageMaker Feature Store, Vertex Feature Store, Feast).
  2. Train: a job, not a laptop. Kubeflow Training, SageMaker Training, Vertex Custom Jobs, Azure ML jobs, or Argo Workflows on a GPU pool.
  3. Evaluate: holdout metrics plus, for LLMs, an eval harness (lm-eval, RAGAS-style checks, a golden prompt set). Gate the promote step on those numbers, the way you gate a canary on error rate.
  4. Register: MLflow Model Registry, or the cloud registry. Name, version, lineage, who approved.
  5. Package: a container, or a model URI that KServe / SageMaker / Vertex can pull. Sign it.
  6. Serve: KServe for classic ML, vLLM or TensorRT-LLM for large language models, or a managed endpoint (SageMaker, Azure ML online, Vertex prediction, Bedrock/Azure OpenAI if you are calling a hosted API).
  7. Observe the model: not only pod CPU. Drift, token latency, quality scores, GPU memory, queue depth. This telemetry is what AIOps later correlates with "checkout conversion fell."
  8. Retrain or rollback: a GitOps tag back to the last good model is a first-class incident action.

Inference in 2026 has its own DevOps dialect: NVIDIA GPU Operator, MIG or time-slicing, KV-cache-aware routing, scale-to-zero for overnight dev models, KEDA on num_requests_waiting. That is still DevOps. The AIOps layer is "this model's p95 TTFT just left the SLO and it started six minutes after we shipped tokenizer X."

Train, evaluate, register, and serve models with MLflow and KServe or vLLM

Automation: Scripts, GitOps, Then Closed Loops

Automation is a ladder. Climb it in order.

  1. Manual with a checklist. You cannot automate a process you cannot name.
  2. Scripted. Bash, Python, Ansible. Fine for a fleets of VMs. Still the glue.
  3. Pipeline. CI/CD runs the script the same way every time.
  4. Reconcile. GitOps and controllers. Drift is an error, not a lifestyle.
  5. Policy. The cluster refuses a privileged pod. Humans stop being the linter.
  6. Suggested action. AIOps says "roll back SHA abc, 80 percent confidence." A human clicks.
  7. Closed loop. The same action runs inside a blast-radius box: only this namespace, only this runbook, only if the SLO is already burning.

Most companies that "bought AIOps" are stuck on step 2 with a nicer UI. The ones that get value already had steps 3 to 5. That is the entire thesis of this post in one ladder.

How a DevOps Team Becomes an AIOps Practice

You do not hire a prophet and a new logo. You grow the data and the trust.

  1. Instrument everything that pages you. OTel SDK or auto-instrumentation on the top 20 services. No orphans.
  2. One collector, one schema. Resource attributes: service.name, deployment.environment, version, team. This is how later clustering works.
  3. Emit change events. Every Argo sync, every flag flip, every Terraform apply. Put them next to metrics.
  4. Build a service map you would bet money on. Even a simple ownership YAML plus generated topology beats folklore.
  5. Reduce monitors. Delete the ones nobody has acted on in 90 days. AIOps on junk is expensive junk.
  6. Correlate before you predict. Dedup and grouping pay back in week one. Prediction is year two.
  7. Suggest, then automate one runbook. Restart a known-stuck worker. Scale a known queue. Rollback a canary. Measure how often the human overrides.
  8. Feed overrides back. If operators always reject a class of alerts, the model should learn or the monitor should die.
  9. Put AI actions behind the same GitOps door. An auto-fix that kubectl-edits prod and leaves no commit is a ghost. Write the revert as a PR or a recorded sync.
  10. Keep people. AIOps removes toil, not accountability. The on-call still owns the SLO. The model is a junior that never sleeps and sometimes hallucinates a root cause.
Five steps from instrumentation to closed-loop automation in CI/CD

Problem: leadership bought a platform after a terrible quarter of incidents.
Cause: they wanted a brain. They had no consistent service names and three conflicting CMDB-ish spreadsheets.
Effect: the demo looked smart on vendor data. On yours it grouped nothing. Spend the first quarter on naming, OTel, and deploy events. Then turn the model on. That sequence is how DevOps becomes AIOps without a reorg theater.

What Really Matters Now

Ignore the slide that says "AI will replace Ops." The constraints that actually decide whether you ship and stay up in 2026:

  • Telemetry cost. Logs will bankrupt you before models will save you. Sample, drop debug in prod, keep traces on the error path. Gartner now rates vendors on retention controls for a reason (Network World, 2025).
  • Open standards. OTel, Prometheus remote write, Git, OCI. These outlive the AIOps logo on this year's PO.
  • Change awareness. The highest-signal feature in any incident tool is "what shipped?" Wire GitOps into the incident object on day one.
  • SLOs over raw alerts. Page on user pain, not on a disk that is allowed to be busy.
  • Progressive delivery. A bad model or a bad binary should hit 5 percent of traffic, not 100 percent. Canary plus auto-rollback is worth more than a clever chatbot in Slack.
  • GPU and queue signals. If you serve models, CPU HPA is a museum piece. Watch queue and TTFT.
  • Identity and blast radius. Closed-loop remediation with a god-mode service account is how you automate a worse outage. Scoped roles, dry-run, and an audit trail.
  • Platform, not heroics. One paved road. Ten unique Jenkinsfiles is why AIOps has nothing consistent to learn from.
  • Humans who can still debug. When the model is wrong, someone must read a trace. That is still a DevOps skill. Teach it. The last post on visual programming was not a detour. Logic still comes before the copilot.

A Worked Example

Imagine a checkout API on EKS, a payments worker on a queue, and a fraud model on KServe.

DevOps layer. Code lives in GitHub. Actions runs tests and Trivy. The image is signed and stored in ECR. A tag bump in the env repo is synced by Argo CD. Rollouts sends 10 percent of traffic to the new checkout. Terraform owns the cluster and the IAM roles. HPA covers the API. KEDA covers the worker. The model has its own deploy pipeline and an MLflow version.

Observability layer. Each service emits OTel traces. RED metrics (rate, errors, duration) sit in Prometheus. Grafana has one checkout SLO board. Deploy events are annotations. The fraud model exports drift and score-latency.

AIOps layer. At 18:40 error rate climbs. Raw alerts: API 5xx, worker lag, KEDA scale events, a CloudWatch RDS CPU blip, and fraud latency. Correlation groups them. Enrichment shows a model version bump at 18:34 and a schema field the worker now drops. Suggestion: roll back model v17, not the API. A human confirms the first time. The second time, policy allows auto-rollback of that model registry stage only. MTTR is 11 minutes instead of 90. The GitOps repo has a commit that says why.

That is the whole architecture in one incident. No new job family required. A DevOps team that kept its telemetry honest, plus one closed loop.

What to Buy, What to Build

  • Build (or standardize) the paved road: Git, CI, GitOps, OTel collector, a default dashboards folder, naming rules.
  • Buy or adopt when glue hurts: a full observability suite if you lack people to run LGTM. An event-intelligence product when you already have more than ~20 noisy sources and a real CMDB/service catalog.
  • Rent GPUs and model APIs: SageMaker, Vertex, Azure ML, Bedrock, Azure OpenAI. Keep registry, eval gates, and rollback in your repo.
  • Do not buy: a second CI system "for AI," an AIOps tool before you have service names, or a copilot seat as a substitute for on-call training.

DevOps made change a habit. AIOps makes sense of the exhaust that habit creates. MLOps is the same habit applied to models. The fashion is to flatten all three into "we are an AI-driven enterprise." The work is plainer. Name the services. Ship through Git. Watch with OpenTelemetry. Scale on the signal that hurts. Let a model group the pages only after those sentences are true.

If you remember one line: AIOps is not a replacement for DevOps. It is DevOps with a memory, a map, and a brake.

References

Sunday, 14 September 2025

Mastering Terraform CI/CD Integration: Automating Infrastructure Deployments (Part 10)

Standard

So far, we’ve run Terraform manually: init, plan, and apply. That works fine for learning or small projects, but in real-world teams you need automation:

  • Infrastructure changes go through version control
  • Every change is reviewed before deployment
  • Terraform runs automatically in CI/CD pipelines

This is where Terraform and CI/CD fit together perfectly.

Why CI/CD for Terraform?

  • Consistency → Every change follows the same workflow
  • Collaboration → Code reviews catch mistakes before they reach production
  • Automation → No more manual terraform apply on laptops
  • Security → Restrict who can approve and apply changes

Typical Terraform Workflow in CI/CD

  1. Developer pushes code → Terraform configs to GitHub/GitLab
  2. CI pipeline runs → terraform fmt, validate, and plan
  3. Reviewers approve → Pull Request reviewed and merged
  4. CD pipeline runs → terraform apply in staging/production

Example: GitHub Actions Workflow

A simple CI/CD pipeline using GitHub Actions:

name: Terraform CI/CD

on:
  pull_request:
    branches: [ "main" ]
  push:
    branches: [ "main" ]

jobs:
  terraform:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Setup Terraform
        uses: hashicorp/setup-terraform@v2

      - name: Terraform Format
        run: terraform fmt -check

      - name: Terraform Init
        run: terraform init

      - name: Terraform Validate
        run: terraform validate

      - name: Terraform Plan
        run: terraform plan

Here’s the flow:

  • On pull requests, Terraform runs checks and plan
  • On main branch push, you can extend this to run apply

Example: GitLab CI/CD

stages:
  - validate
  - plan
  - apply

validate:
  stage: validate
  script:
    - terraform init
    - terraform validate

plan:
  stage: plan
  script:
    - terraform plan -out=tfplan
  artifacts:
    paths:
      - tfplan

apply:
  stage: apply
  script:
    - terraform apply -auto-approve tfplan
  when: manual

Notice that apply is manual → requires approval before execution.

Best Practices for Terraform CI/CD

  1. Separate stages → validate, plan, apply.
  2. Require approval for terraform apply (especially in production).
  3. Store state remotely (S3, Terraform Cloud, or Azure Storage).
  4. Use workspaces or separate pipelines for dev, staging, and prod.
  5. Scan for security → run tools like tfsec or Checkov.

Case Study: Enterprise DevOps Team

A large enterprise adopted Terraform CI/CD:

  • Every change went through pull requests
  • Automated pipelines ran plan on PRs
  • Senior engineers approved apply in production

Impact:

  • Faster delivery cycles
  • Zero manual runs on laptops
  • Full audit history of infrastructure changes

Key Takeaways

  • Terraform + CI/CD = safe, automated, and auditable infrastructure deployments
  • Always separate plan and apply steps
  • Enforce approvals for production
  • Use security scanners for compliance

End of Beginner Series: Mastering Teraform 🎉

We’ve now covered:

  1. Basics of Terraform
  2. First Project
  3. Variables & Outputs
  4. Providers & Multiple Resources
  5. State Management
  6. Modules
  7. Workspaces & Environments
  8. Provisioners & Data Sources
  9. Best Practices & Pitfalls
  10. CI/CD Integration

With these 10 blogs, you can confidently go from Terraform beginner → production-ready workflows.

Bibliography

Friday, 12 September 2025

Mastering Terraform Best Practices & Common Pitfalls: Write Clean, Scalable IaC (Part 9)

Standard

By now, you’ve learned how to build infrastructure with Terraform variables, modules, workspaces, provisioners, and more. But as your projects grow, the quality of your Terraform code becomes just as important as the resources it manages.

Poorly structured Terraform leads to:

  • Fragile deployments
  • State corruption
  • Hard-to-maintain infrastructure

In this blog, we’ll cover best practices to keep your Terraform projects clean, scalable, and safe—along with common mistakes you should avoid.

Best Practices in Terraform

1. Organize Your Project Structure

Keep your files modular and organized:

terraform-project/
  main.tf
  variables.tf
  outputs.tf
  dev.tfvars
  staging.tfvars
  prod.tfvars
  modules/
    vpc/
    s3/
    ec2/
  • main.tf → core resources
  • variables.tf → inputs
  • outputs.tf → outputs
  • modules/ → reusable building blocks

✅ Makes it easier for teams to understand and collaborate.

2. Use Remote State with Locking

Always use remote backends (S3 + DynamoDB, Azure Storage, or Terraform Cloud).
This prevents:

  • Multiple people overwriting state
  • Lost state files when laptops die

✅ Ensures collaboration and consistency.

3. Use Variables & Outputs Effectively

  • Don’t hardcode values → use variables.tf and .tfvars
  • Expose important resource info (like DB endpoints) using outputs.tf

✅ Makes your infrastructure reusable and portable.

4. Write Reusable Modules

  • Put repeating logic into modules
  • Source modules from the Terraform Registry when possible
  • Version your custom modules in Git

✅ Saves time and avoids code duplication.

5. Tag Everything

Always tag your resources:

tags = {
  Environment = terraform.workspace
  Owner       = "DevOps Team"
}

✅ Helps with cost tracking, compliance, and audits.

6. Use CI/CD for Terraform

Integrate Terraform with GitHub Actions, GitLab, or Jenkins:

  • Run terraform fmt and terraform validate on pull requests
  • Automate plan → approval → apply

✅ Infrastructure changes get the same review process as application code.

7. Security First

  • Never commit secrets into .tfvars or GitHub
  • Use Vault, AWS Secrets Manager, or Azure Key Vault
  • Restrict who can terraform apply in production

✅ Protects your organization from accidental leaks.

Common Pitfalls (and How to Avoid Them)

❌ 1. Editing the State File Manually

Tempting, but dangerous.

  • One wrong edit = corrupted state
  • Instead, use commands like terraform state mv or terraform state rm

❌ 2. Mixing Environments in One State File

Don’t put dev, staging, and prod in the same state.

  • Use workspaces or separate state backends

❌ 3. Overusing Provisioners

Provisioners are not meant for full configuration.

  • Use cloud-init, Ansible, or Packer instead

❌ 4. Ignoring terraform fmt and Validation

Unreadable code slows teams down.

  • Always run:

terraform fmt
terraform validate

❌ 5. Not Pinning Provider Versions

If you don’t lock versions, updates may break things:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

❌ 6. Ignoring Drift

Infrastructure can change outside Terraform (console clicks, APIs).

  • Run terraform plan regularly
  • Use drift detection tools (Terraform Cloud, Atlantis)

Case Study: Large Enterprise Team

A global bank adopted Terraform but initially:

  • Mixed prod and dev in one state file
  • Used manual state edits
  • Had no CI/CD for Terraform

This caused outages and state corruption.

After restructuring:

  • Separate backends for each environment
  • Introduced GitHub Actions for validation
  • Locked provider versions

Result: Stable, auditable, and scalable infrastructure as code.

Key Takeaways

  • Organize, modularize, and automate Terraform projects.
  • Use remote state, workspaces, and CI/CD for team collaboration.
  • Avoid pitfalls like manual state edits, provisioner overuse, and unpinned providers.

Terraform isn’t just about writing code, it’s about writing clean, safe, and maintainable infrastructure code.

What’s Next?

In this Series Blog 10, we’ll close the mastering beginner series with Terraform CI/CD Integration, automating plan and apply with GitHub Actions or GitLab CI for production-grade workflows.

Bibliography


Thursday, 11 September 2025

Mastering Terraform Provisioners & Data Sources: Extending Your Infrastructure Code (Part 8)

Standard

So far in Previous Blog Series, we’ve built reusable Terraform projects with variables, outputs, modules, and workspaces. But sometimes you need more:

  • Run a script after a server is created
  • Fetch an existing resource’s details (like VPC ID, AMI ID, or DNS record)

That’s where Provisioners and Data Sources come in.

What Are Provisioners?

Provisioners let you run custom scripts or commands on a resource after Terraform creates it.

They’re often used for:

  • Bootstrapping servers (installing packages, configuring users)
  • Copying files onto machines
  • Running one-off shell commands

Example: local-exec

Runs a command on your local machine after resource creation:

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  provisioner "local-exec" {
    command = "echo ${self.public_ip} >> public_ips.txt"
  }
}

Here, after creating the EC2 instance, Terraform saves the public IP to a file.

Example: remote-exec

Runs commands directly on the remote resource (like an EC2 instance):

resource "aws_instance" "web" {
  ami           = "ami-0c55b159cbfafe1f0"
  instance_type = "t2.micro"

  connection {
    type     = "ssh"
    user     = "ec2-user"
    private_key = file("~/.ssh/id_rsa")
    host     = self.public_ip
  }

  provisioner "remote-exec" {
    inline = [
      "sudo yum update -y",
      "sudo yum install -y nginx",
      "sudo systemctl start nginx"
    ]
  }
}

This automatically installs and starts Nginx on the server after it’s created.

⚠️ Best Practice Warning:
Provisioners should be used sparingly. For repeatable setups, use configuration management tools like Ansible, Chef, or cloud-init instead of Terraform provisioners.

What Are Data Sources?

Data sources let Terraform read existing information from providers and use it in your configuration.

They don’t create resources—they fetch data.

Example: Fetch Latest AMI

Instead of hardcoding an AMI ID (which changes frequently), use a data source:

data "aws_ami" "latest_amazon_linux" {
  most_recent = true
  owners      = ["amazon"]

  filter {
    name   = "name"
    values = ["amzn2-ami-hvm-*-x86_64-gp2"]
  }
}

resource "aws_instance" "web" {
  ami           = data.aws_ami.latest_amazon_linux.id
  instance_type = "t2.micro"
}

Terraform fetches the latest Amazon Linux 2 AMI and uses it to launch the EC2 instance.

Example: Fetch Existing VPC

data "aws_vpc" "default" {
  default = true
}

resource "aws_subnet" "my_subnet" {
  vpc_id     = data.aws_vpc.default.id
  cidr_block = "10.0.1.0/24"
}

This looks up the default VPC in your account and attaches a new subnet to it.

Case Study: Startup with Hybrid Infra

A startup had:

  • A few manually created AWS resources (legacy)
  • New resources created via Terraform

Instead of duplicating legacy resources, they:

  • Used data sources to fetch existing VPCs and security groups
  • Added new Terraform-managed resources inside those

Result: Smooth transition to Infrastructure as Code without breaking existing infra.

Case Study: Automated Web Server Setup

A small dev team needed a demo web server:

  • Terraform created the EC2 instance
  • A remote-exec provisioner installed Apache automatically
  • A data source fetched the latest AMI

Result: One command (terraform apply) → Fully working web server online in minutes.

Best Practices

  • Use data sources wherever possible (instead of hardcoding values).
  • Limit provisioners—prefer cloud-init, Packer, or config tools for repeatability.
  • Keep scripts idempotent (safe to run multiple times).
  • Test provisioners carefully—errors can cause Terraform runs to fail.

Key Takeaways

  • Provisioners = Run custom scripts during resource lifecycle.
  • Data Sources = Fetch existing provider info for smarter automation.
  • Together, they make Terraform more flexible and powerful.

What’s Next?

In Blog 9, we’ll dive into Terraform Best Practices & Common Pitfalls—so you can write clean, scalable, and production-grade Terraform code.

Bibliography

Wednesday, 10 September 2025

Mastering Terraform Workspaces & Environments: Manage Dev, Staging, and Prod with Ease (Part 7)

Standard

In real-world projects, we don’t just have one environment.

We often deal with:

  • Development → for experiments and new features
  • Staging → a near-production environment for testing
  • Production → stable and customer-facing

Manually managing separate Terraform configurations for each environment can get messy.
This is where Terraform Workspaces come in.

What Are Workspaces?

A workspace in Terraform is like a separate sandbox for your infrastructure state.

  • Default workspace = default
  • Each new workspace = a different state file
  • Same Terraform code → Different environments

This means you can run the same code for dev, staging, and prod, but Terraform will keep track of resources separately.

Creating and Switching Workspaces

Commands:

# Create a new workspace
terraform workspace new dev

# List all workspaces
terraform workspace list

# Switch to staging
terraform workspace select staging

Output might look like:

* default
  dev
  staging
  prod

Note: The * shows your current workspace.

Using Workspaces in Code

You can reference the current workspace inside your Terraform files:

resource "aws_s3_bucket" "env_bucket" {
  bucket = "my-bucket-${terraform.workspace}"
  acl    = "private"
}

If you’re in the dev workspace, Terraform creates my-bucket-dev.
In prod, it creates my-bucket-prod.

Case Study: SaaS Company Environments

A SaaS startup had 3 environments:

  • Dev → 1 EC2 instance, small database
  • Staging → 2 EC2 instances, medium database
  • Prod → Auto Scaling group, RDS cluster

Instead of duplicating code, they:

  • Used workspaces for environment isolation.
  • Passed environment-specific variables (dev.tfvars, prod.tfvars).
  • Used the same Terraform codebase for all environments.

Result: Faster deployments, fewer mistakes, and cleaner codebase.

Best Practices for Workspaces

  1. Use workspaces for environments, not for feature branches.
  2. Combine workspaces with variable files (dev.tfvars, staging.tfvars, prod.tfvars).
  3. Keep environment-specific resources in separate state files when complexity grows.
  4. For large orgs, consider separate projects/repos for prod vs non-prod.

Example Project Setup

terraform-project/
  main.tf
  variables.tf
  outputs.tf
  dev.tfvars
  staging.tfvars
  prod.tfvars

Workspace Workflow

  • Select environment: terraform workspace select dev
  • Apply with environment variables: terraform apply -var-file=dev.tfvars

Terraform will deploy resources specifically for that environment.

Advanced Examples with Workspaces

1. Naming Resources per Environment

Workspaces let you build dynamic naming patterns to keep environments isolated:

resource "aws_db_instance" "app_db" {
  identifier = "app-db-${terraform.workspace}"
  engine     = "mysql"
  instance_class = var.db_instance_class
  allocated_storage = 20
}
  • app-db-dev → Small DB for development
  • app-db-staging → Medium DB for staging
  • app-db-prod → High-performance RDS for production

This avoids resource name collisions across environments.

2. Using Workspaces with Remote Backends

Workspaces work especially well when paired with remote state backends like AWS S3 + DynamoDB:

terraform {
  backend "s3" {
    bucket         = "my-terraform-states"
    key            = "env/${terraform.workspace}/terraform.tfstate"
    region         = "us-east-1"
    dynamodb_table = "terraform-locks"
  }
}

Here, each environment automatically gets its own state file path inside the S3 bucket:

  • env/dev/terraform.tfstate
  • env/staging/terraform.tfstate
  • env/prod/terraform.tfstate

This ensures isolation and safety when multiple team members collaborate.

3. CI/CD Pipelines with Workspaces

In modern DevOps, CI/CD tools like GitHub Actions, GitLab CI, or Jenkins integrate with workspaces.

Example with GitHub Actions:

- name: Select Workspace
  run: terraform workspace select ${{ github.ref_name }} || terraform workspace new ${{ github.ref_name }}

- name: Terraform Apply
  run: terraform apply -auto-approve -var-file=${{ github.ref_name }}.tfvars

If the pipeline runs on a staging branch, it will automatically select (or create) the staging workspace and apply the correct variables.

Case Study 1: E-commerce Company

An e-commerce company used to manage separate repos for dev, staging, and prod. This caused:

  • Drift (prod configs didn’t match dev)
  • Duplication (same code copied in three places)

They migrated to one codebase with workspaces:

  • Developers tested features in dev workspace
  • QA validated changes in staging
  • Ops deployed to prod

Impact: Reduced repo sprawl, consistent infrastructure, and easier audits.

Case Study 2: Financial Services Firm

A financial services company needed strict isolation between prod and non-prod environments due to compliance.
They used:

  • Workspaces for logical separation
  • Separate S3 buckets for prod vs non-prod states
  • Access controls (prod state bucket restricted to senior engineers only)

Impact: Compliance achieved without duplicating Terraform code.

Case Study 3: Multi-Region Setup

A startup expanding globally used workspaces per region:

  • us-east-1
  • eu-west-1
  • ap-south-1

Each workspace deployed the same infrastructure stack but in a different AWS region.
This let them scale across regions without rewriting Terraform code.

Pro Tips for Scaling Workspaces

  • Use naming conventions like env-region (e.g., prod-us-east-1) for clarity.
  • Store environment secrets (DB passwords, API keys) in a vault system, not in workspace variables.
  • Monitor your state files—workspace sprawl can happen if you create too many.

What’s Next?

Now you know how to:

  • Create multiple environments with workspaces
  • Use variables to customize each environment
  • Manage dev/staging/prod with a single codebase


Bibliography

Tuesday, 9 September 2025

Mastering Terraform Modules: Reusable Infrastructure Code Made Simple (part 6)

Standard

When building infrastructure with Terraform, copying and pasting the same code across projects quickly becomes messy.

Terraform Modules solve this by letting you write code once and reuse it anywhere—for dev, staging, production, or even multiple teams.

In this blog, you’ll learn:

  • What Terraform Modules are
  • How to create and use them
  • Real-world examples and best practices

What Are Terraform Modules?

A module in Terraform is just a folder with Terraform configuration files (.tf) that define resources.

  • Root module → Your main project directory.
  • Child module → A reusable block of Terraform code you call from the root module.

Think of modules as functions in programming:

  • Input → Variables
  • Logic → Resources
  • Output → Resource details

Why Use Modules?

  1. Reusability → Write once, use anywhere.
  2. Maintainability → Fix bugs in one place, apply everywhere.
  3. Consistency → Ensure similar setups across environments.
  4. Collaboration → Share modules across teams.

Creating Your First Terraform Module

Step 1: Create Module Folder

terraform-project/
  main.tf
  variables.tf
  outputs.tf
  modules/
    s3_bucket/
      main.tf
      variables.tf
      outputs.tf

Step 2: Define the Module (modules/s3_bucket/main.tf)

variable "bucket_name" {
  description = "Name of the S3 bucket"
  type        = string
}

resource "aws_s3_bucket" "this" {
  bucket = var.bucket_name
  acl    = "private"
}

output "bucket_arn" {
  value = aws_s3_bucket.this.arn
}

Step 3: Call the Module in main.tf

module "my_s3_bucket" {
  source      = "./modules/s3_bucket"
  bucket_name = "my-production-bucket"
}

Run:

terraform init
terraform apply

Terraform will create the S3 bucket using the module.

Using Modules from Terraform Registry

You can also use prebuilt modules:

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "3.14.0"

  name = "my-vpc"
  cidr = "10.0.0.0/16"
}

The Terraform Registry has official modules for AWS, Azure, GCP, and more.

Case Study: Multi-Environment Infrastructure

A startup had:

  • Dev environment → Small resources
  • Staging environment → Medium resources
  • Production environment → High availability setup

They created one module for VPC, EC2, and S3:

  • Passed environment-specific variables (instance size, tags).
  • Reused the same modules for all environments.

Result: Reduced code duplication by 80%, simplified maintenance.

Best Practices for Modules

  1. Keep modules small → Each should focus on one task (e.g., S3, VPC).
  2. Version your modules → Tag releases in Git for stability.
  3. Use meaningful variables & outputs for clarity.
  4. Avoid hardcoding values always use variables.
  5. Document your modules so teams can reuse them easily.

Project Structure with Modules

terraform-project/
  main.tf
  variables.tf
  outputs.tf
  terraform.tfvars
  modules/
    s3_bucket/
      main.tf
      variables.tf
      outputs.tf
    vpc/
      main.tf
      variables.tf
      outputs.tf

What’s Next?

Now you know how to:

  • Create your own modules

  • Reuse community modules

  • Build cleaner, scalable infrastructure

In Part 7, we’ll explore Workspaces & Environments to manage dev, staging, and prod in one Terraform project.

Bibliography