I’m using this packer configuration, very similar to the documentation for amazon-ebsvolume
:
source "amazon-ebsvolume" "data_volume" {
region = "us-east-2"
source_ami = "ami-0eb070c40e6a142a3"
instance_type = "t2.micro"
ssh_username = "ec2-user"
ebs_volumes {
volume_type = "gp3"
volume_size = 20
device_name = "/dev/xvdf"
delete_on_termination = false
tag {
key = "Name"
value = "APIDataVolume"
}
}
}
build {
sources = ["source.amazon-ebsvolume.data_volume"]
provisioner "shell" {
inline = [
"sudo mkfs.ext4 /dev/xvdf",
"sudo mkdir /mnt/data",
"sudo mount /dev/xvdf /mnt/data",
# Don't think we need this
# "echo '/dev/xvdf /mnt/data ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab",
"sudo umount /mnt/data"
]
}
}
However this doesn’t put a name on the volume it creates. I can’t use tags, like the docs say:
ebs_volumes {
volume_type = "gp3"
volume_size = 20
device_name = "/dev/xvdf"
delete_on_termination = false
tags {
Name = "APIDataVolume"
}
}
Causes Blocks of type "tag" are not expected here.
I want to use Packer to create a volume that will be reused for persistent data through multiple ec2 instance lifecycles. Am I going about this the wrong way?