Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Terraform Associate All Questions

View all questions & answers for the Terraform Associate exam

Exam Terraform Associate topic 1 question 149 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 149
Topic #: 1
[All Terraform Associate Questions]

Once a new Terraform backend is configured with a Terraform code block, which command(s) is (are) used to migrate the state file?

  • A. terraform apply
  • B. terraform push
  • C. terraform destroy, then terraform apply
  • D. terraform init
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
keiffo2
Highly Voted 2 years, 2 months ago
D: I think Migrate the state file Once you have authenticated to Terraform Cloud, you're ready to migrate your local state file to Terraform Cloud. To begin the migration, reinitialize. This causes Terraform to recognize your cloud block configuration. $ terraform init Initializing Terraform Cloud... Do you wish to proceed? As part of migrating to Terraform Cloud, Terraform can optionally copy your current workspace state to the configured Terraform Cloud workspace. Answer "yes" to copy the latest state snapshot to the configured Terraform Cloud workspace. Answer "no" to ignore the existing state and just activate the configured Terraform Cloud workspace with its existing state, if any. Should Terraform migrate your existing state? Enter a value: Copy During reinitialization, Terraform presents a prompt saying that it will copy the state file to your Terraform Cloud workspace. Enter yes and Terraform will migrate the state from your local machine to Terraform Cloud.
upvoted 24 times
...
nakuaadam
Most Recent 8 months, 2 weeks ago
Selected Answer: D
https://developer.hashicorp.com/terraform/tutorials/cloud/cloud-migrate Important: The terraform push command is no longer functional. https://developer.hashicorp.com/terraform/cli/commands/push
upvoted 1 times
...
[Removed]
11 months, 1 week ago
Selected Answer: D
B is correct if the command is "terraform state push"
upvoted 1 times
...
DevoteamAnalytix
1 year, 7 months ago
I think it's B not D because it is about MIGRATING the state file. "Usage: terraform state push [options] PATH" https://developer.hashicorp.com/terraform/cli/commands/state/push "The terraform push command was an early implementation of remote Terraform runs. It allowed teams to push a configuration to a remote run environment in a discontinued version of Terraform Enterprise." https://developer.hashicorp.com/terraform/cli/commands/push
upvoted 2 times
...
Stanislav4907
1 year, 7 months ago
Selected Answer: D
Once a new Terraform backend is configured with a Terraform code block, you can use the following command to migrate the state file from the previous backend to the new one: terraform init -migrate-state
upvoted 3 times
...
Nunyabiznes
1 year, 7 months ago
Selected Answer: D
Terraform push has been retired after version 0.12.0
upvoted 3 times
...
camps
1 year, 7 months ago
Selected Answer: D
D. terraform init. When configuring a new Terraform backend, the state file needs to be migrated to the new backend so that it can be used to manage infrastructure state going forward. The terraform init command is used to initialize a new backend and migrate the state file to that backend.
upvoted 2 times
...
mamoon_malta2022
1 year, 8 months ago
Answer D: The terraform state push command is used to manually upload a local state file to remote state. This command also works with local state. This command should rarely be used. It is meant only as a utility in case manual intervention is necessary with the remote state.
upvoted 1 times
...
Americanman
1 year, 8 months ago
The terraform state push command is used to manually upload a local state file to remote state. Would go with D
upvoted 2 times
...
z466235244
1 year, 9 months ago
Selected Answer: D
Terraform push is no long functional
upvoted 3 times
...
princajen
1 year, 9 months ago
After configuring a new Terraform backend with a Terraform code block, you will need to use the terraform init command to initialize the backend and download any necessary provider plugins. Once you have initialized the backend, you can use the terraform state command to manage the state file. If you have an existing state file that you need to migrate to the new backend, you can use the terraform state pull command to download the current state file, and then use the terraform state push command to upload it to the new backend.
upvoted 1 times
...
lezgino
1 year, 9 months ago
The correct command to migrate the state file to a new backend is: "terraform init". The "terraform init" command will detect the new backend configuration and prompt you to copy your existing state to the new backend. B is correct
upvoted 1 times
...
Only5
1 year, 10 months ago
This is from chatGPT - answer : B The command used to migrate the state file to a new Terraform backend is terraform state push. This command uploads the local state file to the new backend, replacing the state that may already exist in the backend.
upvoted 1 times
...
ssanjayt
1 year, 10 months ago
Selected Answer: D
Answer is D coz terraform push is deprecated and does not operate in the current version of TFE.
upvoted 2 times
...
InformationOverload
1 year, 11 months ago
id go with B; terraform state push
upvoted 1 times
InformationOverload
1 year, 11 months ago
I change my answer to D since you first have to terraform init and then use terraform state push. (Answer B says just terraform push, and that is not correct)
upvoted 3 times
...
...
alirasouli
1 year, 11 months ago
Selected Answer: D
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. Reference: https://developer.hashicorp.com/terraform/language/settings/backends/configuration#initialization
upvoted 3 times
...
ArizonaClassics
1 year, 11 months ago
D: Command: state push The terraform state push command is used to manually upload a local state file to remote state. This command also works with local state. This command should rarely be used. It is meant only as a utility in case manual intervention is necessary with the remote stat
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...