From 329d5ba6d5fe5db774721aa4d3d5b0584b25ec30 Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Tue, 10 Jan 2023 11:11:26 -0500 Subject: [PATCH] Remove unnecessary ami_block_device_mappings block One only needs to specify ami_block_mappings_block to add additional volumes when the AMI launches that are not present when the instance on which the AMI is built is launched: https://developer.hashicorp.com/packer/plugins/builders/amazon/ebs#ami-block-device-mappings-example I suppose another use might be if you want the root disk when the AMI is launched to be different than it is when the instance on which the AMI is being built is launched, but that doesn't apply here either. It is certainly the case that there is no need to configure the same root volume in the same way in both the launch_block_device_mappings and ami_block_device_mappings blocks. --- src/packer.pkr.hcl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/packer.pkr.hcl b/src/packer.pkr.hcl index d3727ca..8a64d4e 100644 --- a/src/packer.pkr.hcl +++ b/src/packer.pkr.hcl @@ -60,13 +60,6 @@ data "amazon-ami" "debian_bullseye" { locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } source "amazon-ebs" "example" { - ami_block_device_mappings { - delete_on_termination = true - device_name = "/dev/xvda" - encrypted = true - volume_size = 8 - volume_type = "gp3" - } ami_name = "example-hvm-${local.timestamp}-x86_64-ebs" ami_regions = var.ami_regions associate_public_ip_address = true