When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
When changes are made to Azure resources outside of Terraform (for example, through the Azure Cloud Console), the state file that Terraform maintains will not be automatically updated. During the next execution of 'terraform plan' or 'terraform apply', Terraform will detect differences between the state file and the actual infrastructure state. While the 'terraform plan' command will highlight these discrepancies, it does not update the state file itself. The 'terraform apply' command, on the other hand, will try to reconcile these differences and update the state file to reflect the current state of the infrastructure, ensuring consistency with the defined configuration.
IT should be B and C, however the wording is incorrect, Terraform Refresh will only update the state file for new changes via Az Console Terraform Plan does not change the State file, It will however say the diff in the state. The Terraform apply will make the changes to the state file to keep it consistent. So the wording of Option B is bit ambiguous.
Option B's wording is too fuzzy.
Terraform plan / apply runs a terraform refresh to update the state with infrastructure so B makes sense.
I don't think so, terraform will not generate the configuration changes you've maid manually, terraform apply will remove the configuration you've made that is not included in your tf files
Only C
B. This is true, but with an important distinction. Terraform doesn't automatically detect changes made outside of it. If you modify resources directly in Azure (outside of Terraform), during the next terraform plan or terraform apply, there might be a discrepancy between the state file and the actual infrastructure. Terraform will then propose to reconcile this difference, which could involve changing or recreating the affected resources. C. This is true. The Terraform state file isn't automatically updated when changes are made outside of Terraform, such as directly in the Azure Cloud Console.
BC for sure
B, C are correct answers
I believe only option C is correct. I tested this by spinning up an EC2 instance in AWS using Terraform and then manually updating the "Name" tag in the AWS console. Immediately after that, when I ran terraform plan, it indicated that the tag would be changed from the Terraform-assigned value ("TerraformCI") to the manually applied value ("Rajesh"). This demonstrates that Terraform detects changes made outside of its management and plans to update the infrastructure accordingly.
terraform plan output # aws_instance.ec2_example will be updated in-place ~ resource "aws_instance" "ec2_example" { id = "i-037feb3cac6a58f05" ~ tags = { ~ "Name" = "TerraformCI" -> "Rajesh" } ~ tags_all = { ~ "Name" = "TerraformCI" -> "Rajesh" } terraform apply output update tag from TerraformCI to Rajesh
While prevailing sentiment leans towards options B and C, as evidenced by the popularity of ChatGPT's response, I posit that only option C is accurate. Definitive proof of option B's validity hinges on the demonstration of program output reflecting a successful state drift reconciliation. Here is the chatgpt answer when i demonstrated only C is correct. Thank you for providing detailed information about your test and findings. Based on your description, it seems there was a misunderstanding regarding how Terraform interacts with external changes. continued.......
When you manually changed the "Name" tag in the AWS console and then ran terraform plan, Terraform compared the actual infrastructure state (with the "Name" tag set to "Rajesh") against what's defined in your Terraform configuration (where the tag might be set to "TerraformCI"). Seeing the discrepancy, Terraform planned to update the resource to match the configuration—changing the tag back to "TerraformCI". This behavior is expected and demonstrates Terraform's goal to ensure the infrastructure matches the configuration specified in your .tf files. continued....
B and C
should be B and C
I don't think B is an answer here When you change any configuration manually outside your terraform configuration The next time your run terraform apply, terraform will revert your manual changes and follow what is defined in your configuration files So answer i C
the correct answer are B and C
BC When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated. Terraform will update the state file to reflect the changes made to the resources via the Azure Cloud Console during the next plan or apply.
The correct answer is B&C
The right answer is B & C
B. When a change is made to the resources via the Azure Cloud Console, Terraform will update the state file to reflect them during the next plan or apply C. When a change is made to the resources via the Azure Cloud Console, the current state file will not be updated
b and c
B & C are the correct answer.
according to Chat GPT is B and D