A senior admin accidentally deleted some of your cloud instances. What will Terraform do when you run terraform apply?
Terraform detects infrastructure drift by comparing thestate filewith the actual infrastructure.
When an instance ismanually deleted, Terraformsees it as missingand marks it for recreation.
Running terraform apply willonly recreate the missing instanceswhile leaving the rest of the infrastructure unchanged.
Explanation of incorrect answers:
A (Tear down everything and rebuild)-- Incorrect. Terraform does not destroy existing infrastructure unless explicitly told to.
B (Build a completely new set of infrastructure)-- Incorrect. Terraform does not create duplicates unless configuration changes.
D (Stop and error out)-- Incorrect. Terraform does not fail; itrebuilds missing resourcesautomatically.
Official Terraform Documentation Reference:
Handling Infrastructure Drift
You have multiple team members collaborating on infrastructure as code (IaC) using Terraform, and want to apply formatting standards for readability.
How can you format Terraform HCL (HashiCorp Configuration Language) code according to standard Terraform style convention?
The terraform fmt command is used to rewrite Terraform configuration files to a canonical format and style. This command applies a subset of the Terraform language style conventions, along with other minor adjustments for readability. Running this command on your configuration files before committing them to source control can help ensure consistency of style between different Terraform codebases, and can also make diffs easier to read.You can also use the -check and -diff options to check if the files are formatted and display the formatting changes respectively2.Running the terraform fmt command during the code linting phase of your CI/CD process can help automate this process and enforce the formatting standards for your team.Reference= [Command: fmt]2
You've used Terraform to deploy a virtual machine and a database. You want to replace this virtual machine instance with an identical one without affecting the database. What is the best way to achieve this using Terraform?
The terraform taint command marks a resource as tainted, which means it will be destroyed and recreated on the next apply. This way, you can replace the VM instance without affecting the database or other resources.Reference= [Terraform Taint]
You're building a CI/CD (continuous integration/continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?
This is a secure way to inject sensitive variables into your Terraform run, as they will not be stored in any file or source code repository. You can also use environment variables or variable files with encryption to pass sensitive variables to Terraform.
You corrected a typo in a resource name, changing it from aws_s3_bucket.photoes to aws_s3_bucket.photos. You want to update the Terraform state so that the existing resource is recognized under the new name, without destroying and recreating it. Which configuration should you use?
Rationale for Correct Answer: A moved block tells Terraform that an object's address in state has changed (renamed/refactored) and it should move the state from the old address to the new address. This preserves the existing real resource and prevents unnecessary destroy/recreate.
Analysis of Incorrect Options (Distractors):
A: Works but is unnecessarily risky/extra work; moved is the intended refactoring mechanism for renames.
B: Incorrect---refresh-only updates state to match real infrastructure, but it does not remap an object from one address to another.
C: Incorrect---Terraform will treat the new name as a new resource address and the old one as removed unless you explicitly move/rename state.
Key Concept: Refactoring addresses safely using moved blocks (state address migration).
====================
Thomas Miller
6 days agoFrank King
23 days agoFrank Hall
1 month agoEdward Baker
2 months agoElizabeth Cooper
2 months agoGerald Carter
2 months agoJames Ramirez
2 months agoJessica Flores
2 months agoRichard Allen
2 months agoMark Cook
2 months agoDarrel
3 months agoGearldine
3 months agoDonte
3 months agoLorrie
4 months agoSkye
4 months agoLavonda
4 months agoAudrie
4 months agoDong
5 months agoLigia
5 months agoLynelle
5 months agoElise
5 months ago