#packer (2021-10)

packer

Discuss Packer for building AMIs and Docker Images Archive: https://archive.sweetops.com/packer/

2021-10-21

Saichovsky avatar
Saichovsky

Hey guys,

Need some packer help

Saichovsky avatar
Saichovsky
  provisioner "shell" {
    environment_vars = [
      "AWS_SESSION_TOKEN={{user `AWS_SESSION_TOKEN`}}",
      "AWS_ACCESS_KEY_ID={{user `AWS_ACCESS_KEY_ID`}}",
      "AWS_SECRET_ACCESS_KEY={{user `AWS_SECRET_ACCESS_KEY`}}",
      "AWS_SECURITY_TOKEN={{user `AWS_SECURITY_TOKEN`}}"
    ]
    script = "test_script.sh"
  }
Saichovsky avatar
Saichovsky

Why won’t this work? I need to pass environment variables from my laptop’s CLI to the provisioner, so that they can be printed out by the test_script.sh script

Saichovsky avatar
Saichovsky

But I’m getting this error message instead:

Error: Failed preparing provisioner-block "shell" ""

  on jenkins-slave-ami.pkr.hcl line 87:
  (source code not available)

render 'environment_vars': template: root:1:20: executing "root" at <user
`AWS_SESSION_TOKEN`>: error calling user: test in:

AWS_SESSION_TOKEN={{user `AWS_SESSION_TOKEN`}}
    keyboard_arrow_up