diff --git a/.changelog/39039.txt b/.changelog/39039.txt new file mode 100644 index 00000000000..a96c9183335 --- /dev/null +++ b/.changelog/39039.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_elbv2_listener: Fix crash when reading forward actions not configured in state +``` diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index 3646685ddab..012c19e6f27 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -1020,7 +1020,7 @@ func flattenLbForwardAction(d *schema.ResourceData, attrName string, i int, awsA } if rawState := d.GetRawState(); rawState.IsKnown() && !rawState.IsNull() { - if defaultActions := rawState.GetAttr(attrName); defaultActions.LengthInt() > 0 { + if defaultActions := rawState.GetAttr(attrName); defaultActions.IsKnown() && !defaultActions.IsNull() && defaultActions.LengthInt() > 0 { flattenLbForwardActionOneOf(defaultActions, i, awsAction, actionMap) return }