From the course: Learning HashiCorp Packer

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using build variables

Using build variables - Packer Tutorial

From the course: Learning HashiCorp Packer

Start my 1-month free trial

Using build variables

- [Instructor] The build command takes in extra flags, one of which is the var flag, or variable flag. The var flag allows for variables to be passed in when running a build. An example of variables would be an AWS key and secret, something you don't want to hard code into a template, but use it when building. So far, we've been using the AWS key and secret configured for use with the AWS CLI. This is not going to be present on every machine you run Packer. If you run Packer on a CI server it's unlikely that the AWS CLI will be installed, and so far we've been using the AWS key and secret, configured for use with the AWS CLI. This is not going to be present on every machine. If you run your packer build on a CI server, it's unlikely the AWS CLI will be installed and configured. Instead we can input these secrets as variables when building the template. So let's set the AWS access key variable into this template. Variables are at the same level as builders, so if we put it at the top…

Contents