title: How to fix "No default VPC for this user, status code: 400" in Terraform?
body: <p>I am trying to fix this piece of code and I would like to create bastion host but I am receiving:
  Error: Error applying plan:</p>
  <p>1 error occurred:
  * aws_instance.bastion: 1 error occurred:
  * aws_instance.bastion: Error launching source instance: VPCIdNotSpecified: No default VPC for this user
  status code: 400, request id: daf3dd12-d7c4-469a-9be5-3707c0490c2a</p>
  <p>I am using Terraform 0.11</p>
  <p>Code:</p>
  <pre><code>resource &quot;aws_vpc&quot; &quot;main&quot; {
      cidr_block       = &quot;${var.main_vpc_cidr}&quot;
      instance_tenancy = &quot;default&quot;
      enable_dns_support = true
      enable_dns_hostnames = true
  
       tags {
           Name = &quot;main&quot;
              }
          }
  
  
   resource &quot;aws_subnet&quot; &quot;subnet1&quot; {
     vpc_id     = &quot;${aws_vpc.main.id}&quot;
     cidr_block = &quot;10.0.1.0/24&quot;
     availability_zone = &quot;${var.availability_zone1}&quot;
  
  
    tags {
      Name = &quot;app-subnet-1&quot;
      }
   }
  
  
  
      ########## Create bastion host ######
  
  ##resource &quot;aws_default_vpc&quot; &quot;default&quot; {}
  
  resource &quot;aws_instance&quot; &quot;bastion&quot; {
  
    ami                         = &quot;ami-0fdc6293d3e87a86e&quot;
    key_name                    = &quot;${aws_key_pair.bastion_key.key_name}&quot;
    instance_type               = &quot;t2.micro&quot;
    security_groups             = [&quot;${aws_security_group.bastion-sg.name}&quot;]
    associate_public_ip_address = true
    
  }
  
  resource &quot;aws_security_group&quot; &quot;bastion-sg&quot; {
    name   = &quot;bastion-security-group&quot;
    vpc_id = &quot;${aws_vpc.main.id}&quot;
  
    ingress {
      protocol    = &quot;tcp&quot;
      from_port   = 22
      to_port     = 22
      cidr_blocks = [&quot;0.0.0.0/0&quot;]
    }
  
    egress {
      protocol    = -1
      from_port   = 0 
      to_port     = 0 
      cidr_blocks = [&quot;0.0.0.0/0&quot;]
    }
  }
  
  resource &quot;aws_key_pair&quot; &quot;bastion_key&quot; {
    key_name   = &quot;your_key_name&quot;
    public_key = &quot;ssh-rsa AAA
  
  output &quot;bastion_public_ip&quot; {
    value = &quot;${aws_instance.bastion.public_ip}&quot;
  }
  </code></pre>
  <p>variables.tf file:</p>
  <pre><code>variable &quot;aws_access_key&quot; {}
  variable &quot;aws_secret_key&quot; {}
  
  variable &quot;aws_region&quot; {
      description = &quot;EC2 Region for the VPC&quot;
      default = &quot;eu-west-1&quot;
  }
  variable &quot;availability_zone1&quot; {
      description = &quot;Avaialbility Zones&quot;
      default = &quot;eu-west-1a&quot;
  }
  
  variable &quot;availability_zone2&quot; {
      description = &quot;Avaialbility Zones&quot;
      default = &quot;eu-west-1b&quot;
  }
  variable &quot;main_vpc_cidr&quot; {
      description = &quot;CIDR of the VPC&quot;
      default = &quot;10.0.0.0/16&quot;
  }
  </code></pre>