Terraform Error: Warning: Value for undeclared variable

Error

C:\Users\Rajesh Kumar\Desktop\Terarform\ws>terraform plan
╷
│ Warning: Value for undeclared variable
│
│ The root module does not declare a variable named "mytags" but a value was found in file "terraform.tfvars". If you
│ meant to use this value, add a "variable" block to the configuration.
│
│ To silence these warnings, use TF_VAR_... environment variables to provide certain "global" settings to all
│ configurations in your organization. To reduce the verbosity of these warnings, use the -compact-warnings option.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 7, in resource "aws_instance" "dbserver":
│    7:     Name = var.mytags
│
│ An input variable with the name "mytags" has not been declared. This variable can be declared with a variable
│ "mytags" {} block.
╵

Solution

Make sure you declare variable

Terraform Error: Failed to query available provider packagesTerraform Error:

Error

Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws-instance: provider registry registry.terraform.io
│ does not have a provider named registry.terraform.io/hashicorp/aws-instance
│
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a
│ module. To see which modules are currently depending on hashicorp/aws-instance, run the following command:
│     terraform providers

Terraform Error: Workspace is not emptyTerraform Error:

Error

terraform workspace delete qa
╷
│ Error: Workspace is not empty
│
│ Workspace "qa" is currently tracking the following resource instances:
│   - aws_instance.example-number[0]
│
│ Deleting this workspace would cause Terraform to lose track of any associated remote objects, which would then
│ require you to delete them manually outside of Terraform. You should destroy these objects with Terraform before
│ deleting the workspace.
│
│ If you want to delete this workspace anyway, and have Terraform forget about these managed objects, use the -force
│ option to disable this safety check.

Solution


terraform workspace select default
terraform workspace delete qa [ ERROR ] 
terraform workspace select qa
terraform destroy --auto-approve
terraform workspace select default
terraform workspace delete qa