Files
dsk-iac/01-old/packer/00_old/build_ami/datasaker-bastion-packer-ubuntu.pkr.hcl
dsk-minchulahn 0273450ff6 Clean Code
2023-12-19 13:03:29 +09:00

55 lines
1.1 KiB
HCL

packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}
variable "ami_prefix" {
type = string
default = "datasaker-bastion-ubuntu2004"
}
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
source "amazon-ebs" "datasaker-bastion-ubuntu2004" {
ami_name = "${var.ami_prefix}-${local.timestamp}"
instance_type = "t3.small"
region = "ap-northeast-2"
source_ami_filter {
filters = {
image-id = "ami-0ea5eb4b05645aa8a"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
tags = {
source_ami_name = "{{ .SourceAMIName }}"
}
ssh_username = "ubuntu"
}
build {
name = "datasaker-bastion-packer"
sources = [
"source.amazon-ebs.datasaker-bastion-ubuntu2004"
]
provisioner "ansible" {
playbook_file = "./datasaker-bastion-ansible-install_apt_packages.yaml"
extra_arguments = [
"--become",
]
ansible_env_vars = [
"ANSIBLE_HOST_KEY_CHECKING=False",
]
}
}