Skip to content

Commit

Permalink
fix(EC2NetworkInterface): fix panic on not attached NetworkInterfaces…
Browse files Browse the repository at this point in the history
… 🐛 (#752)

It is possible, that an interface is not attached. This leads to the fact that no AttachmendId is available. Accordingly, the string can also not be accessed.
  • Loading branch information
hv202x1 authored Mar 4, 2022
1 parent 24750f8 commit 8b0c1d8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions resources/ec2-network-interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ func (e *EC2NetworkInterface) Remove() error {
Force: aws.Bool(true),
})
if err != nil {
expected := fmt.Sprintf("The interface attachment '%s' does not exist.", *e.eni.Attachment.AttachmentId)
if !strings.Contains(err.Error(), expected) {
return err
if e.eni.Attachment.AttachmentId != nil {
expected := fmt.Sprintf("The interface attachment '%s' does not exist.", *e.eni.Attachment.AttachmentId)
if !strings.Contains(err.Error(), expected) {
return err
}
}

}
}

Expand Down

0 comments on commit 8b0c1d8

Please sign in to comment.