在加壳器中构建 AMI,包括使用加壳器修改快照

Build AMI in packer including modified snapshot with packer

我想构建一个具有两个块设备的 AMI,这两个块设备在供应期间被修改。当我使用加壳器创建 AMI 时,它似乎没有拍摄块设备的新快照。有没有办法强制执行此操作?

我的模板是 { "builders": [{ "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-08842d60", "instance_type": "m4.2xlarge", "security_group_id": "<redacted>", "subnet_id" : "<redacted>", "ssh_username": "ec2-user", "ssh_pty": true, "ami_name": "testing {{timestamp}}", "ami_block_device_mappings": [{ "device_name": "/dev/sdf", "volume_type": "gp2", "volume_size": 100, "delete_on_termination": true, "encrypted": true }, { "device_name": "/dev/sdg", "volume_type": "gp2", "volume_size": 100, "delete_on_termination": true, "encrypted": true }] }] }

问题是我使用的是 ami_block_device_mappings 而不是 launch_block_device_mappings。前者仅添加到 AMI 而不是启动实例。 launch_block_device_mappings 已添加到构建 AMI 的实例中,并将创建快照并添加到已注册的 AMI 中。