Packer: Build 'amazon-ebs' errored: Error launching source instance: No default VPC for this user (VPCIdNotSpecified)

Created on 26 Mar 2015  ยท  8Comments  ยท  Source: hashicorp/packer

Using Packer v0.7.5.

I'm trying to create an image in a specific AWS VPC. Looks like packer is not using that, but trying to use the default VPC (which I don't have). Packer is connecting to my account, I see the security group getting created.

Is this a packer or PEBKAC bug?

I have a config like this:
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user aws_access_key}}",
"secret_key": "{{user aws_secret_key}}",
"region": "us-west-2",
"source_ami": "ami-e192xxxx",
"instance_type": "t2.micro",
"ssh_username": "centos",
"ami_name": "test-{{timestamp}}",
"vpc_id": "vpc-29xxxxxx"
}]

The VPC exists.

==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
==> amazon-ebs: Creating temporary keypair: packer 5513479b-f5c6-032e-bca1-977a58fcb6e5
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Creating temporary security group for this instance...
==> amazon-ebs: Authorizing SSH access on the temporary security group...
==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Error launching source instance: No default VPC for this user (VPCIdNotSpecified)
==> amazon-ebs: Pausing before cleanup of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Pausing before cleanup of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Deleting temporary keypair...
==> amazon-ebs: Pausing before cleanup of step 'StepSourceAMIInfo'. Press enter to continue.
Build 'amazon-ebs' errored: Error launching source instance: No default VPC for this user (VPCIdNotSpecified)

Most helpful comment

Solution: you have to specify a subnet id as well. Maybe add this to documentation?

All 8 comments

Solution: you have to specify a subnet id as well. Maybe add this to documentation?

Just for those Googling around; this will happen if you've deleted your default VPC as well.

Not necessarily. If you define your subnet and vpc id (even with filters), it works without default VPC (I deleted mine a while ago). This works for me:

  "builders": [
    {
      "type": "amazon-ebs",
      "region": "eu-west-2",
      "source_ami": "{{user `amzn_linux2_ami`}}",
      "instance_type": "t2.medium",
      "ssh_username": "ec2-user",
      "ami_name": "<edited>,
      "ami_users": ["<edited>","<edited>"],
      "vpc_filter": {
        "filters": {
          "tag:Name": "My App VPC",
          "isDefault": "false"
        }
      },
      "subnet_filter": {
        "filters": {
          "tag:Network Type": "Public"
        },
        "random": true
      }
    }
  ],

@ophintor i tried using vpc_filter and got this:

amazon-ebs output will be in this color.

1 error(s) occurred:

* unknown configuration key: "vpc_filter"

My solution was just to make sure I have a default VPC, that solved it for me.

@Binternet then you have a really old version of Packer, consider upgrading.

@ophintor Thank you man! Worked like a charm.

Hi, sorry does not work at all ... don't know why:

```=> amazon-ebs: Prevalidating AMI Name: xxxxx
==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue.
amazon-ebs: Found Image ID: ami-00aa4671cbf840d82
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue.
amazon-ebs: Found VPC ID: vpc-abcdef
==> amazon-ebs: Pausing after run of step 'StepNetworkInfo'. Press enter to continue.
==> amazon-ebs: Creating temporary keypair: packer_abcdef
amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue.
==> amazon-ebs: Creating temporary security group for this instance: packer_abcdef
==> amazon-ebs: Authorizing access to port 22 from [1.2.3.4/5] in the temporary security groups...
==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue.
==> amazon-ebs: Pausing after run of step 'StepCleanupVolumes'. Press enter to continue.
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
amazon-ebs: Adding tag: "Name": "Packer Builder"
==> amazon-ebs: Error launching source instance: VPCIdNotSpecified: No default VPC for this user
==> amazon-ebs: status code: 400, request id: abcdefg

Ok, turned out my subnet_filter was wrong

"subnet_filter": {
"most_free": true,
"random": false
},

this is not working, but

"subnet_filter": {
"filters": {
"state": "available"
},
"most_free": true,
"random": true
},
```
is

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tensho picture Tensho  ยท  3Comments

brettswift picture brettswift  ยท  3Comments

craigsimon picture craigsimon  ยท  3Comments

DanielBo picture DanielBo  ยท  3Comments

PartyImp picture PartyImp  ยท  3Comments