Posted inInterview Question Terrafrom
Terraform Interview Questions and Answers
Q1: What happens if you remove an EC2 instance from the Terraform state file after its creation and run terraform apply? Once you remove a resource entry from the state file, Terraform will no longer track it. On the next terraform apply, Terraform will attempt to create the resource again, as it doesn't recognize the resource in its state. Q2: What is the role of the state file in Terraform? The Terraform state file is where Terraform records all the infrastructure it manages. It keeps track of resource metadata, including the current state of the infrastructure, allowing Terraform to make appropriate updates during subsequent executions. Q3: How should the Terraform state file be stored for optimal collaboration? The recommended approach is to store the state file in a remote backend, such as Amazon S3 or GitLab’s Terraform state management. This enables team members to collaborate efficiently, preventing conflicts and resource duplication. Q4: Can you explain state file locking in Terraform? State file locking occurs when Terraform locks the state file during operations like plan, apply, or destroy. This prevents multiple users or processes from making simultaneous changes, reducing the risk of conflicting actions that could damage the infrastructure. Q5: What exactly is a Terraform backend?…