From 96dba3af9825fa421d65517ed2fee2233e754279 Mon Sep 17 00:00:00 2001 From: Kavibritto Chalaman Date: Mon, 16 Oct 2023 11:24:58 +0000 Subject: [PATCH] #1089 added nil check on associated KeyPair --- providers/aws/ec2/instances.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/providers/aws/ec2/instances.go b/providers/aws/ec2/instances.go index b4997579a..32eb93c08 100644 --- a/providers/aws/ec2/instances.go +++ b/providers/aws/ec2/instances.go @@ -212,12 +212,14 @@ func getEC2Relations(inst *etype.Instance, resourceArn string) (rel []models.Lin }) // Get associated Keypair - rel = append(rel, models.Link{ - ResourceID: *inst.KeyName, - Name: *inst.KeyName, - Type: "Key Pair", - Relation: "USES", - }) + if inst.KeyName != nil { + rel = append(rel, models.Link{ + ResourceID: *inst.KeyName, + Name: *inst.KeyName, + Type: "Key Pair", + Relation: "USES", + }) + } // Get associated IAM roles if inst.IamInstanceProfile != nil {