ignore building images that already exists

629 views
Skip to first unread message

Khai Do

unread,
Aug 21, 2019, 5:39:15 PM8/21/19
to Packer
We are using packer with the amazon-ebs builder.  The packer build command throws an error when attempting to build an AMI with a name that matches an existing AMI on AWS.  I would like to make packer provide the same info but NOT fail for this use case?  Instead I would like it to just ignore and continue to the next image build.  Is there a way to tell packer to ignore builds where an AMI already exists?  something like an '-skip-already-exist' flag? 

➜ packer --version
1.4.3
➜  packer build -var-file=../vars.json template.json
amazon-ebs output will be in this color.

==> amazon-ebs: Prevalidating AMI Name: weechat-v1.0.0
==> amazon-ebs: Error: AMI Name: 'weechat-v1.0.0' is used by an existing AMI: ami-0ee682a1a7e3717d0
Build 'amazon-ebs' errored: Error: AMI Name: 'weechat-v1.0.0' is used by an existing AMI: ami-0ee682a1a7e3717d0

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Error: AMI Name: 'weechat-v1.0.0' is used by an existing AMI: ami-0ee682a1a7e3717d0

==> Builds finished but no artifacts were created.
➜   echo $?
1


Rickard von Essen

unread,
Aug 22, 2019, 12:18:57 AM8/22/19
to packe...@googlegroups.com
No you can't do that. As a workaround you can use the aws cli to check if the AMI exists, if so run packer build with -exclude=amazon-ebs 

--
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 packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/50f8f68f-aca8-43a0-9e20-7e050475a6d3%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages