Olá, pessoal!
Estou realizando o processo de modularização e criação de variáveis no Terraform, porém toda que vez realizo o comando terraform init, passa a apresentar o erro abaixo:
Initializing the backend...
Initializing provider plugins...
- Finding hashicorp/aws versions matching "~> 3.76.1"...
- Finding latest version of hashicorp/aw...
- Installing hashicorp/aws v3.76.1...
- Installed hashicorp/aws v3.76.1 (signed by HashiCorp)
╷
│ Error: Failed to query available provider packages
│
│ Could not retrieve the list of available versions for provider hashicorp/aw: provider registry registry.terraform.io does not have a provider named registry.terraform.io/hashicorp/aw
│
│ 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/aw, run the following command:
│ terraform providersSe retirar a modularização e deixar tudo na mesma pasta, funciona normalmente. Revisei o códio para entender de onde veio o provider aw que apresenta no erro, mas não localizei.
Main principal
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.76.1"
}
}
required_version = ">= 1.3.7"
}
provider "aws" {
profile = "default"
region = var.regiao_aws
}
resource "aws_instance" "app_server" {
ami = "ami-095413544ce52437d"
instance_type = var.instancia
key_name = var.chave
tags = {
Name = "Terraform Ansible Python"
}
}
resource "aws_key_pair" "chaveSSH" {
key_name = var.chave
public_key = file("${var.chave}.pub")
}Variáveis
variable regiao_aws {
type = string
}
variable chave {
type = string
}
variable instancia {
type = string
}Main secundária (modularizada)
module "aws-dev" {
source = "../../infra"
instancia = "t2.micro"
regiao_aws = "us-west-2"
chave = "IaC-DEV"
}