0
0
Terraformcloud~20 mins

Terraform apply -replace flag - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Replace Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of the -replace flag in Terraform apply

What does the -replace flag do when used with terraform apply?

AIt updates the specified resource without recreating it.
BIt skips the specified resource during the apply process.
CIt rolls back the last apply operation on the specified resource.
DIt forces Terraform to destroy and recreate the specified resource during apply.
Attempts:
2 left
💡 Hint

Think about how you can force Terraform to rebuild a resource even if no changes are detected.

Configuration
intermediate
2:00remaining
Using -replace flag syntax correctly

Which of the following commands correctly uses the -replace flag to replace the resource aws_instance.web_server?

Aterraform apply -replace=aws_instance.web_server
Bterraform apply --replace aws_instance.web_server
Cterraform apply -replace aws_instance.web_server
Dterraform apply --replace=aws_instance.web_server
Attempts:
2 left
💡 Hint

Check the exact syntax for flags with values in Terraform CLI.

service_behavior
advanced
2:00remaining
Effect of -replace on resource lifecycle

What is the expected behavior of Terraform when applying with -replace=aws_s3_bucket.my_bucket if the bucket exists and has data?

ATerraform will skip the bucket since it already exists.
BTerraform will update the bucket in place without data loss.
CTerraform will destroy the existing bucket and recreate it, causing data loss.
DTerraform will create a new bucket with a different name.
Attempts:
2 left
💡 Hint

Consider what happens when a resource is destroyed and recreated.

security
advanced
2:00remaining
Security implications of using -replace on sensitive resources

What is a key security risk when using terraform apply -replace on resources like databases or secrets managers?

ATemporary exposure of sensitive data during resource recreation.
BPrevention of unauthorized access during apply.
CAutomatic encryption of data during replacement.
DNo impact on security as resources are replaced safely.
Attempts:
2 left
💡 Hint

Think about what happens to data when a resource is destroyed and recreated.

Best Practice
expert
3:00remaining
Best practice when using -replace flag in production

Which is the best practice before running terraform apply -replace on a critical production resource?

ADelete the resource manually before running apply.
BBackup the resource data and test replacement in a staging environment first.
CIgnore state locking to speed up apply.
DRun the command directly in production to save time.
Attempts:
2 left
💡 Hint

Consider how to avoid data loss and downtime.