hashicorp / hashicorp/packer-plugin-amazon
amazon-ebs: Terminate spot instance before copying / tagging AMI
- Dominant language
- Go
- Stars
- 91
- Forks
- 141
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 3
Description
_This issue was originally opened by @nilsmeyer as hashicorp/packer#7932. It was migrated here as a result of the [Packer plugin split](https://github.com/hashicorp/packer/issues/8610#issuecomment-770034737). The original body of the issue is below._
Currently, when using spot instances, the amazon-ebs builder will keep the instance running almost through the end of the build process, e.g:
```
[lot's of provisioner output]
==> amazon-ebs: Creating unencrypted AMI example from instance i-00000000000000000
amazon-ebs: AMI: ami-00000000000000000
==> amazon-ebs: Waiting for AMI to become ready...
==> amazon-ebs: Copying AMI (ami-00000000000000000) to other regions...
amazon-ebs: Copying to: eu-central-1
amazon-ebs: Waiting for all copies to complete...
==> amazon-ebs: Modifying attributes on AMI (ami-00000000000000000)...
amazon-ebs: Modifying: groups
amazon-ebs: Modifying: users
==> amazon-ebs: Modifying attributes on AMI (ami-00000000000000001)...
amazon-ebs: Modifying: groups
amazon-ebs: Modifying: users
==> amazon-ebs: Modifying attributes on snapshot (snap-00000000000000000)...
==> amazon-ebs: Modifying attributes on snapshot (snap-00000000000000001)...
==> amazon-ebs: Adding tags to AMI (ami-00000000000000000)...
==> amazon-ebs: Tagging snapshot: snap-00000000000000000
==> amazon-ebs: Creating AMI tags
amazon-ebs: Adding tag: [..]
==> amazon-ebs: Creating snapshot tags
==> amazon-ebs: Adding tags to AMI (ami-00000000000000001)...
==> amazon-ebs: Tagging snapshot: snap-00000000000000001
==> amazon-ebs: Creating AMI tags
amazon-ebs: Adding tag: [..]
==> amazon-ebs: Creating snapshot tags
==> amazon-ebs: Cancelling the spot request...
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
```
Especially the step of copying the AMI to other regions can take quite a bit of time. I think it makes sense to terminate the instance before this step for cost reduction.
Contributor guide
Assessment
This issue has not been assessed yet.