API not found. ex: https://registry.terraform.io/v1/providers/-/aws-vpc/versions

Good Morning,

A few months ago, I started studying terraform, installed it, performed tests, left a code ready, used terraforming to transform the current infra into code, updated this terraforming to the most current version of terraform, everything happened as expected, without errors.

However, now I’m back to playing with terraform to create the new company infrastructure, and terraform simply accuses that the aws provider is not available for installation, detail, I’m using the most current version, and the same AMI I used when I used it terraform for the first time.

It is interesting, that even when I do a terraform --version with TF_LOG = trace enabled, flaws are pointed out, it seems that files are missing, as shown below:
root@ip-172-31-1-4:/home/ubuntu/bitbucket/infra-test/terraform-cm# terraform --version
2020/02/21 14:08:40 [INFO] Terraform version: 0.12.21
2020/02/21 14:08:40 [INFO] Go runtime version: go1.12.13
2020/02/21 14:08:40 [INFO] CLI args: string{"/usr/local/bin/terraform", “–version”}
2020/02/21 14:08:40 [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2020/02/21 14:08:40 [DEBUG] File doesn’t exist, but doesn’t need to. Ignoring.
2020/02/21 14:08:40 [INFO] CLI command args: string{“version”, “–version”}
Terraform v0.12.21
2020/02/21 14:08:40 [DEBUG] checking for provider in “.”
2020/02/21 14:08:40 [DEBUG] checking for provider in “/usr/local/bin”
2020/02/21 14:08:40 [DEBUG] checking for provider in “.terraform/plugins/linux_amd64”
2020/02/21 14:08:40 [DEBUG] found provider “terraform-provider-aws_v2.49.0_x4”
2020/02/21 14:08:40 [DEBUG] found valid plugin: “aws”, “2.49.0”, “/home/ubuntu/bitbucket/infra-test/terraform-cm/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.49.0_x4”
2020/02/21 14:08:40 [INFO] Failed to read plugin lock file .terraform/plugins/linux_amd64/lock.json: open .terraform/plugins/linux_amd64/lock.json: no such file or directory

And the error reported when terraform tries to get the provider after giving terraform init:

2020/02/21 14:01:30 [DEBUG] plugin requirements: “aws”="~> 2.0"
2020/02/21 14:01:30 [DEBUG] plugin requirements: “aws-vpc”=""
2020/02/21 14:01:30 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
2020/02/21 14:01:30 [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
2020/02/21 14:01:30 [DEBUG] fetching provider versions from “https://registry.terraform.io/v1/providers/-/aws-vpc/versions
2020/02/21 14:01:30 [TRACE] HTTP client GET request to https://registry.terraform.io/v1/providers/-/aws-vpc/versions
2020/02/21 14:01:30 [DEBUG] provider &{registry.terraform.io - aws-vpc linux amd64} not found

Thank you very much in advance, and if any information is missing, let me know.

Hi @AngeloDamasio,

It looks like your configuration is causing Terraform to believe it needs a provider called aws-vpc, rather than one just called aws.

My guess would be that somewhere in your configuration there is a typo like this:

resource "aws-vpc" "example" {
  # ...
}

Notice that it says aws-vpc with a dash, rather than aws_vpc with an underscore. If you correct that to say aws_vpc, Terraform should understand it as belonging to the aws provider and be able to install it as expected.

If you have multiple modules in your configuration and you’re not sure which one has the typo, you could run the command terraform providers to see the provider dependencies on a per-module basis, and thus see which of the modules seems to have the incorrect dependency on a provider named aws-vpc.

1 Like

omg, stupid mistake, thanks for the help, your example pointed out exactly where I was going wrong.