hashicorp / packer-plugin-amazon

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

Feature request for a skip import option on the post-processor #98

Closed nibty closed 3 years ago

nibty commented 3 years 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

Add a skip_import argument to the Amazon import post-processor to allow for skipping the import on specific builds. "true" means that we should skip the import, "false" means to import as usual.

I have a branch with the feature ready. I'm creating this issue to discuss whether or not the feature is wanted. If so, I can create a pull request. https://github.com/nibty/packer-plugin-amazon/commit/c2343a63a29800f887662afadaa77ae4ca4edeff

Use Case(s)

Sometimes I do not wish to import an image to Amazon. With a skip import feature, I can pass a variable from the command line to the post-processor to control whether or not the image is imported into Amazon.

Potential configuration

post-processor "amazon-import" {
    region = "us-east-1"
    license_type = "BYOL"
    keep_input_artifact = true
    ami_description = "Rocky Linux minimal image"
    ami_name = local.rocky_linux_vm_name
    tags = {
      Name = "Rocky Linux v${var.version}"
    }
    format = "vmdk"
    skip_import = var.skip_amazon_import
  }
}

Potential References

sylviamoss commented 3 years ago

Hey @nibty, thanks for opening the issue. We already have such a feature. If you use packer build --except=amazon-import template.pkr.hcl packer will not run the amazon-import post-processor. See here the docs: https://www.packer.io/docs/templates/hcl_templates/blocks/build/post-processor#run-on-specific-builds

nibty commented 3 years ago

Great! I didn't know you could use --except on post-processors. Thank you.