Общие вопросы, которые вы должны знать перед собеседованием

Я дал много интервью как интервьюер, так и интервьюируемый. Я составляю этот список на основе своего опыта, и мы не можем собрать все в одной статье, поэтому я делю эти статьи на 20 вопросов каждая. Посмотрим, во сколько частей это войдет. Вот первые 20 общих вопросов в Terraform.

  1. Что такое IaC и в чем заключаются преимущества?
IaC is a short form of Infrastructure as code and You write and execute the code to define, deploy, update, and destroy your infrastructure and you can follow all the best practices as normal development.
Benefits:
a. Automation
We can bring up the servers with one script and scale up and down based on our load with the same script.
b. Reusability of the code
We can reuse the same code
c. Versioning
We can check it into version control and we get versioning. Now we can see an incremental history of who changed what, how is our infrastructure actually defined at any given point of time, and wehave this transparency of documentationIaC makes changes idempotent, consistent, repeatable, and predictable.
IaC makes it easy to provision and apply infrastructure configurations, saving time. It standardizes workflows across different infrastructure providers (e.g., VMware, AWS, Azure, GCP, etc.) by using a common syntax across all of them.

2. Каковы варианты использования Terraform?

Heroku App Setup
Multi-Tier Applications
Self-Service Clusters
Software Demos
Disposable Environments
Software Defined Networking
Resource Schedulers
Multi-Cloud Deployment
https://www.terraform.io/intro/use-cases.html

3. Как Terraform может так эффективно создавать инфраструктуру?

Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources. Because of this, Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

4. У вас разные среды, и вы хотите развернуть свою инфраструктуру во всех средах, таких как dev, test, prod и т. Д. Как вы этого добиваетесь?

Every Application goes through different environments before it is deployed into production. It’s always best practice to have similar environments for consistency purposes. It’s so easy to replicate the bugs and fix them easily. It’s not easy to replicate the same set of infrastructure in each environment if we do that manually. Terraform makes it easy to create infrastructure in a multi-cloud environment.
Please go through the below article for detailed explanation
Terraform — 5 Ways To Create Infrastructure in Multiple Environments
1) Using Folders — Method 1
2) Using Folders — Method 2
3) Workspaces
4) Modules
5) Terragrunt

5. Является ли Terraform облачным агостиком, и если да, то что это означает?

Yes
cloud-agnostic and allows a single configuration to be used to manage multiple providers, and to even handle cross-cloud dependencies.
It simplifies management and orchestration, helping operators build large-scale multi-cloud infrastructures.

6. Что такое Terraform State и какова его цель?

Every time you run Terraform, it records information about what infrastructure it created in a Terraform state file. By default, when you run Terraform in the folder /some/folder, Terraform creates the file /some/folder/terraform.tfstate. This file contains a custom JSON format that records a mapping from the Terraform resources in your configuration files to the representation of those resources in the real world.
Mapping to the Real World
Terraform requires some sort of database to map Terraform config to the real world because you can't find the same functionality in every cloud provider. You need to have some kind of mechanism to be cloud-agnostic
Metadata
Terraform must also track metadata such as resource dependencies, pointer to the provider configuration that was most recently used with the resource in situations where multiple aliased providers are present.
Performance
When running a terraform plan, Terraform must know the current state of resources in order to effectively determine the changes that it needs to make to reach your desired configuration.For larger infrastructures, querying every resource is too slow. Many cloud providers do not provide APIs to query multiple resources at once, and the round trip time for each resource is hundreds of milliseconds. So, Terraform stores a cache of the attribute values for all resources in the state. This is the most optional feature of Terraform state and is done only as a performance improvement.
Syncing
When two people works on the same file and doing some changes to the infrastructure. Its very important for everyone to be working with the same state so that operations will be applied to the same remote objects.
https://www.terraform.io/docs/state/purpose.html

7. Как называется файл состояния терраформирования?

terraform.tfstate

8. Где вы храните файлы состояния терраформирования при работе с командой?

You should store state files in the remote backend when you are woking in a team for collaboration. Usually, GCP Cloud Storage or AWS S3 buckets or Azure Blob Storage.

9. Куда вы помещаете конфигурации Terraform, чтобы можно было настроить поведение самого Terraform?

The special terraform configuration block type is used to configure some behaviors of Terraform itself, such as requiring a minimum Terraform version to apply your configuration.
terraform {
  # ...
}

10. Что такое поставщики и как их настроить?

A provider is a plugin that Terraform uses to translate the API interactions with the service. A provider is responsible for understanding API interactions and exposing resources. Because Terraform can interact with any API, you can represent almost any infrastructure type as a resource in Terraform.
https://www.terraform.io/docs/configuration/providers.html
provider "google" {
  project = "acme-app"
  region  = "us-central1"
}
The name given in the block header ("google" in this example) is the name of the provider to configure. Terraform associates each resource type with a provider by taking the first word of the resource type name (separated by underscores), and so the "google" provider is assumed to be the provider for the resource type name google_compute_instance.
The body of the block (between { and }) contains configuration arguments for the provider itself. Most arguments in this section are specified by the provider itself; in this example both project and region are specific to the google provider.

11. Что такое инициализация провайдера и зачем она нам нужна?

Each time a new provider is added to configuration -- either explicitly via a provider block or by adding a resource from that provider -- Terraform must initialize the provider before it can be used. 
Initialization downloads and installs the provider's plugin so that it can later be executed.
Provider initialization is one of the actions of terraform init. Running this command will download and initialize any providers that are not already initialized.

12. Как ограничить версию провайдера?

To constrain the provider version as suggested, add a required_providers block inside a terraform block:
terraform {
  required_providers {
    aws = "~> 1.0"
  }
}

13. Сколько способов вы можете настроить версии провайдера?

1. With required_providers blocks under terraform block
terraform {
  required_providers {
    aws = "~> 1.0"
  }
}
2. Provider version constraints can also be specified using a version argument within a provider block
provider {
  version= "1.0"
}

14. Как настроить несколько экземпляров провайдера?

alias
You can optionally define multiple configurations for the same provider, and select which one to use on a per-resource or per-module basis.

15. Зачем нам нужны экземпляры с несколькими поставщиками?

Some of the example scenarios:a. multiple regions for a cloud platform
b. targeting multiple Docker hosts
c. multiple Consul hosts, etc.

16. Как определить конфигурации нескольких поставщиков?

To include multiple configurations for a given provider, include multiple provider blocks with the same provider name, but set the alias meta-argument to an alias name to use for each additional configuration.# The default provider configuration
provider "aws" {
  region = "us-east-1"
}
# Additional provider configuration for west coast region
provider "aws" {
  alias  = "west"
  region = "us-west-2"
}

17. Как выбрать альтернативных провайдеров?

By default, resources use a default provider configuration inferred from the first word of the resource type name. For example, a resource of type aws_instance uses the default (un-aliased) aws provider configuration unless otherwise stated.
resource "aws_instance" "foo" {
  provider = aws.west
  # ...
}

18. Что такое кэш подключаемого модуля поставщика?

By default, terraform init downloads plugins into a subdirectory of the working directory so that each working directory is self-contained. As a consequence, if you have multiple configurations that use the same provider then a separate copy of its plugin will be downloaded for each configuration.Given that provider plugins can be quite large (on the order of hundreds of megabytes), this default behavior can be inconvenient for those with slow or metered Internet connections. Therefore Terraform optionally allows the use of a local directory as a shared plugin cache, which then allows each distinct plugin binary to be downloaded only once.

19. Когда вы используете кеш плагина, вы в конечном итоге увеличиваете каталог кеша с разными версиями. Кто несет ответственность за его чистку?

User
Terraform will never itself delete a plugin from the plugin cache once it's been placed there. Over time, as plugins are upgraded, the cache directory may grow to contain several unused versions which must be manually deleted.

20. Если над одной конфигурацией работают разные команды. Как добиться единообразного форматирования файлов?

terraform fmt
This command automatically updates configurations in the current directory for easy readability and consistency.

Следите за другими частями этого места !!

Часть 2

Скоро будет!!