Resolve Error (AWS Free Tier and Terraform): Error launching source instance: VPCIdNotSpecified: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.

When you use Amazon Free Tier period and want to run free EC2 instance and when you get error:

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

You need to create Security Group resource (example for port 80 for http server):

resource "aws_security_group" "allow_http" {
  name        = "allow_http"

  ingress {
    from_port        = 80
    to_port          = 80
    protocol         = "tcp"
    cidr_blocks      = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }

  egress {
    from_port        = 0
    to_port          = 0
    protocol         = "-1"
    cidr_blocks      = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }
}

Mount VirtualBox vdi image (debian, ubuntu)

You can use qemu package.

apt-get install qemu

After you can check and load network block device kernel-module:

rmmod nbd
modprobe nbd max_part=8

Then you connect image:

qemu-nbd -c /dev/nbd0 image.vdi

And mount (don’t forget create mount directory /media/image):

mount /dev/nbd0p1 /media/image

And unmount:

qemu-nbd -d /dev/nbd0