nhurel / terraspec

Terraform unit test framework
Mozilla Public License 2.0
79 stars 7 forks source link

Issues with 0.14 #16

Closed wyardley closed 3 years ago

wyardley commented 3 years ago

Hi -- Thanks for building this tool. I've had my eye on it for a while, because this is the exact thing I've been looking for for ages, and finally got around to trying to setup some test cases.

I built off the tf0.14 branch (per #14), and tried to create a simple test case, however, I'm wondering if the changes in the way the registry works with 0.14 is causing an issue?

in main.tf:

module "test-cluster" {
  source           = "../../../modules/gke_cluster"
  name             = "testy"
  location         = "us-central1"
 // some stuff skipped here [...]
}

terraform {
  required_version = ">= 0.14"
  required_providers {
    google = {
      source  = "hashicorp/google"
    }
    google-beta = {
      source  = "hashicorp/google-beta"
    }
  }
}
% tree
.
└── modules_gke_cluster_simple
    ├── main.tf
    └── spec
        └── default
            └── default.tfspec
## from within modules_gke_cluster_simple
% tf init --backend=false
Initializing modules...
- test-cluster in ../../../modules/gke_cluster

Initializing provider plugins...
- Finding latest version of hashicorp/google-beta...
- Finding latest version of hashicorp/google...
- Using hashicorp/google v3.58.0 from the shared cache directory
- Using hashicorp/google-beta v3.58.0 from the shared cache directory

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run "terraform init" in the future.

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
% terraspec
🏷  default
Failed to instantiate provider "registry.terraform.io/hashicorp/google" to obtain schema: unknown provider "registry.terraform.io/hashicorp/google" : 
Failed to instantiate provider "registry.terraform.io/hashicorp/google-beta" to obtain schema: unknown provider "registry.terraform.io/hashicorp/google-beta" : 

🏁 1 suites run in 3.848539ms    error : 1   success : 0
nhurel commented 3 years ago

Hello I've pushed a fix on tf0.14 branch. Terraform now downloads providers under the .terraform/providers directory instead of .terraform/plugins.

wyardley commented 3 years ago

Thanks. I’ll give it a shot.

wyardley commented 3 years ago

Thanks - got that to work (after fixing a local $PATH issue).