2024-11-16 03:30:04 +00:00
|
|
|
packer {
|
|
|
|
required_plugins {
|
|
|
|
amazon = {
|
|
|
|
version = ">= 1.2.8"
|
|
|
|
source = "github.com/hashicorp/amazon"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "ami_prefix" {
|
|
|
|
type = string
|
|
|
|
default = "homelab-aws"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
locals {
|
|
|
|
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
source "amazon-ebs" "debian" {
|
|
|
|
ami_name = "${var.ami_prefix}-debian-${local.timestamp}"
|
|
|
|
instance_type = "t2.medium"
|
|
|
|
region = "us-east-1"
|
|
|
|
source_ami_filter {
|
|
|
|
filters = {
|
2024-11-17 03:26:04 +00:00
|
|
|
image-id = "ami-064519b8c76274859"
|
2024-11-16 03:30:04 +00:00
|
|
|
root-device-type = "ebs"
|
|
|
|
virtualization-type = "hvm"
|
|
|
|
|
|
|
|
}
|
|
|
|
most_recent = true
|
|
|
|
owners = ["136693071363"]
|
|
|
|
|
|
|
|
}
|
|
|
|
ssh_username = "admin"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
name = "AMIs for homelab use"
|
|
|
|
sources = [
|
|
|
|
"source.amazon-ebs.debian",
|
|
|
|
]
|
|
|
|
|
|
|
|
provisioner "shell" {
|
|
|
|
script = "scripts/initial.sh"
|
|
|
|
}
|
|
|
|
|
|
|
|
provisioner "file" {
|
|
|
|
source = "files/id_rsa.pub"
|
2024-11-17 03:26:04 +00:00
|
|
|
destination = "/home/admin/"
|
2024-11-16 03:30:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|