Hello Team,
Is it possible to add single source in the Packer HCL2 and using multiple Build Block can i export images to other clouds also.
For Example -
I have one image stored in Azure compute gallery for Jboss, need to export this Jboss image to AWS and GCP too.
Is this possible using packer or
Do i have store natively once store the image and keep spinning up VM’s every time i need to patch VM’s or create any artifact for native cloud.
The typical workflow I adopt here is to have cloud-specific build
and post-processor
blocks, but a single provisioner
block. I.e. it can be thought of as:
- Choose the base image of your liking from the clouds you want to support (GCP, AWS, Docker, etc and define the relevant filters for finding them.
- Create a provisioning model (I typically use the Ansible provisioner, so that I can maintain a single configuration management system for arbitrary clouds).
- Add cloud-specific post-processors for tagging, pushing images, etc. This is mostly necessary for those images which are built locally, e.g. container images which need to be pushed to a registry.
To answer your specific example:
I would avoid having a flow whereby I build an image in one cloud, then export it and push it to another cloud… that seems like an unnecessarily long pipeline.
Instead, maintain base images in the clouds you want to use, and build off of them:
source "googlecompute" "basic-example" {
source_image = ""
...
}
source "amazon-ebs" "basic-example" {
source_ami_filter {
...
}
...
}
build {
sources = [
"source.googlecompute.basic-example",
"source.amazon-ebs.basic-example"
]
# add whatever provisioners are desired...
provisioner "ansible" {
...
}
}