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 191 discussion

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

FILL BLANK -
You need to migrate a workspace to use a remote backend. After updating your configuration, what command do you run to perform the migration?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

Show Suggested Answer Hide Answer
Suggested Answer: terraform init

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
dinesh198728
Highly Voted 2 years, 2 months ago
terraform init 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.
upvoted 11 times
...
XP_2600
Highly Voted 1 year, 9 months ago
I think terraform init -migrate-state The -migrate-state option will attempt to copy existing state to the new backend, and depending on what changed, may result in interactive prompts to confirm migration of workspace states. The -force-copy option suppresses these prompts and answers "yes" to the migration questions. Enabling -force-copy also automatically enables the -migrate-state option. https://developer.hashicorp.com/terraform/cli/commands/init
upvoted 7 times
...
nmnm22
Most Recent 3 months, 2 weeks ago
terraform init
upvoted 1 times
...
tuso
5 months, 3 weeks ago
Just did it some days ago (from local to s3). I did "terraform init" and then terraform asks to confirm the migration of your state file. No "-migrate-state" needed.
upvoted 1 times
...
Komas1999
5 months, 3 weeks ago
terraform init -migrate-state missing the last part in the correct answer
upvoted 1 times
...
alen995454
10 months, 1 week ago
Re-running init with an already-initialized backend will update the working directory to use the new backend settings. Either -reconfigure or -migrate-state must be supplied to update the backend configuration https://developer.hashicorp.com/terraform/cli/commands/init I'm going w/ : terraform init -migrate-state
upvoted 3 times
...
BaburTurk
1 year, 2 months ago
terraform init -migrate-state. This command will tell Terraform to read the existing state file and migrate it to the new remote backend. The -migrate-state flag is only available in Terraform 0.15 and later. If you are using an older version of Terraform, you will need to use the terraform state mv command to manually migrate the state file. Here is an example of how to use the terraform init -migrate-state command: terraform init -migrate-state \ -backend=s3://my-bucket/my-workspace
upvoted 2 times
enklau
4 months ago
i agree with ur answer but terraform state mv is for moving individual resources within the state file
upvoted 1 times
...
...
Nick_001
1 year, 8 months ago
terraform init -migrate-state
upvoted 4 times
...
LeyLey
1 year, 9 months ago
terraform init --reconfigure is correct
upvoted 1 times
...
Daro_
1 year, 9 months ago
terraform init --reconfigure should be correct<<<<<<<<<<<< https://support.hashicorp.com/hc/en-us/articles/360001151948-Migrate-Workspace-State-Using-Terraform-State-Push-Pull
upvoted 2 times
...
yair319732
1 year, 10 months ago
terraform init --reconfigure , but I think terraform init will be sufficient.
upvoted 1 times
...
fedeX
1 year, 10 months ago
terraform init -upgrade To migrate a workspace to use a remote backend, you need to run the terraform init command with the -upgrade flag. This will cause Terraform to upgrade the workspace to use the new backend configuration. For example, if you have updated your configuration to use an S3 backend. This will cause Terraform to create any necessary resources in the remote backend (such as an S3 bucket) and migrate the workspace state to the new backend. It is important to note that this will overwrite any existing state in the remote backend, so it is recommended to take a backup of the state before running this command.
upvoted 1 times
E_aws
1 year, 10 months ago
"terraform init" would be enough
upvoted 2 times
...
Daro_
1 year, 9 months ago
terraform init -upgrade -- to upgrade version of providers which are already installed
upvoted 1 times
...
...
BaburTurk
1 year, 11 months ago
https://support.hashicorp.com/hc/en-us/articles/360001151948-Migrate-Workspace-State-Using-Terraform-State-Push-Pull
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 ...