When using Terraform to deploy resources into Azure, which scenarios are true regarding state files? (Choose two.)
A.
When a change is made to the resources via the Azure Cloud Console, the changes are recorded in a new state file
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
D.
When a change is made to the resources via the Azure Cloud Console, the changes are recorded in the current state file
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.
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
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.
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....
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
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
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.
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
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
AzureGurl
Highly Voted 2 years, 5 months agoalirasouli
1 year, 11 months agomsingh20
1 year, 3 months agoTyler2023
1 year agoNikita74
Highly Voted 2 years, 1 month ago090200f
Most Recent 4 months, 1 week agovibzr2023
7 months, 4 weeks agovibzr2023
7 months, 4 weeks agovibzr2023
7 months, 4 weeks agovibzr2023
7 months, 4 weeks agoAbsence379
8 months, 3 weeks agomattuyghur
9 months, 3 weeks agoTyler2023
1 year agobrax404
1 year, 1 month agoPikopo
1 year, 1 month agogofavad926
1 year, 1 month agodebabrata6983
1 year, 2 months agoRajmane
1 year, 3 months agomodarov
1 year, 3 months agoMarch2023
1 year, 5 months agomilan92stankovic
1 year, 5 months agoTaalai
1 year, 6 months agosdm13168
1 year, 6 months ago