Hi, I am new to Terraform and I am trying to deploy an EC2 to an existing VPC which is not the default VPC.
I have copied the codes from the URL below, but I am getting an error "creating EC2 Instance: VPCIDNotSpecified: No default VPC for this user. After I add “vpc_id” in the codes, I received another error “Error: Unsupported argument. An argument named “vpc_id” is not expected here.”
resource “aws_instance” “web” {
vpc_id = “vpc-0b89dffeadebdf035”
ami = “ami-003c463c8207b4dfa”
instance_type = “t2.micro”
tags = {
Name = “HelloWorld”
}
}
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance