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.
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"
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.
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.
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
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.
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.
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.
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.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
yaza
Highly Voted 2 years, 1 month agozyxphreez
Highly Voted 2 years, 2 months agoRevSD
Most Recent 10 months, 3 weeks agosamimshaikh
11 months agoshortcut
1 year agoaanataliya
1 year, 2 months ago3cc17f1
1 year, 1 month agoarunrkaushik
1 year, 3 months agomilan92stankovic
1 year, 5 months agoPriyankakanna
1 year, 6 months agopiezaS
1 year, 6 months agosdm13168
1 year, 6 months agokiran15789
1 year, 6 months agoNi33
1 year, 6 months agoStanislav4907
1 year, 7 months agoNunyabiznes
1 year, 8 months ago_sreya23_
1 year, 8 months agokhaled_razouk
1 year, 8 months ago