0
0
Terraformcloud~5 mins

State replace-provider in Terraform - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the Terraform command state replace-provider do?
It updates the provider references in the Terraform state file, replacing an old provider source with a new one without changing the actual resources.
Click to reveal answer
beginner
Why would you use terraform state replace-provider?
To fix provider source changes, such as when a provider moves to a new namespace or changes its name, ensuring Terraform can manage resources correctly.
Click to reveal answer
beginner
What is the basic syntax of the terraform state replace-provider command?
terraform state replace-provider \
  old-provider-address \
  new-provider-address
where addresses are provider source strings like registry.terraform.io/hashicorp/aws.
Click to reveal answer
beginner
Can terraform state replace-provider change resource configurations?
No, it only updates the provider references in the state file. Resource configurations in code remain unchanged.
Click to reveal answer
intermediate
What should you do before running terraform state replace-provider?
Back up your Terraform state file to avoid accidental loss and ensure you have the new provider installed or configured.
Click to reveal answer
What is the main purpose of terraform state replace-provider?
ATo update provider references in the state file
BTo upgrade Terraform version
CTo delete resources from the state
DTo change resource configurations
Which of these is a valid use case for terraform state replace-provider?
AChanging resource attributes in code
BAdding new resources to Terraform
CDestroying all resources
DChanging the provider namespace after a provider is moved
Does terraform state replace-provider modify your Terraform configuration files?
AYes, it updates the .tf files
BNo, it only updates the state file
CYes, it changes resource blocks
DNo, it deletes the configuration files
What should you do before running terraform state replace-provider?
ARun <code>terraform destroy</code>
BDelete your Terraform configuration
CBack up your state file
DUninstall Terraform
Which command would you use to replace the provider registry.terraform.io/oldcorp/aws with registry.terraform.io/newcorp/aws?
Aterraform state replace-provider registry.terraform.io/oldcorp/aws registry.terraform.io/newcorp/aws
Bterraform provider replace registry.terraform.io/oldcorp/aws registry.terraform.io/newcorp/aws
Cterraform state mv registry.terraform.io/oldcorp/aws registry.terraform.io/newcorp/aws
Dterraform provider update registry.terraform.io/oldcorp/aws registry.terraform.io/newcorp/aws
Explain what terraform state replace-provider does and when you would use it.
Think about provider source address changes and state file updates.
You got /4 concepts.
    Describe the steps you should take before and after running terraform state replace-provider.
    Consider safety and verification steps.
    You got /4 concepts.