Terraform Interview Questions
The following are the interview questions on terraform:
1. What do you mean by Terraform in AWS?
Terraform is an advanced technology partner in the AWS Partner Network (APN) and is part of the AWS DevOps competency. It’s similar to AWS Cloud Formation in that it’s an “infrastructure as code” tool for creating, updating, and versioning your AWS infrastructure.
2. What do you mean by terraform Cloud?
Terraform Cloud is a platform that allows teams to use terraform together on-demand or in response to events. Unlike a general-purpose continuous integration system, it is deeply linked with Terraform’s workflows and data. It has a private registry for sharing Terraform modules, easy access to shared state and confidential data, full policy controls for upgrading infrastructure and managing the contents of Terraform, and much more.
3. What are the critical features of terraform?
Terraform allows you to manage your infrastructures as code and build it as needed. The following are some of its most important features:
- A console that enables users to see how things work.
- The ability to convert HCL code to a JSON format
- An interpolation-supporting configuration language
- A module count keeps track of how many modules have been installed on the infrastructure.
4. What are the most useful terraform commands?
The following are some of the most useful terraform commands:
- Terraform init- creates a new directory in the current one
- Terraform refresh- updates the state file
- Terraform apply- terraform code is applied, and terraform builds are performed.
- Terraform plan- a test run to see what terraform will do • Terraform output- a glimpse of terraform output
- Terraform destroy- destructs what terraform has constructed
- Terraform graph- Creates a DOT formatted graph
- What do you understand by terraform backend?
A backend can be specified in each Terraform setup, which defines two key things:
Where are surgeries carried out?
Where is the state saved? (Terraform retains track of all the resources created in a state file)
- Why is terraform used for DevOps?
Terraform uses the HashiCorp Configuration Language, similar to JSON (HCL). HCL provides a straightforward vocabulary that enables defining and enforcing infrastructure configurations across different clouds and on-premises data centers simple for DevOps teams.
- What are the version controls aided by terraform besides GitHub?
GitLab EE, GitLab CE, and Bucket cloud were all supported by the version controls.
- What are the modules in terraform?
In terraform, a module is a framework for multiple resources used together. Every terraform requires the root module, which contains all the resources indicated in the—tf files.
- Is terraform usable for on-prem infrastructure?
Yes, Terraform can be used to build on-premise infrastructure. We can choose from various suppliers to see which one best matches our needs. All we require is an API.
10. Does terraform support multi-provider deployments?
Yes, Terraform supports multi-provider deployments, including on-premises solutions like OpenStack and VMware and SDN management.
11. How can duplicate resource errors be ignored during terraform applications?
We can check with the following options:
- Deleting those resources from the cloud provider (API) and re-creating them with Terraform
- Remove those resources from Terraform’s code to stop it from being managed by it.
- Import the resource using Terraform and remove the code attempting to replicate it.
12. Name all version controls supported by terraform?
The supported version controls are:
- Azure DevOps Services
- Azure DevOps Server
- Bitbucket Server
- Bitbucket Cloud
- Gitlab EE and CE
- Gitlab.com
- GitHub Enterprise
- GitHub.com (OAuth)
- GitHub.com13. Define resource graph in terraform.
The resources are represented visually in a resource graph. It allows you to change and create independent resources at the same time. Terraform establishes a plan for the graph’s configuration to develop plans and update the state. It efficiently and successfully creates a structure to assist us in comprehending the disadvantages.
14. How to store sensitive data in terraform?
To interface with your cloud provider’s API, Terraform requires credentials. However, these credentials are frequently saved unencrypted on your desktop. Every day, GitHub is exposed to tens of thousands of API and cryptographic keys. As a result, your API keys should never be explicitly saved in Terraform code. All passwords, TLS certificates, SSH keys, and anything else that shouldn’t be saved in plain text should be stored in encrypted storage.
15. How to lock terraform module versions?
A verified method of locking terraform module versions using the terraform module registry as a source. We can use the version attribute in the module of the Terraform configuration file. Because we’re using the Github repository as a source, we’ll need to use? Ref to define the versions, branch, and query string.
16. What is terraform Core? Tell us some primary responsibilities of it.
Terraform Core is a binary built in the Go programming language and statically compiled. Terraform users can use the compiled binaries as a starting point. The primary responsibilities include:
- Infrastructure as code functionalities read and interpolate modules and configuration files,
- Building a Resource Graph
- RPC-based plugin communication
- Execution of the plan
- Resource status management.
17. How will you upgrade plugins on terraform?
Use the ‘-upgrade’ option when running ‘terraform init.’ This command searches releases.hashicorp.com for new provider versions that are appropriate. It also downloads provider versions if they are available. The automated downloads directory is “.terraform/plugins/OS> ARCH>.”
18. How will you control and handle rollbacks if something goes wrong?
To make it the new and current one, I need to recommit the prior code version in my (VCS)visual computing system. This will launch the terraform run command, which will run the old code. I’ll make sure that everything in the code reverts to its previous state because Terraform is more declarative. I’d use Terraform Enterprise’s State Rollback capability to restore the previous state if the state file became corrupted.
19. Which command destroys terraform-managed infrastructure?
To destroy terraform-managed infrastructure, run the following command:
Terraform destroy [options] [dir]
20. What is a private module Registry?
Terraform Cloud has a Private Module Registry feature that allows you to share Terraform modules throughout your enterprise. On the registry, you can set rules or “sentinel policies” that govern how members of your organization can use the modules.
21. Is terraform usable for an on-prem infrastructure?
Terraform can be used to build on-premise infrastructure, yes. We can choose from various suppliers to see which one best matches our needs. All we require is an API.
22. What is meant by terraform D?
Terraform D is a plugin for Windows and most in-service systems. Terraform init looks for plugins in the following directory by default.
23. Define Null resources in Terraform.
The null resource creates a standard resource library but doesn’t do anything else. The triggers option allows you to specify any values that will cause resources to be replaced. When something was altered, explain it.
24. Explain Oracle Cloud Infrastructure.
Oracle Corporation offers cloud computing services, i.e., Oracle Cloud, including storage, servers, applications, services, and networks delivered through a global network of Oracle Corporation managed data centers. The firm provides these services on-demand via the internet.
25. Define IAC?
Infrastructure as Code (IAC) allows you to code instead of using manual processes to construct, alter, and manage your infrastructure. The configuration files are built according to the specifications of your infrastructure, and they may be modified and transmitted securely within an organization.
26. What are the components of Terraform architecture?
The Terraform architecture includes the following features:
- Sub-graphs
- Expression Evaluation
- Vertex Evaluation
- Graph Walk
- Graph Builder
- State Manager
- Configuration Loader
- CLI (Command Line interface)
- Backend
27. Are callbacks possible with Terraform on Azure?
Microsoft Azure Cloud shell includes a Terraform occurrence that has already been installed. Terraform’s Azure supplier delivers users with simple functionality. Callbacks are more likely on Azure if you use the Azure Event Hubs.
28. What is a private module registry?
Terraform Cloud has a Private Module Registry feature that allows you to share Terraform modules throughout your enterprise. On the registry, you can set rules or “sentinel policies” that govern how members of your organization can use the modules.
29. Does terraform support multi-provider deployments?
Yes, Terraform supports multi-provider deployments, including on-premises solutions like OpenStack and VMware and SDN management.
30. Mention some built-in provisioners available in terraform?
The following is a list of Terraform’s built-in provisioners:
- Habitat Provisioner
- File Provisioner
- Chef Provisioner
- Salt-masterless Provisioner
- Remote-exec Provisioner
- Puppet Provisioner
- Local-exec Provisione
- 31. List out some of the most recent Terraform Azure Providers considerations?
New data resources like the Azure batch certificate, which aids in certificate management, are included in the current versions. In networking, this resource is used to regulate the prefix. Bugs have been fixed, and the azure app service has been improved.
Akhila
Author
Hola! I believe words cause magic and here Iam helping you become aware of advancing technologies, because the future of communication starts here.