-
-
Save grahamc/1217f6e25d2aadd000ed662678e022a8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ cat ./terraform/main.tf | |
# from https://github.com/NixOS/nixpkgs/pull/99198#issuecomment-720686639 | |
terraform { | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
} | |
local = { | |
source = "hashicorp/local" | |
} | |
null = { | |
source = "hashicorp/null" | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ terraform init ./terraform | |
Initializing modules... | |
- xxx in xxx/terraform/xxx | |
Initializing the backend... | |
Initializing provider plugins... | |
- Finding latest version of hashicorp/local... | |
- Finding latest version of hashicorp/null... | |
- Finding latest version of hashicorp/aws... | |
- Installing hashicorp/local v1.4.0... | |
- Installed hashicorp/local v1.4.0 (unauthenticated) | |
- Installing hashicorp/null v2.1.2... | |
- Installed hashicorp/null v2.1.2 (unauthenticated) | |
- Installing hashicorp/aws v2.65.0... | |
- Installed hashicorp/aws v2.65.0 (unauthenticated) | |
The following providers do not have any version constraints in configuration, | |
so the latest version was installed. | |
To prevent automatic upgrades to new major versions that may contain breaking | |
changes, we recommend adding version constraints in a required_providers block | |
in your configuration, with the constraint strings suggested below. | |
* hashicorp/aws: version = "~> 2.65.0" | |
* hashicorp/local: version = "~> 1.4.0" | |
* hashicorp/null: version = "~> 2.1.2" | |
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 apply \ | |
-state="./xxx/terraform.tfstate" \ | |
-input=false \ | |
-var-file="./xxx/terraform.tfvars.json" \ | |
./terraform | |
Error: Could not load plugin | |
Plugin reinitialization required. Please run "terraform init". | |
Plugins are external binaries that Terraform uses to access and manipulate | |
resources. The configuration provided requires plugins which can't be located, | |
don't satisfy the version constraints, or are otherwise incompatible. | |
Terraform automatically discovers provider requirements from your | |
configuration, including providers used in child modules. To see the | |
requirements and constraints, run "terraform providers". | |
2 problems: | |
- Failed to instantiate provider "registry.terraform.io/-/aws" to obtain | |
schema: unknown provider "registry.terraform.io/-/aws" | |
- Failed to instantiate provider "registry.terraform.io/-/local" to obtain | |
schema: unknown provider "registry.terraform.io/-/local" | |
upstream nixpgs rev: 1dc37370c489b610f8b91d7fdd40633163ffbafd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> { } }: | |
pkgs.mkShell { | |
buildInputs = [ | |
pkgs.nixfmt | |
pkgs.shellcheck | |
pkgs.shfmt | |
(pkgs.terraform_0_13.withPlugins | |
(p: [ p.aws p.template p.external p.null p.local ])) | |
]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.terraform/ | |
├── modules | |
│ └── modules.json | |
├── plugin_path | |
└── plugins | |
├── registry.terraform.io | |
│ └── hashicorp | |
│ ├── aws | |
│ │ └── 2.65.0 | |
│ │ └── linux_amd64 -> /nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins/registry.terraform.io/hashicorp/aws/2.65.0/linux_amd64 | |
│ ├── local | |
│ │ └── 1.4.0 | |
│ │ └── linux_amd64 -> /nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins/registry.terraform.io/hashicorp/local/1.4.0/linux_amd64 | |
│ └── null | |
│ └── 2.1.2 | |
│ └── linux_amd64 -> /nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins/registry.terraform.io/hashicorp/null/2.1.2/linux_amd64 | |
└── selections.json | |
13 directories, 3 files | |
$ which terraform | |
/nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/bin/terraform | |
$ cat /nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/bin/terraform | |
#! /nix/store/k8p54jg8ipvnfz435mayf5bnqhw4qqap-bash-4.4-p23/bin/bash -e | |
export NIX_TERRAFORM_PLUGIN_DIR='/nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins' | |
exec "/nix/store/3r5ps634s9n7pcbc35kskjwpkmh3qn1x-terraform-0.13.5/bin/terraform" "$@" | |
$ tree /nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins | |
/nix/store/q4nbkyaasmn8hvsch47bxsmmxkh5afwc-terraform-0.13.5/plugins | |
├── registry.terraform.io | |
│ └── hashicorp | |
│ ├── aws | |
│ │ └── 2.65.0 | |
│ │ └── linux_amd64 | |
│ │ └── terraform-provider-aws_v2.65.0 | |
│ ├── external | |
│ │ └── 1.2.0 | |
│ │ └── linux_amd64 | |
│ │ └── terraform-provider-external_v1.2.0 | |
│ ├── local | |
│ │ └── 1.4.0 | |
│ │ └── linux_amd64 | |
│ │ └── terraform-provider-local_v1.4.0 | |
│ ├── null | |
│ │ └── 2.1.2 | |
│ │ └── linux_amd64 | |
│ │ └── terraform-provider-null_v2.1.2 | |
│ └── template | |
│ └── 2.1.2 | |
│ └── linux_amd64 | |
│ └── terraform-provider-template_v2.1.2 | |
├── terraform-provider-aws_v2.65.0 | |
├── terraform-provider-external_v1.2.0 | |
├── terraform-provider-local_v1.4.0 | |
├── terraform-provider-null_v2.1.2 | |
└── terraform-provider-template_v2.1.2 | |
17 directories, 10 files | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment