2
respostas

[Bug] Error: Error launching source instance: VPCIdNotSpecified: No default VPC for this user.

│ Error: Error launching source instance: VPCIdNotSpecified: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC. │ status code: 400,

with aws_instance.dev[0], │ on main.tf line 14, in resource "aws_instance" "dev": │ 14: resource "aws_instance" "dev"{

2 respostas

Oi, Daniel. Tudo bem?

Poderia postar aqui o seu código para que a gente possa tentar entender melhor o problema?

Daniel tenta usar assim usar em ohio ou adaptar para região de preferencia

terraform init

terraform plan

module "vpc" { source = "terraform-aws-modules/vpc/aws"

name = "vpc-terraform"

cidr = var.vpc_cidr_block

# ohio

azs = ["us-east-2a", "us-east-2b"]

private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]

public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]

Colocar false pelo motivo de cobrança da aws

enable_nat_gateway = false

}

module "ec2_instance" { source = "terraform-aws-modules/ec2-instance/aws" version = "~> 3.0"

# debian 11

count = 1

name = "terraform"

ami = "ami-06a7641d5bd7bdc65"

instance_type = "t2.micro"

subnet_id = module.vpc.public_subnets[0]

vpc_security_group_ids = [aws_security_group.sg_443.id, aws_security_group.sg_port_80.id, aws_security_group.sg_ssh.id]

associate_public_ip_address = true

key_name = "par_ohio_linux" # posso usar uma chave que já existe na AWS

}