A Packer plugin that enables automated creation of custom VM images on Crusoe Cloud.
- Automated Image Building: Create custom VM images from base Crusoe Cloud images
- Flexible SSH Authentication: Auto-generates temporary SSH keys or uses your existing keys
- Multi-Region Support: Build images across different Crusoe Cloud locations
- HMAC-Based Authentication: Secure API communication using HMAC-SHA256 signatures
- Automatic Cleanup: Temporary resources are cleaned up automatically
# Install published releases with packer init / packer build
packer init image.pkr.hcl
# Build from source
make build
# Install to Packer plugins directory (typically '$HOME/.config/packer/plugins')
make installTagged vX.Y.Z releases are published automatically to GitHub Releases by
GitHub Actions so Packer can download this plugin directly from the repository.
Or use the install script:
./install.shCreate a Packer template file (e.g., image.pkr.hcl):
packer {
required_plugins {
crusoe = {
version = ">= 0.0.1"
source = "github.com/modal-labs/crusoe"
}
}
}
source "crusoe" "ubuntu" {
access_key_id = "${env("CRUSOE_ACCESS_KEY_ID")}"
secret_access_key = "${env("CRUSOE_SECRET_ACCESS_KEY")}"
project_id = "${env("CRUSOE_PROJECT_ID")}"
location = "us-northcentral1-a"
instance_type = "a40.1x"
image_id = "ubuntu22.04:latest"
image_name = "my-custom-image"
image_description = "Ubuntu with custom packages"
ssh_username = "root"
}
build {
sources = ["source.crusoe.ubuntu"]
provisioner "shell" {
inline = [
"apt-get update",
"apt-get install -y nginx vim curl"
]
}
}Build the image:
export CRUSOE_ACCESS_KEY_ID="your-access-key"
export CRUSOE_SECRET_ACCESS_KEY="your-secret-key"
export CRUSOE_PROJECT_ID="your-project-id"
packer build image.pkr.hclaccess_key_id- Crusoe access key ID (env:CRUSOE_ACCESS_KEY_ID)secret_access_key- Crusoe secret access key (env:CRUSOE_SECRET_ACCESS_KEY)project_id- Crusoe project ID (env:CRUSOE_PROJECT_ID)location- Instance location (e.g., "us-northcentral1-a", "eu-iceland1-a")instance_type- VM type (e.g., "a40.1x", "c1a.32x")image_id- Base image ID (e.g., "ubuntu22.04:latest", "ubuntu24.04")
api_endpoint- API endpoint (default: "https://api.crusoecloud.com")image_name- Output image name (default: "packer-{timestamp}")image_description- Output image descriptioninstance_name- Temporary instance name (default: "packer-{timestamp}")disk_size_gib- Root disk size in GiB (default: 50)instance_timeout- Timeout for instance creation and operations (default: "20m")image_timeout- Timeout for image creation (default: "45m")state_timeout- Deprecated: Useinstance_timeoutinsteadssh_key_id- Pre-existing SSH key ID to usessh_private_key_file- Path to SSH private key filessh_username- SSH username (default: "root")
For more information on how to configure the plugin, please read the
documentation located in the docs/ directory.
# Format code
make fmt
# Run tests
make test
# Generate code
make generate
# Clean build artifacts
make clean- SSH Key Setup: Creates temporary SSH key or uses provided key
- Instance Creation: Launches VM instance with specified configuration
- Provisioning: Runs your provisioner scripts (shell, file, etc.)
- Shutdown: Gracefully stops the instance
- Image Creation: Creates custom image from instance disk
- Cleanup: Removes temporary resources (instance, SSH keys)
See the examples/ and build/ directories for more examples:
examples/basic.pkr.hcl- Simple single-region buildexamples/with-ssh-key.pkr.hcl- Multi-region build with custom SSH keys
- Go 1.24.0 or later
- Packer 1.7.0 or later
- Active Crusoe Cloud account with API credentials
This project is maintained by Modal Labs.