Practice IaC state management vocabulary: Terraform state files, remote backends, state locking, state drift, and importing existing resources into state.
0 / 15 completed
1 / 15
Terraform tracks managed infrastructure in a ___ file that records the current known state of every resource.
The Terraform state file (terraform.tfstate) is a JSON record that maps each resource in your configuration to its real-world counterpart. Terraform uses it to determine what changes are needed when you run plan or apply.
2 / 15
The team stores state in a ___ backend so all engineers work from the same state.
A remote state backend (S3 + DynamoDB, GCS, Azure Blob Storage, Terraform Cloud) stores the state file in a shared location. This allows multiple engineers to run Terraform against the same infrastructure, and enables state locking to prevent conflicts.
3 / 15
The pipeline fails: 'The state is ___ by another run.' What does this mean?
State locking prevents two Terraform processes from modifying the same state simultaneously, which could corrupt it. DynamoDB (for S3 backend) or the Terraform Cloud backend handle locking. If a run is interrupted, the lock must be manually released.
4 / 15
The monitoring alerts show ___ drift: resources exist in AWS that are not in Terraform state, or state differs from reality.
State drift occurs when the actual cloud resources diverge from what the Terraform state file records. Common causes include manual changes via the console, resource drift from external automation, or resources modified by other tools. terraform plan detects drift.
5 / 15
The ops team needs to manage an existing load balancer. They run terraform ___ to bring it under Terraform's control.
terraform import adds an existing cloud resource to the Terraform state file without recreating it. This lets you start managing manually created resources with Terraform. You still need to write the corresponding configuration to match the imported resource.
6 / 15
Sarah (Senior DevOps Engineer) comments on a PR proposing changes to the Terraform state locking strategy:
'It's crucial we implement state locking. Without it, concurrent updates from different teams could lead to drift and unpredictable infrastructure behavior. We need to ensure that only one process can modify the state at any given time.' What does Sarah primarily refer to when discussing 'state locking'?
Sarah is focusing on preventing conflicts during simultaneous updates. State locking mechanisms, like locking files or using transactional operations, are designed to serialize access and avoid data corruption when multiple processes try to modify the Terraform state concurrently. Option A describes backup strategies; C relates to versioning, and D describes scaling based on drift – none of which align with her concern about concurrent modification.
7 / 15
Mark (Infrastructure Engineer) sends a Slack message to the team:
'I'm seeing some weird behavior with our database instances. Terraform is constantly updating their security group rules, and they're not reflecting in the application! It looks like the state isn't being properly synchronized.' What is Mark most likely experiencing regarding IaC state management?
Mark is describing a common problem related to asynchronous updates. Terraform state files are not inherently transactional; changes made to the state file aren't immediately reflected in the underlying infrastructure. This lag can lead to discrepancies between the configuration and the running environment if synchronization isn't properly handled.
8 / 15
The API response from the Terraform CLI after a state apply is:
```json
{
"result": "hcl_resource.instance.changed",
"message": "Resource 'hcl_resource.instance' has changed."
}
```
What does this response primarily indicate in the context of IaC state management?
The response indicates that one particular resource – hcl_resource.instance – has been altered since the last time Terraform captured its state. This change triggers an update in the infrastructure, highlighting the importance of tracking and managing state drift to maintain consistency.
9 / 15
During a standup meeting, David (Lead Developer) says: 'We're using Terraform state locking to prevent concurrent changes. However, I'm seeing occasional errors where the application doesn't reflect the latest infrastructure updates after we push new code.' What is David most likely observing related to IaC state management?
David's observation points to a potential conflict between state locking and the application's deployment workflow. If the application doesn't automatically refresh its configuration after Terraform updates the state, it may be using an outdated version, leading to inconsistencies. This often happens if the application isn't designed to actively poll for changes or relies solely on the Terraform-driven updates.
10 / 15
The team is migrating an existing load balancer managed by a legacy configuration tool to Terraform. They run `terraform apply` to bring it under Terraform's control. Later, monitoring alerts show significant drift: resources exist in AWS that are not in the Terraform state, or state differs from reality. What is this most likely indicative of?
This situation strongly suggests an incomplete migration. Simply running `terraform apply` doesn't automatically capture *all* configurations of the legacy load balancer—especially if it had undocumented or non-standard settings. The resulting drift indicates a gap between Terraform's state and the actual operational environment, requiring further investigation and manual configuration synchronization.
11 / 15
Sarah (Senior DevOps Engineer) comments on a PR proposing changes to the Terraform state locking strategy:
'It's crucial we implement state locking. Without it, concurrent updates from different teams could lead to drift and unpredictable infrastructure behavior. We need to ensure that only one process can modify the state at any given time.' What does Sarah primarily refer to when discussing 'state locking'?
Sarah is focusing on preventing conflicts during simultaneous updates. State locking mechanisms, like locking files or using transactional operations, are designed to serialize access and avoid data corruption when multiple processes try to modify the Terraform state concurrently. Option A describes backup strategies; C relates to versioning, and D describes scaling based on drift – none of which align with her concern about concurrent modification.
12 / 15
Mark (Infrastructure Engineer) sends a Slack message to the team:
'I'm seeing some weird behavior with our database instances. Terraform is constantly updating their security group rules, and they're not reflecting in the application! It looks like the state isn't being properly synchronized.' What is Mark most likely experiencing regarding IaC state management?
Mark is describing a common problem related to asynchronous updates. Terraform state files are not inherently transactional; changes made to the state file aren't immediately reflected in the underlying infrastructure. This lag can lead to discrepancies between the configuration and the running environment if synchronization isn't properly handled.
13 / 15
The API response from the Terraform CLI after a state apply is:
```json
{
"result": "hcl_resource.instance.changed",
"message": "Resource 'hcl_resource.instance' has changed."
}
```
What does this response primarily indicate in the context of IaC state management?
The response indicates that one particular resource – hcl_resource.instance – has been altered since the last time Terraform captured its state. This change triggers an update in the infrastructure, highlighting the importance of tracking and managing state drift to maintain consistency.
14 / 15
During a standup meeting, David (Lead Developer) says: 'We're using Terraform state locking to prevent concurrent changes. However, I'm seeing occasional errors where the application doesn't reflect the latest infrastructure updates after we push new code.' What is David most likely observing related to IaC state management?
David's observation points to a potential conflict between state locking and the application's deployment workflow. If the application doesn't automatically refresh its configuration after Terraform updates the state, it may be using an outdated version, leading to inconsistencies. This often happens if the application isn't designed to actively poll for changes or relies solely on the Terraform-driven updates.
15 / 15
The team is migrating an existing load balancer managed by a legacy configuration tool to Terraform. They run `terraform apply` to bring it under Terraform's control. Later, monitoring alerts show significant drift: resources exist in AWS that are not in the Terraform state, or state differs from reality. What is this most likely indicative of?
This situation strongly suggests an incomplete migration. Simply running `terraform apply` doesn't automatically capture *all* configurations of the legacy load balancer—especially if it had undocumented or non-standard settings. The resulting drift indicates a gap between Terraform's state and the actual operational environment, requiring further investigation and manual configuration synchronization.
What will I practise in "IaC State Management Vocabulary"?
Practice IaC state management vocabulary: Terraform state files, remote backends, state locking, state drift, and importing existing resources into state.
How many exercises are in this module?
This module has 15 multiple-choice exercises, each with instant feedback and a full explanation of the correct answer.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall.
Do I need to create an account to do these exercises?
No account is required. Just click an option to answer — your score for this session is tracked automatically in the progress bar above.
What happens if I choose the wrong answer?
You'll immediately see which answer was correct, plus a full explanation covering the vocabulary and reasoning behind it — mistakes are where most of the learning happens.
Can I retry the exercises if I want a higher score?
Yes — use the "Try again" button on the results screen to reset and go through all the questions again.
Is my progress saved if I close the page?
No. Progress is tracked only for your current visit; reloading or leaving the page resets the counter. This keeps the exercise simple and account-free.
Where can I find more Infrastructure as Code exercises?
Browse the full Infrastructure as Code hub for related drills, or check the "Next up" link below to continue with a connected topic.
How is this different from reading an article on the same topic?
Articles explain vocabulary and concepts in prose; this exercise tests and reinforces that vocabulary through active recall with immediate feedback — the two work best together.
Who writes these exercises?
Every exercise is written by the CoderSlingo team, drawing on real workplace English used in IT roles, then reviewed for accuracy and clarity.