InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How can you prevent Duplicate Resource Error in Terraform? |
|
Answer» Depending on the situation and the necessity, it can be ACCOMPLISHED in one of three ways.
Kubernetes AWS Azure |
|
| 2. |
What do you understand about remote backend in the context of Terraform? |
|
Answer» Terraform's remote backend stores terraform state and can also CONDUCT operations in the terraform cloud. terraform commands such as init, plan, apply, destroy , get, output, providers, state (sub-commands: list, mv, PULL, push, rm, show), taint, untaint, validate, and many others can be RUN from a remote backend. It can be used with a single or several remote terraform cloud workspaces. You can utilise terraform cloud's run ENVIRONMENT to conduct remote operations like terraform plan or terraform apply. |
|
| 3. |
What procedures should be taken to make a high-level object from one module available to the other module? |
|
Answer» The steps to make an object from one module available to the other module at a high LEVEL are as follows:
|
|
| 4. |
When something goes wrong, how will you control and handle rollbacks in Terraform? |
|
Answer» In our Version Control SYSTEM, we need to recommit the previous code version to make it the NEW and current one. This would start the terraform run command, which would execute the old code. Because Terraform is more declarative, we will make sure that EVERYTHING in the code reverts to its previous state. If the state file becomes corrupted, we would USE Terraform ENTERPRISE's State Rollback feature to restore the previous state. |
|
| 5. |
What do you know about Terraform core? What are the primary responsibilities of Terraform core? |
|
Answer» TERRAFORM Core is a BINARY created in the Go programming language that is statically compiled. The compiled binary is the terraform command line TOOL (CLI), which is the starting point for anyone who wants to use Terraform. The source code can be found at github.com/hashicorp/terraform. The primary responsibilities of Terraform core includes:
|
|
| 6. |
Explain State File Locking in the context of Terraform. |
|
Answer» Terraform's STATE FILE locking method prevents conflicts between numerous users doing the same TASK by blocking activities on a given state file. When ONE user unlocks the lock, only the other user has access to that state. Terraform will lock your state for any operations that potentially write state if your backend supports it. This prevents outsiders from gaining access to the lock and corrupting your state. All operations that have the potential to write state are automatically locked. There will be no indication that this is happening. Terraform will not CONTINUE if state locking fails. The -lock flag can be used to deactivate state locking for most tasks, although it is not advised. Terraform will send a status message if gaining the lock takes longer than planned. If your backend enables state locking, even if Terraform doesn't send a message, it still happens. |
|
| 7. |
What do you know about Terragrunt? What are its uses? |
|
Answer» Terragrunt is a lightweight WRAPPER that adds extra features for maintaining DRY configurations, dealing with many Terraform modules, and MANAGING remote state. Following are the use CASES of Terragrunt:
|
|
| 8. |
Explain the command terraform fmt in the context of Terraform. |
|
Answer» Terraform configuration files are rewritten using the terraform fmt command in a consistent structure and style. This command uses a subset of the Terraform language style conventions, as well as some small readability tweaks. Other Terraform commands that produce Terraform configuration will produce files that follow the terraform fmt style, therefore following this style in your own files will assure consistency. Because formatting selections are always subjective, you may disagree with terraform fmt's choices. This command is PURPOSELY opinionated and lacks customization options because its PRIMARY goal is to promote stylistic consistency throughout Terraform codebases, even THOUGH the chosen style will never be everyone's favourite. Syntax: terraform fmt [options] DIR By default, fmt LOOKS for configuration files in the current directory. If the dir option is provided, it will instead scan the specified directory. The following are the flags that are available:
|
|
| 9. |
What do you mean by a Virtual Private Cloud (VPC)? Which command do you use in Terraform to use a VPC service? |
|
Answer» A Virtual Private Cloud (VPC) is a private virtual network within AWS where you can store all of your AWS services. It will have gateways, route tables, network access control lists (ACL), subnets, and security groups, and will be a logical data centre in AWS. When you create a service on a public cloud, it is effectively open to the rest of the WORLD and can be vulnerable to internet attacks. You lock your instances down and secure them from outside threats by putting them INSIDE a VPC. The VPC limits the types of TRAFFIC, IP addresses, and individuals who have access to your instances. This STOPS unauthorised users from ACCESSING your resources and protects you from DDOS assaults. Because not all services require internet connection, they can be safely stored within a private network. You can then only allow particular machines to connect to the internet. We use the command aws_vpc to use a VPC Service in Terraform. |
|
| 10. |
Differentiate between Terraform and Ansible. |
||||||||||||||
|
Answer» Ansible : Ansible is a remarkably straightforward IT automation technology. Configuration management, APPLICATION deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration are all handled by this software. Complex modifications, such as zero-downtime rolling updates with load balancers, are simple using Ansible. Following table lists the differences between Ansible and Terraform:
|
|||||||||||||||
| 11. |
Explain the command terraform taint in the context of Terraform. |
|
Answer» Terraform receives notification from the terraform taint command that a specific item has been degraded or damaged. This is represented by Terraform designating the item as "tainted" in the Terraform state, in which case Terraform will suggest replacing it in the next plan you write. If you want to compel the replacement of a specific object despite the fact that no configuration modifications are required, using the terraform apply -replace option is preferred. Utilizing the "replace" option while creating a plan is preferable to using terraform taint because it allows you to SEE the entire impact of the alteration before taking any externally VISIBLE action. When you utilise terraform taint to achieve a similar impact, you run the danger of someone else on your team devising a new strategy to counter your tainted object before you've had a chance to consider the implications. Syntax: terraform taint [options] address The address option specifies the location of the infected resource. The following options are available with this command:
|
|
| 12. |
Differentiate between Terraform and Cloudformation. |
|
Answer» The following points highlight the differences between Terraform and Cloudformation:
|
|
| 13. |
Explain the architecture of Terraform request flow. |
|
Answer» A request in Terraform undergoes the following steps as shown in the diagram: Following are the different components in the above architecture: Command Line Interface (CLI): CLI (Common Language Interface) (command package) Aside from some early bootstrapping in the root package (not shown in the diagram), when a user starts the terraform application, execution jumps RIGHT into one of the command package's "command" implementations. The commands.go file in the repository's root directory contains the mapping between user-facing command names and their respective command package types. The job of the command implementation for these commands is to read and parse any command line arguments, command-line options, and environment variables required for the given command and use them to generate a backend.operation object. The operation is then transferred to the backend that is currently selected. Backends: In Terraform, a backend has a variety of RESPONSIBILITIES:
The local backend retrieves the current state for the workspace specified in the operation using a state manager (either statemgr.Filesystem if the local backend is being used directly, or an implementation provided by whatever backend is being wrapped), then uses the config loader to load and do initial processing/validation of the configuration specified in the operation. It then constructs a terraform.context object using these, as well as the other parameters specified in the procedure. The main object actually executes Terraform operations. Configuration Loader : Model types in package configs represent the top-level configuration structure. configs.Config represents an entire configuration (the root module and all of its child modules). ALTHOUGH the configs package offers some low-level functionality for creating configuration objects, the major entry point is via configload.Loader, which is found in the sub-package configload. When a configuration is loaded by a backend, a loader takes care of all the complexities of installing child modules (during terraform init) and then locating those modules again. It takes the path to a root module and loads all of the child modules in a recursive manner to create a single configs. State Manager: The state manager is in charge of storing and retrieving snapshots of a workspace's Terraform state. Each manager is an implementation of a subset of the statemgr package's interfaces, with most practical managers implementing the entire SET of statemgr.Full's operations . The smaller interfaces are mostly for use in other function signatures to be specific about what actions the function might perform on the state manager; there's no reason to design a state manager that doesn't implement all of statemgr. Full. Graph Builder: The terraform.Context method invokes a graph builder. A graph builder is used to represent the essential steps for that operation and the dependence relationships between them. Because the graph-building process differs by operation, each has its own graph builder. A "plan" operation, for example, requires a graph created directly from the configuration, whereas an "apply" action creates its graph from the set of modifications stated in the plan being applied. Graph Walk: The graph walking method visits each vertex of the graph in a fashion that respects the graph's "happens after" edges. Each vertex in the graph is assessed in such a way that the "happens after" edges are taken into account. The graph walk method will assess many vertices at the same time if possible. Vertex Evaluation: During a graph walk, the action executed for each vertex is referred to as execution. Execution PERFORMS a series of random operations that make sense for a given vertex type. Before the graph walk begins evaluating further vertices with "happens after" edges, a vertex must be complete correctly. When one or more errors occur during evaluation, the graph walk is interrupted and the errors are returned to the user. |
|