AWS new VM (Private IP)

19 views
Skip to first unread message

Renato Marcandier

unread,
Jul 27, 2020, 9:05:48 AM7/27/20
to Packer

Hello guys,

I am trying to run this conf.sh script against my new AWS VM from my mac laptop.
When the VM is up and running I am using this AWS command to grab the IP, however, from inside packer, I am not able to grab it, only from my shell terminal.
Can you see the problem?

If is there any better way to achieve it just let me know.



Packer.json


Conf.sh:



Error:

==> amazon-ebs: Pausing at breakpoint provisioner with note "this is a breakpoint 1".
==> amazon-ebs: Press enter to continue. 
==> amazon-ebs: Running local shell script: /var/folders/9q/pzl_rvls7svbpv86bfcydrsc0000gn/T/packer-shell332274264
    amazon-ebs: i-086b22975ad9648ed
==> amazon-ebs: Pausing at breakpoint provisioner with note "this is a breakpoint 2".
==> amazon-ebs: Press enter to continue. 
==> amazon-ebs: Running local shell script: /var/folders/9q/pzl_rvls7svbpv86bfcydrsc0000gn/T/packer-shell839414416
    amazon-ebs:
==> amazon-ebs: Pausing at breakpoint provisioner with note "this is a breakpoint 3".
==> amazon-ebs: Press enter to continue. 
==> amazon-ebs: Running local shell script: ./conf.sh
==> amazon-ebs:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
==> amazon-ebs:                                  Dload  Upload   Total   Spent    Left  Speed
==> amazon-ebs:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: $AWS_INSTANCE_IP
==> amazon-ebs:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
==> amazon-ebs:                                  Dload  Upload   Total   Spent    Left  Speed
==> amazon-ebs:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: $AWS_INSTANCE_IP
==> amazon-ebs: Provisioning step had errors: Running the cleanup provisioner, if present...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: No volumes to clean up, skipping
Build 'amazon-ebs' errored: Script exited with non-zero exit status: 6.Allowed exit codes are: [0]

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Script exited with non-zero exit status: 6.Allowed exit codes are: [0]

==> Builds finished but no artifacts were created.
❯ AWS (master) ✘ 

Regards
RG

Rickard von Essen

unread,
Jul 27, 2020, 10:50:17 AM7/27/20
to packe...@googlegroups.com
I would handle it like this.

1) run shell (not local) curl the metadata service and save it to a file, say /tmp/ipaddress 

2) use file provisioner download to fet it to your machine. 

3) in a shell-local script read the IP into a variable. 

--
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/hashicorp/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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/7f4e253d-2928-43f9-a2ef-a3a39420273co%40googlegroups.com.

Megan Marsh

unread,
Jul 27, 2020, 4:48:04 PM7/27/20
to packe...@googlegroups.com
On recent versions of packer, you can use the "build" template engine to get the IP: you'd set the env var like

"environment_vars": ["AWS_INSTANCE_IP={{ build `Host`}}"]

Reply all
Reply to author
Forward
0 new messages