From b3895c6af1f1d57d5fb2fd895f9950b55246a157 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Mon, 13 Feb 2023 17:48:19 -0800 Subject: packer: add packer ubuntu template --- packer/ubuntu.pkr.hcl | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 packer/ubuntu.pkr.hcl (limited to 'packer/ubuntu.pkr.hcl') diff --git a/packer/ubuntu.pkr.hcl b/packer/ubuntu.pkr.hcl new file mode 100644 index 0000000..e7d4f37 --- /dev/null +++ b/packer/ubuntu.pkr.hcl @@ -0,0 +1,72 @@ +packer { + required_plugins { + amazon = { + version = ">= 1.0.1" + source = "github.com/hashicorp/amazon" + } + } +} + +variable "version" { + type = string + default = "1.0.0" +} + +data "amazon-ami" "ubuntu-focal-east" { + region = "us-east-2" + filters = { + name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" + } + most_recent = true + owners = ["099720109477"] +} + +source "amazon-ebs" "basic-example-east" { + region = "us-east-2" + source_ami = data.amazon-ami.ubuntu-focal-east.id + instance_type = "t2.small" + ssh_username = "ubuntu" + ssh_agent_auth = false + ami_name = "packer_AWS_{{timestamp}}_v${var.version}" +} + +data "amazon-ami" "ubuntu-focal-west" { + region = "us-west-1" + filters = { + name = "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*" + } + most_recent = true + owners = ["099720109477"] +} + +source "amazon-ebs" "basic-example-west" { + region = "us-west-1" + source_ami = data.amazon-ami.ubuntu-focal-west.id + instance_type = "t2.small" + ssh_username = "ubuntu" + ssh_agent_auth = false + ami_name = "packer_AWS_{{timestamp}}_v${var.version}" +} + +build { + hcp_packer_registry { + bucket_name = "learn-packer-ubuntu" + description = <