'terraform init Failed to query available provider packages
i've tf file "tes.tf" with the following contains
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.73"
}
}
}
provider "aws" {
region = "eu-west-1"
}
resource "aws-instance" "myec2" {
ami = "ami-01efa4023f0f3a042"
instance_type = "t2.micro"
tags = {
"Name" = "fahrial-ec2-terraform"
}
}
but when i try to run "terraform init" getting the following error, does anyone know what the cause is?
# terraform init
Initializing the backend...
Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Finding latest version of hashicorp/aws-instance...
- Using previously-installed hashicorp/aws v3.73.0
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aws-instance: provider registry
│ registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/aws-instance
│
│ All modules should specify their required_providers so that external consumers will get the correct providers when using a
│ module. To see which modules are currently depending on hashicorp/aws-instance, run the following command:
│ terraform providers
Solution 1:[1]
There is an error with resource name named aws-instance. It should be aws_instance, with underscore.
You can take a look to registry: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tynchtyk |
