IaC in Regulated Industries: 8 Challenges and Fixes

Eight challenges of Infrastructure as Code in regulated industries, from change evidence and secrets in state to drift and change boards, with fixes.

Aug 26, 2025 - 11:45
Nov 12, 2026 - 14:13
 0  38
TOPICDevOps BasicsPractical guide
IaC in Regulated Industries: 8 Challenges and Fixes

Infrastructure as Code in banks, insurers, hospitals and other regulated businesses runs into problems that ordinary teams can ignore: proving who approved each change, keeping secrets out of state and plan files, enforcing policy before anything is applied, catching drift from manual fixes, and fitting legacy systems and change boards into a Git workflow.

This post walks through those challenges one at a time and shows the controls that address each, using Terraform and Open Policy Agent as the worked examples. For the tools themselves, see our pillar on infrastructure as code tools for DevOps. Product facts were checked against HashiCorp, OPA and Checkov documentation in November 2026. This is engineering guidance, not legal advice; your compliance team decides what a given regulation requires.

Key takeaways

  • Regulators and auditors care about evidence: who requested a change, who approved it, what was deployed and whether it matched what was approved. A Git-plus-pipeline workflow can produce that evidence, but only if direct console changes are blocked.
  • Terraform state and saved plan files can contain secrets. The sensitive flag only hides values in CLI output. Ephemeral values (Terraform 1.10 and later) and write-only arguments (1.11 and later) keep values out of state and plan files.
  • Policy as code tools such as OPA can evaluate a Terraform plan before apply. Scanners such as Checkov catch common misconfigurations in source files.
  • Remote, encrypted, versioned state with locking and audit logs is the baseline. In the S3 backend, DynamoDB locking is deprecated in favour of use_lockfile.
  • The hardest problems are organisational: change advisory boards, separation of duties, legacy systems that cannot be described in code, and staff used to fixing things by hand.

Why regulated environments are different

A start-up adopting IaC mostly wants speed and repeatability. A regulated firm wants those too, but it also has to show an outside party that every change to production was authorised, tested and traceable, and that sensitive data stayed protected along the way. Frameworks differ by sector and country, yet most of them ask for the same kinds of controls: change management, access control, segregation of duties, logging, encryption and periodic review.

IaC can make those controls easier to prove, because every change becomes a commit, a review and a pipeline run. It can also create new risks. A pipeline with administrator credentials is a powerful target, a state file can hold database passwords in plain text, and a single module change can alter hundreds of resources at once. The challenges below come from that tension. If you want the broader DevOps view of compliance, our post on ensuring compliance in regulated industries with DevOps covers process and culture; this one stays with the infrastructure code itself.

Challenge 1: Proving change control from code to cloud

Auditors usually want to trace a production change back to a ticket, a reviewer and an approval, and forward to the exact resources it touched. With IaC, the natural trail is: an issue or change record, a branch, a pull request with review, a saved plan, an approval, and an apply that uses that saved plan.

The gaps tend to appear in three places. First, people still make console changes during incidents, so the code no longer describes reality. Second, plans are generated on a laptop and never stored, so nobody can show what was approved. Third, the person who wrote the change can also approve and apply it, which breaks segregation of duties.

Practical controls:

  • Protect the main branch and require at least one reviewer who is not the author.
  • Generate the plan in the pipeline, save it as an artifact, and apply that exact plan file after approval rather than re-planning.
  • Give the apply stage its own credentials, used only by the pipeline. Human accounts get read-only access to production by default, with break-glass access logged and reviewed.
  • Keep pipeline logs and plan artifacts for as long as your retention policy requires.
terraform init
terraform plan -out=tfplan.binary
terraform show -json tfplan.binary > tfplan.json
# store tfplan.binary and tfplan.json as pipeline artifacts
# after approval, in a later stage:
terraform apply tfplan.binary

Challenge 2: Secrets in state and plan files

This is the issue that surprises teams most often. Terraform's documentation is explicit: marking a variable or output as sensitive redacts it from CLI output and the HCP Terraform UI, but it does not keep the value out of state or plan files. Local state files are plaintext and include any secrets your configuration defines.

Newer Terraform versions give you better options. Ephemeral variables, ephemeral child-module outputs and the ephemeral block arrived in Terraform 1.10, and Terraform omits ephemeral values from state and plan files entirely. Write-only arguments on managed resources arrived in 1.11. They usually end in _wo and come with a matching _wo_version argument that you increment when the value changes. The provider uses the value during the operation and Terraform discards it afterwards.

Even with these features, treat state as sensitive data:

  • Store it remotely, not on laptops or in Git.
  • Encrypt it at rest. The S3 backend's encrypt option enables server-side encryption of the state and lock files, and kms_key_id lets you use a customer managed key.
  • Restrict who can read it and keep access logs.
  • Enable bucket versioning, which HashiCorp strongly recommends so you can recover from accidental deletion.

Our guide to storing secrets in Ansible and Terraform projects goes further into vault integrations and secret managers.

Challenge 3: Enforcing policy before apply

Manual review does not scale when one pull request can change many resources. Regulated teams need machine-checked rules such as "no public storage buckets," "all databases encrypted," or "no IAM changes without security sign-off," and they need those checks to run before anything reaches the cloud.

Two complementary approaches work well together. Static scanners read the source files. Checkov, for example, scans Terraform, CloudFormation, ARM templates, Kubernetes manifests, Helm charts, Dockerfiles and more, and ships with more than 750 predefined policies plus support for custom ones. Plan-time policy engines read the planned changes instead. The Open Policy Agent documentation shows the pattern: convert the saved plan to JSON and evaluate it with a Rego policy.

package terraform.analysis

default authz := false

authz if {
    score < blast_radius
    not touches_iam
}

In OPA's example, score is a weighted count of creates, updates and deletes, and blast_radius is a threshold. The plan is allowed only when it stays below the threshold and does not touch IAM. You run it with opa exec --decision terraform/analysis/authz --bundle policy/ tfplan.json. The value for a regulated team is that the rule itself lives in Git, gets reviewed, and produces a recorded pass or fail for every change. For a wider look at the tools, see which DevOps tools lead policy as code adoption.

A common mistake is to switch every policy to "block" on day one. Teams then disable the checks to get urgent work through. Start with warnings, measure how often each rule fires, fix the noisy ones, and then make the important rules blocking.

Challenge 4: Drift and out-of-band changes

Drift is the gap between what the code says and what is actually running. In regulated settings it matters twice: it means production differs from what was approved, and it means the next apply may silently undo an emergency fix.

Drift usually comes from incident fixes in the console, from other tools that manage the same resources, and from vendors or support staff with direct access. The controls are partly technical and partly procedural:

  • Run a scheduled terraform plan against each environment and alert when it shows changes nobody committed.
  • When an emergency change is made by hand, require a follow-up pull request that brings the code back in line, and link it to the incident record.
  • Make one tool the owner of each resource. Two tools changing the same security group is a recipe for a failed audit.
  • Reduce standing human write access so drift becomes rare rather than routine.

Challenge 5: State, locking and environment separation

Many compliance programmes expect production to be separated from non-production, with different people allowed to change each. In IaC terms this means separate state for each environment, often in separate cloud accounts or subscriptions, with access controls on each backend.

Locking prevents two pipeline runs from writing the same state at the same time. HashiCorp's S3 backend page now marks DynamoDB-based locking as deprecated and says it will be removed in a future minor version. The replacement is use_lockfile = true, which stores a lock object next to the state and needs s3:GetObject, s3:PutObject and s3:DeleteObject on it. Both settings can be used together while you migrate. Our post on remote state management in Terraform covers backend choices in more depth.

terraform {
  backend "s3" {
    bucket       = "example-tfstate-prod"
    key          = "network/terraform.tfstate"
    region       = "ap-south-1"
    encrypt      = true
    use_lockfile = true
  }
}

Challenge 6: Legacy systems and partial coverage

Regulated firms rarely start fresh. They have mainframes, appliances, on-premises virtualisation and vendor-managed systems, some of which have no usable API or provider. Trying to bring everything under IaC at once usually stalls.

A more realistic approach is to draw a clear boundary. New cloud workloads are code-only from the first day. Existing resources are imported in priority order, starting with the ones that change often or carry the most risk. Systems that cannot be described in code stay under the existing change process, and the documentation says so explicitly, so an auditor sees a deliberate scope rather than an accidental gap. Configuration management tools such as Ansible often bridge the space between provisioned infrastructure and what runs on legacy hosts.

Challenge 7: Change boards, approvals and speed

Many regulated organisations route production changes through a change advisory board that meets on a schedule. IaC pipelines can deploy many times a day, so the two models clash. Teams that bypass the board lose audit standing; teams that send every small change to the board lose most of the benefit of automation.

The workable middle ground is to agree categories with the risk and compliance owners. Low-risk, well-tested change types (for example, scaling a known service within limits, or rotating certificates) become pre-approved standard changes, with the pull request, policy results and plan artifact serving as the record. High-risk types, such as network boundary or IAM changes, still go to the board, with the plan output attached so reviewers see exactly what will change.

Challenge 8: Skills and culture

Operations staff who have spent years fixing problems directly in consoles often see IaC as slower, especially during incidents. Developers may write infrastructure code without understanding the controls behind it. Security teams may not read HCL or Rego. None of this is solved by tooling alone.

What helps is shared ownership of a small set of reviewed modules, pairing between operations and development staff on real changes, and making the secure path the easy path: a module that creates an encrypted bucket with logging should be simpler to use than writing one from scratch. Training on the tools matters as well; our Terraform training in Kharadi, Pune and live online covers state, modules and pipeline workflows.

Challenges and controls at a glance

ChallengeTypical riskControls that help
Change traceabilityCannot show who approved what was deployedProtected branches, saved plan artifacts, apply from approved plan
Secrets in statePlaintext credentials in state or plan filesEphemeral values, write-only arguments, encrypted remote state
Policy enforcementMisconfigured resources reach productionCheckov scans, OPA evaluation of plan JSON
DriftProduction differs from approved codeScheduled plans, follow-up PRs after manual fixes
Environment separationSame people and state for test and productionSeparate accounts, backends and pipeline credentials
Legacy coverageUndocumented gaps in IaC scopeExplicit scope, prioritised imports, existing change process for the rest
Change boardsBypassed approvals or stalled deliveryPre-approved standard change types with automated evidence
SkillsUnsafe modules, manual workaroundsShared reviewed modules, pairing, training

A phased adoption path

Teams that succeed usually go in stages. In the first stage they move state to an encrypted remote backend, put all IaC in Git with branch protection, and run plans in a pipeline. In the second they add scanning and plan-time policy in warning mode, plus scheduled drift detection. In the third they remove standing human write access to production, make key policies blocking, and agree standard change categories with the compliance owners. Each stage produces evidence an auditor can review, which makes the next stage easier to approve. Before every deployment, the checks described in infrastructure compliance scans before deployment fit naturally into this pipeline.

Frequently asked questions

Does marking a Terraform variable as sensitive keep it out of state?

No. The sensitive flag only redacts the value from CLI output and the HCP Terraform UI. To keep values out of state and plan files, use ephemeral values (Terraform 1.10 and later) or write-only arguments (1.11 and later).

How can auditors see what was approved in an IaC change?

Save the plan in the pipeline as an artifact, export it with terraform show -json, link it to the pull request and change record, and apply that same saved plan after approval.

Is DynamoDB still needed for Terraform state locking on S3?

HashiCorp marks DynamoDB-based locking as deprecated. Set use_lockfile to true to lock with an S3 object instead. Both can be configured together during migration.

What is the difference between Checkov and OPA for Terraform?

Checkov scans IaC source files against built-in and custom policies. OPA evaluates Rego policies against input such as a Terraform plan converted to JSON, so it sees the actual planned changes.

How do you handle emergency console changes in a regulated IaC setup?

Allow them through a logged break-glass process, then require a follow-up pull request that brings the code back in line, linked to the incident record. Scheduled plans catch any change that was missed.

Can legacy systems be left out of IaC?

Yes, if the scope is explicit. Document which systems stay under the existing change process, import the rest in priority order, and make all new cloud workloads code-only.

References

Interested in learning more?Get a callback from our training advisors.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Angry Angry 0
Sad Sad 0
Wow Wow 0
Mridul I am a passionate technology enthusiast with a strong focus on DevOps, Cloud Computing, and Cybersecurity. Through my blogs at DevOps Training Institute, I aim to simplify complex concepts and share practical insights for learners and professionals. My goal is to empower readers with knowledge, hands-on tips, and industry best practices to stay ahead in the ever-evolving world of DevOps.