From 90126306ff77502798007ca1dec5ba05b30cf472 Mon Sep 17 00:00:00 2001 From: Mark Butcher Date: Sat, 7 Oct 2023 02:14:25 +1100 Subject: [PATCH] Fix #1707 (#1786) Check for nil before doing type conversion. --- providers/aws/ec2.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/providers/aws/ec2.go b/providers/aws/ec2.go index 112c7de6c5..1c8a53a864 100644 --- a/providers/aws/ec2.go +++ b/providers/aws/ec2.go @@ -94,6 +94,10 @@ func (g *Ec2Generator) PostConvertHook() error { if r.InstanceInfo.Type != "aws_instance" { continue } + if r.Item["root_block_device"] == nil { + continue + } + rootDeviceVolumeType := r.InstanceState.Attributes["root_block_device.0.volume_type"] if !(rootDeviceVolumeType == "io1" || rootDeviceVolumeType == "io2" || rootDeviceVolumeType == "gp3") { delete(r.Item["root_block_device"].([]interface{})[0].(map[string]interface{}), "iops")