Packer: Can packer user variables be lists or only strings

Created on 10 May 2017  路  1Comment  路  Source: hashicorp/packer

I'm trying to pass ami_regions list as an user variables and I'm unsuccessfully. There was a bug for this https://github.com/hashicorp/packer/issues/950 opened before. Could this be regression or am I doing something wrong ?

Packer version: 1.0.0
User variable in the ami.json file: "ami_regions": [ "{{ user aws_regions }}" ],

Debug output:
`packer build -debug -var 'ami_regions=us-east-1,us-west-2' ami.json
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.

1 error(s) occurred:

  • Unknown region: `
question

Most helpful comment

try "ami_regions": "{{ user aws_regions }}"

this worked for me

{
 "variables": {
        "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
        "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
        "region":         "{{env `AWS_DEFAULT_REGION`}}",
        "matt_regions":         "us-west-1,us-west-2"
    },
    "builders": [
        {
            "access_key": "{{user `aws_access_key`}}",
            "ami_name": "packer-qs-{{timestamp}}",
            "instance_type": "t2.micro",
            "region": "us-east-1",
            "ami_regions": "{{user `matt_regions`}}",
            "secret_key": "{{user `aws_secret_key`}}",
            "source_ami": "ami-fce3c696",
            "ssh_username": "ubuntu",
            "type": "amazon-ebs"
        }
    ]
}

>All comments

try "ami_regions": "{{ user aws_regions }}"

this worked for me

{
 "variables": {
        "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
        "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
        "region":         "{{env `AWS_DEFAULT_REGION`}}",
        "matt_regions":         "us-west-1,us-west-2"
    },
    "builders": [
        {
            "access_key": "{{user `aws_access_key`}}",
            "ami_name": "packer-qs-{{timestamp}}",
            "instance_type": "t2.micro",
            "region": "us-east-1",
            "ami_regions": "{{user `matt_regions`}}",
            "secret_key": "{{user `aws_secret_key`}}",
            "source_ami": "ami-fce3c696",
            "ssh_username": "ubuntu",
            "type": "amazon-ebs"
        }
    ]
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nikoos picture Nikoos  路  3Comments

znerd picture znerd  路  3Comments

sourav82 picture sourav82  路  3Comments

wduncanfraser picture wduncanfraser  路  3Comments

brettswift picture brettswift  路  3Comments