Packer: Feature: auto-load var files

Created on 18 Jun 2019  ·  4Comments  ·  Source: hashicorp/packer

There is a really nice feature in terrafom where it will automatically load terraform.tfvars and any *.auto.tfvars files without you having to specify -var-file=foo.tfvars on the command line.

My feature request is for a similar feature in packer, so for example I could create a file containing a var definition with a list of AWS account ids and regions:

sharing.auto.json

{
      "destination_regions": "us-east-1,eu-west-1",
      "destination_accounts": "12345678,23456789",
}

which I could pick up from any of the packer json files in the same directory:

ami_one.json

{
  "builders": [
    {
      "type": "amazon-ebs",
      "ami_regions": "{{user `destination_regions` }}",
      "ami_users": "{{user `destination_accounts` }}",
      "....": "...."
    }
  ],
  "variables": {
    "destination_regions": "us-west-1,us-west-2",
    "destination_accounts": ""
  }
}

so I could run packer build ami_one.json without having to specify any var files on the command line.

config-2.0 core enhancement

Most helpful comment

Hello there, this can now be closed as it works with Packer 🎉 ! Doc is here: https://www.packer.io/docs/from-1.5/variables

All 4 comments

Good idea! I'm not sure when we'll be able to prioritize this but I would love to implement it.

Hello there, this can now be closed as it works with Packer 🎉 ! Doc is here: https://www.packer.io/docs/from-1.5/variables

Thanks very much! 🎉

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