Skip to content

Commit

Permalink
Merge pull request #66 from gruntwork-io/packer-tmp-dir
Browse files Browse the repository at this point in the history
Add support for specifying env vars for the Packer build
  • Loading branch information
brikis98 authored Apr 3, 2018
2 parents 2a312b8 + 5515950 commit b5bda25
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packer/packer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,23 @@ import (
)

type PackerOptions struct {
Template string // The path to the Packer template
Template string // The path to the Packer template
Vars map[string]string // The custom vars to pass when running the build command
Only string // If specified, only run the build of this name
Env map[string]string // Custom environment variables to set when running Packer
}

// Build the given Packer template and return the generated AMI ID
func BuildAmi(options PackerOptions, logger *log.Logger) (string, error) {
logger.Printf("Running Packer to generate AMI for template %s", options.Template)

output, err := shell.RunCommandAndGetOutput(shell.Command {Command: "packer", Args: formatPackerArgs(options)}, logger)
cmd := shell.Command {
Command: "packer",
Args: formatPackerArgs(options),
Env: options.Env,
}

output, err := shell.RunCommandAndGetOutput(cmd, logger)
if err != nil {
return "", err
}
Expand Down

0 comments on commit b5bda25

Please sign in to comment.