Skip to content

Instantly share code, notes, and snippets.

@pkolyvas
Created January 29, 2020 22:48
Show Gist options
  • Save pkolyvas/5514e7f46a812e3da8dea34b2f395048 to your computer and use it in GitHub Desktop.
Save pkolyvas/5514e7f46a812e3da8dea34b2f395048 to your computer and use it in GitHub Desktop.
# folder/sources.pkr.hcl
source "amazon-ebs" "example" {
ami_name = "packer-partyparrot-{{timestamp}}"
region = "us-east-1"
instance_type = "t2.micro"
source_ami_filter {
filters {
virtualization-type = "hvm"
name = "ubuntu/images/*ubuntu-xenial-16.04-amd64-server-*"
root-device-type = "ebs"
}
owners = ["amazon"]
most_recent = true
}
communicator = "ssh"
ssh_username = "ubuntu"
}
# folder/build.pkr.hcl
// A build starts sources and runs provisioning steps on those sources.
build {
sources = [
// there can be multiple sources per build
"source.amazon-ebs.example"
]
// All provisioners and post-processors have a 1:1 correspondence to their
// current layout. The argument name (ie: inline) must to be unquoted
// and can be set using the equal sign operator (=).
provisioner "shell" {
inline = ["sleep 5"]
}
provisioner "shell-local" {
inline = ["echo the address is: $PACKER_HTTP_ADDR and build name is: $PACKER_BUILD_NAME"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment