GSEC · Question #258
Which Terraform command should be run immediately after creating a new configuration file for a cloud-based virtual machine?
The correct answer is A. Init. The first Terraform command after creating a new configuration is 'init', which prepares the working directory and downloads required providers and modules.
Question
Which Terraform command should be run immediately after creating a new configuration file for a cloud-based virtual machine?
Options
- AInit
- BBuild
- CApply
- DCommit
How the community answered
(48 responses)- A73% (35)
- B4% (2)
- C17% (8)
- D6% (3)
Why each option
The first Terraform command after creating a new configuration is 'init', which prepares the working directory and downloads required providers and modules.
'terraform init' initializes the working directory by downloading and installing the provider plugins and modules declared in the configuration. It must be run before any other Terraform commands because it sets up the backend and the dependency lock file required for planning and applying changes.
'build' is not a valid Terraform CLI subcommand and does not exist in the Terraform workflow.
'terraform apply' provisions infrastructure but cannot run successfully before 'terraform init' has initialized the providers and configured the backend.
'commit' is a Git version control command and is not part of the Terraform CLI workflow.
Concept tested: Terraform workflow initialization command
Source: https://developer.hashicorp.com/terraform/cli/commands/init
Topics
Community Discussion
No community discussion yet for this question.