Exam Terraform Associate All QuestionsBrowse all questions from this exam
Question 22

terraform init initializes a sample main.tf file in the current directory.

    Correct Answer: B

    The terraform init command initializes a new or existing Terraform working directory by downloading and installing any necessary provider plugins and setting up the backend. It does not create a sample main.tf file in the current directory. The main.tf file is a configuration file that must be created manually by the user. If a main.tf file already exists, terraform init will set up the directory based on its contents. Therefore, the correct answer is that terraform init does not initialize a sample main.tf file.

Discussion
Jlee7Option: B

The answer is False. The terraform init command does not initialize a sample main.tf file in the current directory. It initializes the working directory by downloading and installing provider plugins, downloading modules, and creating a Terraform state file. If you do not have a main.tf file in your working directory, Terraform will create one for you. However, the file will be empty. You will need to add your Terraform configuration to the main.tf file. You can find more information about the terraform init command in the Terraform documentation: https://www.terraform.io/docs/cli/commands/init.html

vibzr2023

The answer is False but terraform init will not create a empty main.tf file but will still initialize the directory for use with Terraform, setting up the necessary internal data structures and downloading providers specified in any Terraform configuration files that are present. If you run terraform init in an empty directory or a directory without any .tf files, Terraform will complete the initialization process but will indicate that no configuration files were found. You'll need to create main.tf or other .tf files manually. I ran a test ------ PS C:\Users\rajna\OneDrive\Documents\TerraformCI> terraform init Terraform initialized in an empty directory! The directory has no Terraform configuration files. You may begin working with Terraform immediately by creating Terraform configuration files. PS C:\Users\rajna\OneDrive\Documents\TerraformCI>

aanataliyaOption: A

Answer is A. See below points. 1. Question does not ask if it creates main.tf or not. it asks wheather main.tf initializes or not. 2. Ran terraform init in empty directory and it warns "The directory has no Terraform configuration files." it means it tries to find configuration file to initialize. 3. configuration file can be of any name with .tf extension. 4. ran command with main.tf in directory with extra curly braces and initialization fails. because it try to initialize main.tf 5. rename main.tf with sample.tf with extra curly braces and it still gives same error. 6. Official documentation says "command initializes a working directory containing Terraform configuration files". main.tf is a configuration file. Again, question never says it creates it. question clearly asks if main.tf is initialized. it means main.tf is already exists w.r.t. this question Reference: https://developer.hashicorp.com/terraform/cli/commands/init Please vote for this correct answer

aanataliya

Those who are thinking its about creating main.tf. Question should have been "terrafom init creates sample init file" not initializes.

Tyler2023

The answer is B The question says terraform init initializes a sample main.tf file, think about the word "sample" meaning it creates the file which is terraform will not create that for you By default, terraform init assumes that the working directory already contains a configuration and will attempt to initialize that configuration. It will never try to create a sample file with sample configuration for you. But the question says it creates that sample file, meaning the direction is empty.

Hp45Option: A

A lot of people are taking this question as init command is creating a main.tf. The context in the question is - if there was a sample main.tf in current folder then init would initialize the file. I vote for A.

SilentHOption: B

Even if the answer is somehow A, I'm voting B on principle.

Shane_COption: B

It absolutely does not generate a main.tf; B is the correct answer

DuboisNicolasDuclairOption: A

A Because terraform initialize *a sample main.tf* it means that we can have a multiple types of files like *.tf So A is a good answer

Shane_C

It absolutely does not generate a main.tf; B is the correct answer

Ni33Option: B

B is correct. It initializes versions and providers irrespective of name of the tf files.

ReziOption: A

A is correct 100% terraform init initializes any file with the extension ".tf" in the pwd. it says "a" sample main.tf, it didn't say "the" sample main.tf. Please note the difference.

AzRNoobOption: B

B. False. The terraform init command initializes a new or existing Terraform working directory by downloading and installing any necessary plugins and modules specified in the configuration. It does not create a main.tf file or any other configuration file in the current directory. You will need to create a main.tf file (or another configuration file with a different name) manually and write the necessary configuration code for your infrastructure. Once you have done so, you can run terraform init to prepare the working directory for use with Terraform.

sagunala5Option: B

By default, terraform init assumes that the working directory already contains a configuration and will attempt to initialize that configuration.

NunyabiznesOption: B

The terraform init command initializes a new or existing Terraform working directory by downloading and installing any required providers and modules, as well as setting up the backend. It does not create a sample main.tf file in the current directory. The main.tf file is a configuration file where you define the resources that you want to create using Terraform. It needs to be created manually by the user.

sagunala5

who asked whether sample main.tf was created, they are asking if is it initialising. so my answer is A

Shane_C

Not correct, init does not generate a main.tf for you; B is the correct answer

Molly1994Option: B

main.tf is an option file. it might not exist. terraform init means to download all basic infrastructures from the configuration file. B false.

DianaPopalOption: B

The correct answer is B. False. The terraform init command in Terraform is used to initialize a Terraform configuration in the current directory. It downloads the necessary provider plugins and sets up the backend configuration. However, terraform init does not create a sample main.tf file in the current directory. The main.tf file is the main configuration file in Terraform where you define your infrastructure resources and their configurations. It is typically created manually by the user and contains the desired state of the infrastructure. When you run terraform init, it looks for an existing main.tf file in the current directory to load the configuration. If the main.tf file does not exist, Terraform will not create it automatically.

karendavtyanOption: B

B. False

FaaizzOption: B

BBBBBBBB

Power123Option: B

B for sure

NunyabiznesOption: B

The terraform init command initializes a new or existing Terraform working directory by downloading and installing any required providers and modules, as well as setting up the backend. It does not create a sample main.tf file in the current directory. The main.tf file is a configuration file where you define the resources that you want to create using Terraform. It needs to be created manually by the user.