I am running NixOS 24.05.20240903.6f6c45b.
Trying to get a devshell setup for working with terraform. This is the basic flake:
# flake.nix
{
description = "";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
futils.url = "github:numtide/flake-utils";
};
outputs =
{ self, nixpkgs, futils }: (
futils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
terraform
google-cloud-sdk
];
};
}
)
);
}
# provider.tf
terraform {
required_providers {
random = {
source = "hashicorp/random"
version = "3.6.2"
}
google = {
source = "hashicorp/google"
version = "6.2.0"
}
}
}
After doing a nix develop .#
, I run terraform init and terraform plan and these are my outputs:
$ terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/google from the dependency lock file
- Reusing previous version of hashicorp/random from the dependency lock file
- Installing hashicorp/google v6.2.0...
- Installed hashicorp/google v6.2.0 (signed by HashiCorp)
- Installing hashicorp/random v3.6.2...
- Installed hashicorp/random v3.6.2 (signed by HashiCorp)
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.
$ terraform plan
╷
│ Error: Failed to load plugin schemas
│
│ Error while loading schemas for plugin components: 2 problems:
│
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/google:
│ failed to instantiate provider "registry.terraform.io/hashicorp/google" to obtain schema: fork/exec
│ .terraform/providers/registry.terraform.io/hashicorp/google/6.2.0/linux_amd64/terraform-provider-google_v6.2.0_x5:
│ permission denied.
│ - Failed to obtain provider schema: Could not load the schema for provider registry.terraform.io/hashicorp/random:
│ failed to instantiate provider "registry.terraform.io/hashicorp/random" to obtain schema: fork/exec
│ .terraform/providers/registry.terraform.io/hashicorp/random/3.6.2/linux_amd64/terraform-provider-random_v3.6.2_x5:
│ permission denied..
╵
what am I doing wrong here, can’t doesn’t the plugin load? Looking at the files in the terraform provider folders permissions look correct
$ ls -lan .terraform/providers/registry.terraform.io/hashicorp/*
.terraform/providers/registry.terraform.io/hashicorp/google:
total 12
drwxr-xr-x 3 1000 100 4096 Sep 10 10:11 .
drwxr-xr-x 4 1000 100 4096 Sep 10 10:11 ..
drwxr-xr-x 3 1000 100 4096 Sep 10 10:11 6.2.0
.terraform/providers/registry.terraform.io/hashicorp/random:
total 12
drwxr-xr-x 3 1000 100 4096 Sep 10 10:11 .
drwxr-xr-x 4 1000 100 4096 Sep 10 10:11 ..
drwxr-xr-x 3 1000 100 4096 Sep 10 10:11 3.6.2
though I can’t seem to run the binaries manually
$ .terraform/providers/registry.terraform.io/hashicorp/google/6.2.0/li
nux_amd64/terraform-provider-google_v6.2.0_x5
bash: .terraform/providers/registry.terraform.io/hashicorp/google/6.2.0/linux_amd64/terraform-provider-google_v6.2.0_x5: Permission denied
$ ls -lan .terraform/providers/registry.terraform.io/hashicorp/google/
6.2.0/linux_amd64/terraform-provider-google_v6.2.0_x5
-rwxr-xr-x 1 1000 100 104017920 Sep 10 10:11 .terraform/providers/registry.terraform.io/hashicorp/google/6.2.0/linux_amd64/terraform-provider-google_v6.2.0_x5