Skip to content

Commit

Permalink
Check if DescribeKeyPairs returns a result. (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
tasdomas authored Jun 2, 2023
1 parent 6f30c16 commit a0fb6be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion task/aws/resources/resource_key_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"strings"

"github.com/0x2b3bfa0/logrusctx"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
Expand Down Expand Up @@ -90,7 +91,12 @@ func (k *KeyPair) Read(ctx context.Context) error {
return common.NotFoundError
}
}

if pairs == nil {
// Unexpected, but it looks like DescribeKeyPairs may return no error and a nil
// result.
logrusctx.Error(ctx, "EC2 DescribeKeyPairs returned nil result.")
return nil
}
k.Resource = &pairs.KeyPairs[0]
return nil
}
Expand Down

0 comments on commit a0fb6be

Please sign in to comment.