@@ -10,7 +10,7 @@ import (
1010 "net/http"
1111 "strings"
1212 "time"
13-
13+ "os"
1414 "github.com/SumoLogic/sumologic-lambda-extensions/lambda-extensions/utils"
1515
1616 "github.com/SumoLogic/sumologic-lambda-extensions/lambda-extensions/config"
@@ -73,6 +73,7 @@ func (s *sumoLogicClient) makeRequest(ctx context.Context, buf *bytes.Buffer) (*
7373 endpoint , err := s .getHttpEndpoint ()
7474 if err != nil {
7575 err = fmt .Errorf ("Failed to get SUMO HTTP Endpoint error: %v" , err )
76+ return nil , err
7677 }
7778
7879 request , err := http .NewRequestWithContext (ctx , "POST" , endpoint , buf )
@@ -94,6 +95,7 @@ func (s *sumoLogicClient) makeRequest(ctx context.Context, buf *bytes.Buffer) (*
9495
9596// Use cached KMS decrypted endpoint, refresh the cached endpoint, or return unencrypted endpoint
9697func (s * sumoLogicClient ) getHttpEndpoint () (string , error ) {
98+
9799 if s .config .KMSKeyId == "" {
98100 return s .config .SumoHTTPEndpoint , nil
99101 }
@@ -114,11 +116,13 @@ func (s *sumoLogicClient) getHttpEndpoint() (string, error) {
114116 blob , err := b64 .StdEncoding .DecodeString (s .config .SumoHTTPEndpoint )
115117 if err != nil {
116118 fmt .Errorf ("Error converting string to blob, error: %v" , err )
119+ return "" , err
117120 }
118121
119122 input := & kms.DecryptInput {
120- CiphertextBlob : blob ,
121- KeyId : aws .String (s .config .KMSKeyId ),
123+ CiphertextBlob : blob ,
124+ KeyId : aws .String (s .config .KMSKeyId ),
125+ EncryptionContext : map [string ]string {"LambdaFunctionName" : os .Getenv ("AWS_LAMBDA_FUNCTION_NAME" )},
122126 }
123127
124128 result , err := DecodeData (context .TODO (), client , input )
0 commit comments