Nullify

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.

How to Fix Terraform Misconfigurations in Code, Not in the Cloud Console

To fix Terraform misconfigurations properly, change the Terraform code that created the resource, merge it through review, and let terraform apply push the corrected setting. Don't fix it by hand in the cloud console. A console fix makes the live resource disagree with its code, and the next apply can quietly put the misconfiguration back.

That's the whole rule. The rest of this guide is about how to follow it when you have hundreds of findings and no idea which repository owns which bucket.

Why console fixes don't stay fixed

When security teams talk to us about cloud findings, the same pattern comes up again and again. A public storage bucket gets flagged. Someone with console access flips it to private. The finding closes. Two weeks later, it's back.

The finding didn't come back because the fix was wrong. It came back because the fix was in the wrong place.

HashiCorp's tutorial on managing resource drift explains the mechanics. Terraform refreshes its state against real infrastructure on every plan and apply. If someone changed a resource outside Terraform, a normal plan or apply will try to revert that manual change to match the code. The tutorial warns this can even destroy or recreate resources unintentionally.

So the console fix and the code are now competing. The code wins on the next apply.

The real problem is the gap between the finding and the repo

If the fix is that simple, why do teams keep fixing in the console?

Because a cloud finding names a resource, and the fix lives in a repository. A security engineer looking at an over-permissive IAM role in a production account usually has no fast way to answer three questions:

  1. Which repository's Terraform created this role?
  2. Which module, file and line sets the bad permission?
  3. Who owns that code and can approve the change?

The console is right there, and the repository is a search across dozens of codebases. That's not a discipline problem. It's a missing map from resource to source.

How to fix a Terraform misconfiguration at the source

1. Trace the resource to its code

Start with the resource identifier from the finding. Search your Terraform repositories for the resource name, tags or the module that provisions that type. Tag every resource with its repository and owner at creation time. It pays for itself the first time you need this step.

2. Confirm the live state matches the code

Before changing anything, run terraform plan -refresh-only in that workspace. HashiCorp recommends it for inspecting drift without making changes. If someone already "fixed" the resource in the console, you'll see it here.

3. Change the setting in code

Edit the resource or module argument that creates the misconfiguration. Prefer fixing the module over patching one call site, so every resource built from it is fixed at once.

4. Review the plan, not just the diff

Run terraform plan and read what it will change. A one-line change to a shared module can touch fifty resources. The plan is your blast radius.

5. Merge through your normal pipeline

Open a pull request, get it approved by the code owner, and apply it through CI. The finding closes because the source is fixed, not because someone clicked a toggle.

6. Prevent it next time

Add a policy check or scanner to the pull request pipeline so the same misconfiguration is caught before it's applied again.

Console fix vs code fix

Console fixTerraform code fix
Time to close the findingMinutesHours to days
Survives the next terraform applyNo, it's revertedYes
Fixes every resource built from the moduleNoYes
Leaves an audit trailCloud logs onlyPull request, review and plan
Creates driftYesNo

The point is not that the console is always wrong. For an actively exploited exposure, change the live setting first to stop the bleeding. Then make the code fix the same day, so the emergency change isn't reverted.

Common Terraform misconfigurations worth fixing in code

These are the cloud findings that most often recur after a console fix, because they're set in shared modules:

  • Storage buckets with public access or missing block-public-access settings.
  • Security groups open to 0.0.0.0/0 on admin or database ports.
  • IAM policies with wildcard actions or resources.
  • Unencrypted storage or databases where encryption is a single argument.
  • Logging turned off on buckets, load balancers or API gateways.

Each is usually one argument in one module, which makes it a good candidate for an automated, reviewable fix.

How Nullify connects cloud findings to code fixes

Nullify's Cloud Security audits AWS, GCP, Azure and Kubernetes continuously, triggered when the environment changes rather than on a schedule. Each finding is traced back to the source repository that created the resource, and owners come from CODEOWNERS. That's the resource-to-source map most teams are missing.

From there, Autofix can treat a triaged cloud misconfiguration like a code vulnerability: plan a minimal change in the infrastructure as code, run it through an independent review, run the checks the workflow has, and open a draft PR for the owner to approve. It works the PR through CI and review and never merges on its own. Nullify scans Terraform, CloudFormation and Kubernetes manifests.

One honest limit: deep asset-graph analysis covers AWS and GCP. Azure is audit-level only.

Frequently asked questions

What is Terraform drift?

Drift is when real infrastructure no longer matches the Terraform configuration and state that describe it, usually because someone changed a resource outside Terraform. You can see it with terraform plan -refresh-only. A normal apply will try to revert the manual change to match the code.

Should I fix cloud misconfigurations in the console or in Terraform?

In Terraform. A console fix creates drift and can be reverted on the next apply. The exception is an active incident: change the live setting first to contain it, then make the matching code change the same day.

How do I find which Terraform code created a cloud resource?

Search your infrastructure repositories for the resource name, tags or module, and check state files for the resource address. Tagging every resource with its repository and owner at creation time makes this a lookup instead of a search. Some cloud security tools trace findings to their source repository automatically.

Can cloud misconfigurations be fixed automatically?

Yes, when the fix is made in infrastructure as code and reviewed like any other change. An automated fix should change the module or resource argument, show the plan's impact, and go through the owner's pull request review rather than editing live infrastructure directly.