hashicorp / packer-plugin-amazon

Packer plugin for Amazon AMI Builder
https://www.packer.io/docs/builders/amazon
Mozilla Public License 2.0
75 stars 112 forks source link

Post-processors are not able to run when skip_create_ami is set #513

Open andyshinn opened 1 month ago

andyshinn commented 1 month ago

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request. If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Post-processors are not run when skip_create_ami is true.

Use Case(s)

I am trying to run some EC2 instances to build and download an artifact and then add it to the manifest with the artifice and manifest post-processors. But they don't appear to work when I don't want to keep the AMI with skip_create_ami.

Potential configuration

source "amazon-ebs" "ubuntu-jammy-arm64" {
  ami_name                                  = "package-${source.name}-ruby"
  ssh_username                              = "ubuntu"
  instance_type                             = "m6g.xlarge"
  source_ami                                = data.amazon-ami.ubuntu-jammy-arm64.id
  skip_create_ami                           = true
  force_run_post_processors                 = true
}

Potential References

lbajolet-hashicorp commented 2 weeks ago

Hi @andyshinn,

I'm not sure what you're trying to do exactly, but from Packer's perspective, a build that doesn't create an AMI does not expose artifacts, so besides post-processors like shell-local, you probably won't be able to run any since there's no artifact to process.

I'm veering towards not classifying this as a bug/enhancement, since it looks fundamentally incompatible with what Packer aims to do, but please feel free to push back on that, there might be a valid use-case that I'm missing here.

Thanks!

andyshinn commented 2 weeks ago

Specifically, I am trying to use the artifice post-processor. According to the first couple sentences of the post-processor it seems perfectly normal to want to do something like this: https://developer.hashicorp.com/packer/docs/post-processors/artifice