0

I have a terraform project that I'm working on that I wanted to do automated testing against.

Locally, the testing framework works fine but it's failing on my build/test server.

I have checked and order of events on the server are:

  1. Check if the terraform folder and lock file exist, they don't
  2. Run terraform init on 'default' workspace
  3. Check if the terraform folder and lock file exist, they do
  4. Swap terraform workspaces to my intended workspace and run init again
  5. Build a custom tfvars file
  6. Run apply on the workspace with the var file

The error I'm getting is:

[31mâ•·[0m[0m
[31m│[0m [0m[1m[31mError: [0m[0m[1mFailed to load plugin schemas[0m
[31m│[0m [0m
[31m│[0m [0m[0mError while loading schemas for plugin components: 2 problems:
[31m│[0m [0m
[31m│[0m [0m- Failed to obtain provider schema: Could not load the schema for provider
[31m│[0m [0mregistry.terraform.io/hashicorp/aws: failed to instantiate provider
[31m│[0m [0m"registry.terraform.io/hashicorp/aws" to obtain schema: Unrecognized remote
[31m│[0m [0mplugin message: 
[31m│[0m [0m
[31m│[0m [0mThis usually means that the plugin is either invalid or simply
[31m│[0m [0mneeds to be recompiled to support the latest protocol..
[31m│[0m [0m- Failed to obtain provider schema: Could not load the schema for provider
[31m│[0m [0mregistry.terraform.io/hashicorp/azurerm: failed to instantiate provider
[31m│[0m [0m"registry.terraform.io/hashicorp/azurerm" to obtain schema: Unrecognized
[31m│[0m [0mremote plugin message: 
[31m│[0m [0m
[31m│[0m [0mThis usually means that the plugin is either invalid or simply
[31m│[0m [0mneeds to be recompiled to support the latest protocol...
[31m╵[0m[0m

Both Error: Failed to load plugin schemas | Azure | Terraform and Terraform Error: Failed to load plugin schemas say to remove the old terraform folder but in this case it doesn't exist prior to the init

I have tried using -upgrade and -reconfigure in the init as well as check if the terraform files exist prior to the init.

I don't understand why I'm getting this failure during the apply stage.

10
  • Which OS and CPU are you using?
    – Marko E
    Dec 13, 2022 at 17:25
  • @MarkoE, Ubuntu and a 64 bit CPU. Why do you ask? I'd like to know more about the issue you're thinking about. Dec 13, 2022 at 17:44
  • Sometimes it happens that there isn't a suitable binary (e.g., M1 chip) but I was just wondering if it's an unusual combination.
    – Marko E
    Dec 13, 2022 at 17:58
  • It seems like the plugin executables are somehow incompatible with your system and so are failing to start up at all; Terraform is noticing that they aren't correctly speaking the plugin protocol, and so returns an error. I'm not sure why that would be but it might be interesting to try to directly execute the plugin programs from your shell. You can find them under .terraform/providers and after all of the nested directories you will find executable files with name prefixes like terraform-provider-aws. Dec 13, 2022 at 18:28
  • 1
    (If you try this and learn something interesting, please edit your question to include the exact error messages you saw.) Dec 13, 2022 at 18:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.