#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →

Interview Insights · Cloud Tools

The Cloud Tools Question That Ninety Percent of Candidates Fumble

'Someone changed a security group in the console last night. Your Terraform code still has the old rule. What happens on the next apply, and what do you do?' It sounds simple. Most answers fall apart within a minute.

Tracks
The Drift Question · Live Interactive
Answer type
—
What the candidate says
Gap
—
What is missing
Verdict
—
How it lands
Detect→Ask→Reconcile→Prevent
Click an answer type to see why the common answers fumble and what a complete drift answer sounds like.

Home / Tutorials / Career Guides / The Cloud Tools Question That Ninety Percent of Candidates Fumble

Interview Insights · Cloud Tools

The Cloud Tools Question That Ninety Percent of Candidates Fumble

DETECTASKRECONCILEPREVENTSee the driftterraform planRefresh-onlyStep 1Why it changedIncident fix?Mistake?Step 2Pick truthUpdate code, orRevert the changeStep 3Stop repeatsLimit consoleDetect earlyStep 4
A complete answer to the drift question has four steps: detect the difference, find out why it happened, reconcile code and reality, and prevent repeats.

Quick summary — Terraform drift

The drift question is fumbled because candidates answer only the tool part and forget the people part. Technically, the next plan will show the difference and an apply will put the resource back to match the code. That is the part most candidates know. What they miss is that the manual change might have been an emergency fix that keeps production alive. Overwriting it blindly can cause an outage. A strong answer detects the drift, asks why it happened, decides which side is right, reconciles them and then reduces the chance of it happening again.

In this guide you will learn:

  1. Exactly what Terraform does when real infrastructure differs from code
  2. Why the obvious answer can cause an outage
  3. Refresh-only plans, import blocks and ignore_changes and when each fits
  4. How teams prevent drift with permissions and detection
  5. A model answer you can adapt in under two minutes

SECTION 01What Terraform actually does when reality changes

Terraform keeps a state file that records what it believes exists. When you run terraform plan, it first refreshes that state by reading the real resources from the cloud API. Then it compares three things: your code, the refreshed state and what it would need to change to make reality match the code. If someone added a rule by hand, the plan will propose removing it, because the code does not include it.

That is the mechanical part of the answer, and it is worth saying precisely. Many candidates say 'Terraform will give an error' or 'Terraform will not notice', and both are wrong for normal managed attributes.

Manual change in consoleWhat the next plan showsEffect of a blind applyHidden risk
Extra inbound rule added to a security group~ update removing the ruleThe rule is deletedIf it was an emergency fix, access breaks
Instance type changed to a larger size~ update back to the smaller typeInstance resized down, may restartPerformance problem returns
Resource deleted by hand+ create a new oneA fresh, empty resource appearsData from the old one is gone
New resource created by handNothing; Terraform does not know about itStays unmanagedForgotten cost and security gaps
$ terraform plan

aws_security_group.app: Refreshing state... [id=sg-0abc123]

Terraform will perform the following actions:

  # aws_security_group.app will be updated in-place
  ~ resource "aws_security_group" "app" {
        id      = "sg-0abc123"
      ~ ingress = [
          - {
              - cidr_blocks = ["203.0.113.10/32"]
              - from_port   = 22
              - to_port     = 22
              - protocol    = "tcp"
              # (other attributes hidden)
            },
            # (1 unchanged element hidden)
        ]
    }

Plan: 0 to add, 1 to change, 0 to destroy.
drift-plan.txt

Notice the last sentence of the spoken answer. That is where most candidates stop being average. They connect the tool's behaviour to a real situation on a team.

Key insight: Drift is not just a Terraform problem. It is a sign that someone needed to change something outside the normal process. Finding out why is part of the job.

SECTION 02Reconciling: choose which side is the truth

Once you know why the change happened, you choose. If the manual change was a mistake, you let Terraform revert it with a normal plan and apply. If the manual change was correct, you update the code to include it, so the next plan shows no changes. And if a resource was created entirely by hand and should now be managed, you bring it under Terraform with an import.

There is also a case where drift is expected: some attributes are changed by other systems on purpose, such as an Auto Scaling group's desired capacity. For those, ignore_changes tells Terraform not to fight the other system.

SituationRight actionTool or commandWhat to watch
Manual change was a mistakeRevert to match codeterraform plan, then applyConfirm nobody depends on the change
Manual change was a valid fixUpdate code to match realityEdit .tf, plan shows no changesReview and merge through the normal process
Resource created by hand, should be managedImport into stateimport block or terraform importWrite matching code before applying
Attribute changed by automation on purposeStop Terraform fighting itlifecycle ignore_changesOnly ignore what truly belongs to the other system
# Terraform 1.5 and later: declarative import
import {
  to = aws_s3_bucket.reports
  id = "myproj-reports-ap-south-1"
}

resource "aws_s3_bucket" "reports" {
  bucket = "myproj-reports-ap-south-1"
}

# Run:
#   terraform plan
# The plan shows the bucket will be imported.
# Adjust the resource block until the plan shows
# no other changes, then apply.

# Older CLI style, same effect:
#   terraform import aws_s3_bucket.reports myproj-reports-ap-south-1
reconcile.tf

A refresh-only plan is also worth mentioning. terraform plan -refresh-only shows how state differs from reality without proposing changes to resources, and terraform apply -refresh-only updates the state to accept what is there. It is useful when you want Terraform to record reality first and then decide what the code should say.

Be careful with ignore_changes. If you ignore too much, Terraform stops protecting you, and real drift goes unnoticed. Ignore only attributes that another system is meant to own.

Remember: Reconciling means making code and reality agree on purpose. The direction depends on why the drift happened, not on which one is easier to change.

SECTION 03Preventing drift and the model answer

The final part of a strong answer is prevention. Teams reduce drift by limiting who can change production in the console, routing changes through pull requests and running scheduled plans to detect drift early. Some also use services such as AWS Config to flag changes to sensitive resources like security groups.

Put together, a complete answer has four steps: detect, ask, reconcile and prevent. It takes about two minutes to say. The table shows the prevention options and the tab gives a model answer you can adapt.

Prevention methodHow it worksStrengthLimitation
Read-only console for most peopleIAM grants write access only to the pipeline roleRemoves most casual changesNeeds a break-glass process for emergencies
Scheduled drift checkA CI job runs terraform plan daily and alerts on changesCatches drift quicklyOnly covers resources Terraform manages
AWS Config rulesRecords configuration changes and evaluates rulesSees changes to any supported resourceExtra setup and cost
Break-glass with follow-upEmergency access is logged and must be codified afterAllows urgent fixes safelyRelies on people following the process
"On the next plan, Terraform refreshes the security group
and proposes removing the rule, since it is not in code.
A blind apply would delete it.

So first I would find out why it was added, from the
team or CloudTrail. If it was a mistake, I let Terraform
revert it. If it was a needed fix, I add the rule to the
code through a pull request, so the plan becomes clean.

To prevent repeats, I would keep console write access
limited, run a scheduled plan that alerts on drift, and
have a break-glass process where emergency changes are
codified the next working day."
drift-check.yml

The -detailed-exitcode flag is the small detail that makes the scheduled check work: exit code 2 means changes were found, so the job fails and someone gets notified. Mentioning it shows you have thought about how detection is actually wired up.

Pro move: Mention CloudTrail when you talk about finding out who made the change. It shows you know where the evidence lives, and it moves the answer from guessing to investigating.
How Uncodemy helps: Uncodemy trainers cover Cloud Tools interview questions as part of the Cloud Computing Training Course: project reviews, mock interviews and resume feedback, with placement assistance once you are interview-ready.

SECTION 04Drift practice lab and answer card

You can practise this whole question in a practice account in under an hour. These tabs give you the lab steps, an answer card to memorise the structure and a self-check.

DRIFT LAB

1. Create a security group with one rule in Terraform.
2. In the console, add a second inbound rule (your IP).
3. Run terraform plan. Read what it proposes.
4. Run terraform plan -refresh-only. Compare.
5. Option A: apply normally and watch the rule vanish.
6. Option B: add the rule to code; plan should be clean.
7. Create a bucket by hand; bring it in with an import block.
8. terraform destroy at the end.
drift-practice.md

SECTION 05Tips for answering drift and state questions

These tips apply to the drift question and to its many variations, such as 'someone deleted a resource' or 'state is out of date'.

  • State the mechanics precisely — Say that plan refreshes from the real API and then compares with code; it shows you know how the tool works.
  • Pause before the apply — Always say you would read the plan and ask why before applying anything that reverts a manual change.
  • Name both directions — Explain that sometimes the code is wrong and should be updated, not only that reality should be reverted.
  • Know your import options — Mention both the import block and the older terraform import command, and that code must match before you apply.
  • End with prevention — A short line about access control and scheduled drift checks shows you think about the system, not just the incident.
Pro tip: Run the drift lab once and keep the plan output. When you describe it in an interview, saying 'when I tried this, the plan proposed removing the rule' is far more convincing than describing it in theory. In Uncodemy mock interviews, this is often the first follow-up we ask after a Terraform project.

SECTION 06Interview Q&A — Terraform drift

Q1What happens on terraform plan if a resource was changed manually?

Terraform refreshes the resource's real attributes from the provider API, compares them to the configuration and proposes changes to bring reality back in line with the code. For a manually added rule, the plan will show an in-place update that removes it.

Q2What does terraform plan -refresh-only do?

It shows how the state file differs from the real infrastructure without proposing changes to the resources themselves. Running apply -refresh-only then updates the state to match reality. It is useful to record what is actually there before deciding how the code should change.

Q3How do you bring a manually created resource under Terraform?

Write a resource block for it and import it, either with an import block in configuration, available from Terraform 1.5, or the terraform import command. Then adjust the resource block until the plan shows no unexpected changes, and apply.

Q4When would you use ignore_changes?

When another system legitimately manages an attribute, such as Auto Scaling changing desired_capacity, or tags added automatically by a separate tool. Without it, every apply would undo those changes. I would ignore only those specific attributes, not whole resources.

Q5How would you find out who changed a resource in AWS?

Search CloudTrail event history for API calls on that resource, such as AuthorizeSecurityGroupIngress for a security group rule. The event shows the identity, time, source IP and request details. AWS Config can also show the configuration timeline for supported resources.

SECTION 07Test yourself — Terraform drift quiz

Five questions. No sign-up.

0 / 5

Pick an answer to see why it is right or wrong.

SECTION 08Frequently asked questions

What is drift in Terraform?

Drift is a difference between what your Terraform code and state describe and what actually exists in the cloud, usually caused by manual changes or other tools modifying resources. Terraform shows it on the next plan.

How do you detect configuration drift in AWS?

Run terraform plan regularly, for example in a scheduled CI job with -detailed-exitcode. AWS Config can also record configuration changes and evaluate rules, and CloudTrail records the API calls that made the changes.

What is the difference between terraform refresh and plan -refresh-only?

The older terraform refresh command updated state directly without showing you what changed. plan -refresh-only shows the differences first, and apply -refresh-only updates state after you review them, which is the safer recommended approach.

How do I import existing AWS resources into Terraform?

Write a resource block, then use an import block with the target address and the resource ID, or run terraform import. Run plan, adjust the code until no unexpected changes appear and then apply to record it in state.

Should I make changes in the AWS console if I use Terraform?

Ideally not for resources Terraform manages, because it causes drift. Use the console to explore and to handle real emergencies, then put any lasting change into code through the normal review process.

Does Uncodemy help with Cloud Tools interview questions?

Yes. Uncodemy's Cloud Computing Training Course in Noida (classroom and online) includes live projects, one-to-one mock interviews and resume reviews, so you practise Cloud Tools interview questions with trainer feedback before the real interview. You can book a free demo class from this page to see how the sessions work.

Classroom & online · Noida

Answer the drift question with confidence

Our Cloud Computing Training Course includes Terraform labs on state, drift, imports and CI checks, so you can handle the tools questions most candidates fumble.

Talk to a counsellor for current fees
  • Terraform state and drift labs
  • CI/CD with plan checks
  • Mock cloud tools rounds
  • Weekday & weekend batches