Olá pessoal,
Ontem quando estava fazendo o curso, tentei executar o código dos vídeos e me deparei com o erro abaixo.
Minha dúvida é a seguinte: o instrutor fez alguma configuração prévia de VPC padrão na AWS para isso funcionar?
Detalhes:
Versões:
Terraform v0.15.4
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v2.70.0
aws-cli/2.2.5 Python/3.8.8 Linux/5.4.0-73-generic exe/x86_64.ubuntu.20 prompt/off
Código:
provider "aws" {
version = "~> 2.0"
region = "us-east-1"
}
resource "aws_instance" "dev" {
count = 2
ami = "ami-0747bdcabd34c712a"
instance_type = "t2.micro"
key_name = "terraform-aws"
tags = {
Name = "dev${count.index}"
}
}
Erro:
│ Error: Error launching source instance: VPCResourceNotSpecified: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.
│ status code: 400, request id: d7467f37-b91d-4af3-b116-ae34fc8eeb39
│
│ with aws_instance.dev[1],
│ on main.tf line 6, in resource "aws_instance" "dev":
│ 6: resource "aws_instance" "dev" {
│
╵
╷
│ Error: Error launching source instance: VPCResourceNotSpecified: The specified instance type can only be used in a VPC. A subnet ID or network interface ID is required to carry out the request.
│ status code: 400, request id: 542a581e-e571-43f9-99ec-96c86715c8cf
│
│ with aws_instance.dev[0],
│ on main.tf line 6, in resource "aws_instance" "dev":
│ 6: resource "aws_instance" "dev" {