Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 120


You have to initialize a Terraform backend before it can be configured.

Show Answer
Correct Answer: B

The correct answer is False. In Terraform, you need to configure the backend first by specifying the backend type and details in your Terraform configuration files (usually main.tf) before you initialize Terraform. After specifying the backend, you run the terraform init command, which initializes the backend according to the provided configuration. Initialization sets up the working directory and prepares it for further operations, but the configuration must come first.

Discussion

39 comments
Sign in to comment
yaza
Apr 6, 2023

Selected Answer: B you cannot initialize something that does not exist, so obviously you have to configure it first

zyxphreezOption: B
Mar 7, 2023

you first configure the backed and then initialize ....therefore should be B

TechHero
Jul 19, 2023

A. True Before configuring a backend in Terraform, the backend must be initialized with the terraform init command. This command will initialize the backend, configure the backend and download any necessary providers specified in the Terraform code. It also performs some other tasks like checking for the existence of the state file in the backend, and creating it if it doesn't exist. If you don't initialize the backend before configuring it, Terraform will not be able to find the backend and will assume that it is using the local filesystem as the backend, which can lead to unexpected results. It's important to note that, if you are using a remote backend, you must run terraform init command on the machine where you want to run the terraform apply command, it will not work if you run the command on a different machine. It's also important to note that if you are changing the backend configuration, you must run terraform init again with the -reconfigure flag.

NunyabiznesOption: B
Sep 27, 2023

B. False The backend configuration is specified within the Terraform configuration files, typically in the main.tf file. You don't have to initialize a backend before configuring it; instead, you provide the backend configuration within the Terraform files, and then run terraform init. The initialization process will set up the backend as per the configuration provided. So, the backend configuration is done first, and then you initialize Terraform, which sets up the backend accordingly.

keiffo2
Mar 6, 2023

Whenever a configuration's backend changes, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations. TRUE

vichu0308
Mar 8, 2023

Backends are configured directly in Terraform files in the terraform section. After configuring a backend, it has to be initialized. Therefore its B

AnininaOption: A
Jun 21, 2023

ChatGPT says True

piezaS
Nov 21, 2023

A. True Before configuring and using a Terraform backend, you need to initialize it first. The initialization process sets up the backend configuration, such as the type of backend (e.g., S3, Azure Storage, etc.) and the connection details. This is done by running the terraform init command, which initializes the working directory and prepares it for Terraform operations, including the configuration of the backend.

Priyankakanna
Nov 23, 2023

What I understand is who choose false confusing with terminology its config nor writting configuration ie before creating the resource ie apply we need to initialise the backend so we have to run init so that from the configuration files it will download the necessary plugins for the backend and then apply the configuration to configure the resources

RVivekOption: A
Mar 29, 2023

A - You have to initialize the backend

alifieOption: A
Apr 14, 2023

During init, the root configuration directory is consulted for backend configuration and the chosen backend is initialized using the given configuration settings.

wanrltw
Jun 9, 2023

So first you need to configure the backend and only AFTER run the init. Thus the answer is B.

alirasouliOption: B
Jun 4, 2023

Whatever change you make in the backend, you need to run `terraform init` again. The backend does not pick the changes dynamically in contrast to, e.g. resources pick from variables. Therefore adding configuration after initialization of the backend is non-sense. You can also refer to the documentation: "When you change a backend's configuration, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations." https://developer.hashicorp.com/terraform/language/settings/backends/configuration#initialization

agmesasOption: B
Aug 7, 2023

B, making the exam difficult and confusing with wording but easy content. You must initialize a terraform backend before it can be used but you must (in case not use a local backend) configure the backend before initializing. First, create a backend.tf config, then run terrafom init to use it.

Stanislav4907Option: A
Oct 7, 2023

Yes, before configuring a Terraform backend, you need to initialize it. Initializing a backend sets up the necessary resources and configurations to use a particular backend, such as creating storage containers or initializing remote state. To initialize a backend, you can use the terraform init command. This command reads the configuration files in your working directory and installs any necessary plugins or modules, as well as initializes the backend you have specified in your configuration. After initializing the backend, you can configure it by adding the appropriate configuration to your Terraform configuration files. The backend configuration typically includes details such as the backend type, the backend's credentials or access details, and any additional settings specific to the backend you're using. Once you have initialized and configured your backend, you can then use Terraform to create and manage infrastructure resources in the backend.

milan92stankovicOption: B
Dec 15, 2023

I vote for B

arunrkaushik
Feb 12, 2024

Correct is B: How sleepy are people who voted for an option A... like compiling the code before writing it.

aanataliyaOption: A
Mar 14, 2024

Configure doesnt mean writing configuration of "backend block" in this context. Hashicorp always use "block" if they want to mention writing configuration. example : backend block, terraform block or cloud block. If I say, I want to configure linux server doesnt mean writing HCL for linux server. Just writing "backend block" doesnt actually configure backend. You have to run/execute that HCL "backend block" to actually create backend configuration. During actual backend configuration, Terraform writes the backend configuration in plain text in two separate files. Check Ref: https://developer.hashicorp.com/terraform/language/settings/backends/configuration And this cannot be done until we first execute init.

3cc17f1
Apr 25, 2024

That link you provided contradicts your answer: "When you change a backend's configuration, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations." Clearly this suggests that configuration occurs PRIOR to initialisation.

samimshaikhOption: B
Jun 29, 2024

B When you change a backend's configuration, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations. After you initialize, Terraform creates a .terraform/ directory locally. This directory contains the most recent backend configuration, including any authentication parameters you provided to the Terraform CLI. Do not check this directory into Git, as it may contain sensitive credentials for your remote backend.

RevSD
Jul 4, 2024

In case of local backend , just an init is sufficient and no config is needed. May be question should be more clearer to say if it is local or remote

Hizumi
Mar 5, 2023

Answer is True Whenever a configuration's backend changes, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations. Reference: https://www.terraform.io/language/settings/backends/configuration

amanpOption: A
Mar 5, 2023

It is true.

dinesh198728Option: A
Mar 8, 2023

It should be A. Backend should be initialized for the first time.

dinesh198728Option: A
Mar 10, 2023

Initialization Whenever a configuration's backend changes, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations. When changing backends, Terraform will give you the option to migrate your state to the new backend. This lets you adopt backends without losing any existing state. To be extra careful, we always recommend manually backing up your state as well. You can do this by simply copying your terraform.tfstate file to another location. The initialization process should create a backup as well, but it never hurts to be safe! https://www.terraform.io/language/settings/backends/configuration

wanrltw
Jun 9, 2023

"Whenever a configuration's backend changes" sounds like the configuration change happens BEFORE running the init, doesn't it?

Pinky0289
Mar 13, 2023

Option A. True Before proceeding to configuration, the backend needs to be initialized.

ArizonaClassics
Jun 7, 2023

Backends are configured directly in Terraform files in the terraform section. After configuring a backend, it has to be initialized. Below, we show a complete example of configuring the "consul" backend: terraform { backend "consul" { address = "demo.consul.io" scheme = "https" path = "example_app/terraform_state" } } You specify the backend type as a key to the backend stanza. Within the stanza are backend-specific configuration keys. The list of supported backends and their configuration is in the sidebar to the left. Only one backend may be specified and the configuration may not contain interpolations. Terraform will validate this.

macross
Jun 8, 2023

Perhaps its habit - I init before I config. But I can see you not doing init first. Still, just for habit - I am going with A

robertninho
Jul 5, 2023

Option A, "True," is incorrect because you do not have to initialize a Terraform backend before it can be configured. In Terraform, the backend is responsible for storing the Terraform state and determining how updates to the state are stored and how the state is loaded when you execute Terraform commands

robertninho
Jul 5, 2023

B for me

srcntpc
Jul 7, 2023

Selected Answer: A Initialization. When you change a backend's configuration, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations. After you initialize, Terraform creates a . terraform/ directory locally.

resnefOption: B
Jul 15, 2023

When you change a backend's configuration, you must run terraform init again to validate and configure the backend before you can perform any plans, applies, or state operations.

pyro7
Jul 31, 2023

The Correct answer is A True. The Terraform backend must be initialized before it can be configured.

Mahendran103Option: B
Aug 14, 2023

you cannot initialize something that does not exist

rotimislawOption: B
Aug 24, 2023

Seems B to me

Americanman
Aug 28, 2023

backend needs to be configured first.

khaled_razoukOption: B
Sep 10, 2023

you can't do that if it doesn't exist

_sreya23_Option: B
Sep 24, 2023

Without configuration (not writing code) you can't initialize it.

Ni33Option: B
Nov 9, 2023

B is the correct answer !

kiran15789Option: A
Nov 13, 2023

Before configuring a backend in Terraform, it is necessary to initialize it. This is done by running the terraform init command, which sets up the working directory for the configuration, downloads any necessary plugins, and initializes the backend. Once the backend is initialized, you can configure it by editing the backend block in the Terraform configuration file.

sdm13168Option: B
Nov 18, 2023

B you need to configure the backend first, then run terraform init

shortcutOption: B
May 15, 2024

I guess, here "initialize" means "instantiate" i.e. the backend must be there For e.g.- a S3 bucket should be present first before we can use it (i.e. configure it in HCL). So, from that perspective, it should be "A". However, we can also have local backends, which is where the terraform configuration file themselves reside, and we don't have to separately instantiate those. Hence, the answer is "B"