Drop the outer { and "variables":.
See https://packer.io/docs/templates/user-variables.html#from-a-file
On Sat, Jun 8, 2019, 22:59 Arun kumar <[email protected]> wrote:
> Hi All,
>
> I have been using packer for ami builds recently. when I used the
> variables inside the template, template works fine but when I provide the
> variables using -var-file=variables.json, it throws me below mentioned
> error.
>
> *"Error reading variables in 'vars.json': json: cannot unmarshal object
> into Go value of type string"*
>
> I looked for a thread to find out the solution, but haven't had luck
> finding it. Most of the threads are incomplete...
> Can someone please shed some light why is this happening. Below is my
> variables file.
>
> {
> "variables":
> {
> "aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
> "aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
> "aws_session_token" : "{{env `AWS_SESSION_TOKEN`}}",
> "region": "us-east-1",
> "iam_role": "packer-role",
> "vpc_id": "vpc-xxxxxxx",
> "subnet_id": "subnet-xxxxxxxx",
> "security_group_id": "sg-xxxxxxxxx",
> "created_ami_name": "xxxxxxxx-{{env `date +%Y-%m-%d`}}",
> "kms_key_id": "ami-kms-key",
> "instance_type": "t2.micro",
> "Environment": "dev",
> "source_ami_name": "testami",
> "ssh_username": "ubuntu",
> "script": "setup.sh",
> "owners": ["987654321"]
> }
> }
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/packer/issues
> IRC: #packer-tool on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Packer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/packer-tool/aee190fd-259e-40ad-a937-ffd25a641429%40googlegroups.com
> <https://groups.google.com/d/msgid/packer-tool/aee190fd-259e-40ad-a937-ffd25a641429%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/packer-tool/CALz9Rt9ukbAAF7A2%3DSrRzGdD7fk72ogimTB8JPkyd4gW8C-kwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.